Skip to content

Commit

Permalink
Remove newline in update file (#114)
Browse files Browse the repository at this point in the history
* Remove the empty line from the version information file.
See https://keepass.info/help/v2_dev/plg_index.html#upd
* Add version file tests
  • Loading branch information
robinvanpoppel committed Apr 12, 2020
1 parent a9fc816 commit ae29600
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 11 deletions.
16 changes: 6 additions & 10 deletions KeeTrayTOTP.Tests/KeeTrayTOTP.Tests.csproj
@@ -1,22 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{7911FEEB-D902-49D1-8A55-CD761D66D58D}</ProjectGuid>
<TargetFramework>net45</TargetFramework>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TestProjectType>UnitTest</TestProjectType>
<TargetFramework>net472</TargetFramework>
<AssemblyTitle>KeeTrayTOTP.Tests</AssemblyTitle>
<Product>KeeTrayTOTP.Tests</Product>
<Copyright>Copyright © $([System.DateTime]::Now.ToString(yyyy))</Copyright>
<OutputPath>bin\$(Configuration)\</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugType>full</DebugType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
</PropertyGroup>
<ItemGroup>
<Content Include="..\version_manifest.txt" Link="version_manifest.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.1" />
Expand Down
52 changes: 52 additions & 0 deletions KeeTrayTOTP.Tests/VersionInformationTests.cs
@@ -0,0 +1,52 @@
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.IO;
using System.Linq;
using System.Reflection;

namespace KeeTrayTOTP.Tests
{
[TestClass]
public class VersionInformationTests
{
private readonly string[] VersionInformationLines = File.ReadAllLines("version_manifest.txt");

[TestMethod]
public void VersionFile_ShouldHaveCorrectLength()
{
VersionInformationLines.Should().HaveCountGreaterOrEqualTo(3, "File should be a minimum of 3 lines");
}

[TestMethod]
public void VersionFile_ShouldNotContainEmptyLines()
{
VersionInformationLines.Should().NotContain("", "File should not contain empty lines");
}

[TestMethod]
public void VersionFile_ShouldStartAndEndWithSeparators()
{
var separator = VersionInformationLines.First();
separator.Should().HaveLength(1);
VersionInformationLines.Last().Should().Be(separator, "File should start and end with the same separator");
}

[TestMethod]
public void VersionFile_ShouldContainSingleEntryForPluginWithCurrentVersion()
{
var separatorArray = new[] { VersionInformationLines.First() };
var pluginLines = VersionInformationLines.Except(separatorArray);
pluginLines.Should().HaveCount(1);

var updateParts = pluginLines.Single().Split(separatorArray, System.StringSplitOptions.RemoveEmptyEntries);
updateParts.Should().HaveCount(2);

var assembly = typeof(KeeTrayTOTPExt).Assembly;
var assemblyFileVersionAttribute = assembly.GetCustomAttribute<AssemblyFileVersionAttribute>();
var assemblyTitleAttribute = assembly.GetCustomAttribute<AssemblyTitleAttribute>();

updateParts.First().Should().Be(assemblyTitleAttribute.Title, "First part should equal the plugin name");
updateParts.Last().Should().Be(assemblyFileVersionAttribute.Version, "Last part should equal the current plugin version.");
}
}
}
1 change: 0 additions & 1 deletion version_manifest.txt
@@ -1,4 +1,3 @@
:
KeeTrayTOTP:0.103.0.0

:

0 comments on commit ae29600

Please sign in to comment.