Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[Bb]in
[Oo]bj
*.suo
*.user
*.user
/.vs
/packages
66 changes: 66 additions & 0 deletions WhenTheVersion.Tests/AssemblyInfoReaderTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using WhenTheVersion;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace WhenTheVersion.Tests
{
[TestClass()]
public class AssemblyInfoReaderTests
{
string _projectDirectory = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName;

[TestMethod()]
public void GetRevisionInfoTestCaseStraightForward()
{
AssemblyInfoReader assemblyInfoReader = new AssemblyInfoReader(Path.Combine(_projectDirectory, "AssemblyInfoTestCase1.cs"));
var revisionInfo = assemblyInfoReader.GetRevisionInfo();
//In this case it should not fail
Assert.AreEqual(true, revisionInfo.Succeed);
}


[TestMethod()]
public void GetRevisionInfoTestCaseWithAsterisks()
{
AssemblyInfoReader assemblyInfoReader = new AssemblyInfoReader(Path.Combine(_projectDirectory, "AssemblyInfoTestCase2.cs"));
var revisionInfo = assemblyInfoReader.GetRevisionInfo();
//In this case it should not succeed
Assert.AreEqual(true, !revisionInfo.Succeed);

}

[TestMethod()]
public void GetRevisionInfoTestCaseWithComments()
{
AssemblyInfoReader assemblyInfoReader = new AssemblyInfoReader(Path.Combine(_projectDirectory, "AssemblyInfoTestCase3.cs"));
var revisionInfo = assemblyInfoReader.GetRevisionInfo();
//In this case it should succeed
Assert.AreEqual(true, revisionInfo.Succeed);
Assert.AreEqual(16, revisionInfo.NextRevisionNumber);
}


[TestMethod()]
public void GetRevisionInfoTestCaseMissingAssemblyVersionInfo()
{
AssemblyInfoReader assemblyInfoReader = new AssemblyInfoReader(Path.Combine(_projectDirectory, "AssemblyInfoTestCase4.cs"));
var revisionInfo = assemblyInfoReader.GetRevisionInfo();
//This needs to fail as file doesn't have AssemblyInfo line
Assert.AreEqual(false, revisionInfo.Succeed);
}

[TestMethod()]
[ExpectedException(typeof(FileNotFoundException))]
public void GetRevisionInfoTestCaseMissingFile()
{
AssemblyInfoReader assemblyInfoReader = new AssemblyInfoReader(Path.Combine(_projectDirectory, "AssemblyInfoTestCase6.cs"));
//This needs to throw FileNotFoundException
var revisionInfo = assemblyInfoReader.GetRevisionInfo();
}
}
}
26 changes: 26 additions & 0 deletions WhenTheVersion.Tests/AssemblyInfoTestCase1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("e54a2b6f-998e-45e0-9329-8117e77e3067")]

[assembly: AssemblyVersion("2019.6.20.0")]
[assembly: AssemblyFileVersion("2019.6.20.0")]
26 changes: 26 additions & 0 deletions WhenTheVersion.Tests/AssemblyInfoTestCase2.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("e54a2b6f-998e-45e0-9329-8117e77e3067")]

[assembly: AssemblyVersion("2019.6.*")]
[assembly: AssemblyFileVersion("2019.6.*")]
29 changes: 29 additions & 0 deletions WhenTheVersion.Tests/AssemblyInfoTestCase3.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("e54a2b6f-998e-45e0-9329-8117e77e3067")]

//[assembly: AssemblyVersion("2019.6.20.1")] - This should not be used and next version should be 16
//[assembly: AssemblyVersion("2019.6.20.12")] - This should not be used and next version should be 16

[assembly: AssemblyVersion("2019.6.20.15")]
[assembly: AssemblyFileVersion("2019.6.20.15")]
26 changes: 26 additions & 0 deletions WhenTheVersion.Tests/AssemblyInfoTestCase4.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("e54a2b6f-998e-45e0-9329-8117e77e3067")]

//[assembly: AssemblyVersion("2019.6.20.1")] - This should not be used and next version should be 0
//[assembly: AssemblyVersion("2019.6.20.12")] - This should not be used and next version should be 0
36 changes: 36 additions & 0 deletions WhenTheVersion.Tests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("WhenTheVersion.Tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WhenTheVersion.Tests")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("b8012fc7-6098-416c-a5da-ad266ca00030")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
110 changes: 110 additions & 0 deletions WhenTheVersion.Tests/WhenTheVersion.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{B8012FC7-6098-416C-A5DA-AD266CA00030}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>WhenTheVersion.Tests</RootNamespace>
<AssemblyName>WhenTheVersion.Tests</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
</Reference>
<Reference Include="System" />
</ItemGroup>
<Choose>
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
</ItemGroup>
</When>
<Otherwise />
</Choose>
<ItemGroup>
<Compile Include="AssemblyInfoReaderTests.cs" />
<None Include="AssemblyInfoTestCase1.cs" />
<None Include="AssemblyInfoTestCase2.cs" />
<None Include="AssemblyInfoTestCase3.cs" />
<None Include="AssemblyInfoTestCase4.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WhenTheVersion\WhenTheVersion.csproj">
<Project>{2cacb06c-1f98-4938-a333-92eba724cef9}</Project>
<Name>WhenTheVersion</Name>
</ProjectReference>
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
</ItemGroup>
</When>
</Choose>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props'))" />
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets'))" />
</Target>
<Import Project="..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
5 changes: 5 additions & 0 deletions WhenTheVersion.Tests/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MSTest.TestAdapter" version="1.3.2" targetFramework="net46" />
<package id="MSTest.TestFramework" version="1.3.2" targetFramework="net46" />
</packages>
19 changes: 17 additions & 2 deletions WhenTheVersion.sln
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29009.5
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WhenTheVersion", "WhenTheVersion\WhenTheVersion.csproj", "{2CACB06C-1F98-4938-A333-92EBA724CEF9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WhenTheVersion.Tests", "WhenTheVersion.Tests\WhenTheVersion.Tests.csproj", "{B8012FC7-6098-416C-A5DA-AD266CA00030}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -19,8 +23,19 @@ Global
{2CACB06C-1F98-4938-A333-92EBA724CEF9}.Release|Any CPU.Build.0 = Release|Any CPU
{2CACB06C-1F98-4938-A333-92EBA724CEF9}.Release|x86.ActiveCfg = Release|x86
{2CACB06C-1F98-4938-A333-92EBA724CEF9}.Release|x86.Build.0 = Release|x86
{B8012FC7-6098-416C-A5DA-AD266CA00030}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B8012FC7-6098-416C-A5DA-AD266CA00030}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B8012FC7-6098-416C-A5DA-AD266CA00030}.Debug|x86.ActiveCfg = Debug|Any CPU
{B8012FC7-6098-416C-A5DA-AD266CA00030}.Debug|x86.Build.0 = Debug|Any CPU
{B8012FC7-6098-416C-A5DA-AD266CA00030}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B8012FC7-6098-416C-A5DA-AD266CA00030}.Release|Any CPU.Build.0 = Release|Any CPU
{B8012FC7-6098-416C-A5DA-AD266CA00030}.Release|x86.ActiveCfg = Release|Any CPU
{B8012FC7-6098-416C-A5DA-AD266CA00030}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8DC6B4A4-B8E9-43BD-949D-9F1201181102}
EndGlobalSection
EndGlobal
Loading