Skip to content

Commit

Permalink
#4-Repeat tests for each code generator
Browse files Browse the repository at this point in the history
  • Loading branch information
TimothyK committed Sep 4, 2017
1 parent 6d6fd54 commit 5cb8daa
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 8 deletions.
16 changes: 8 additions & 8 deletions StronglyTypedEnumConverter_Tests/BasicEnumTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,28 @@
namespace StronglyTypedEnumConverter
{
[TestClass]
public class BasicEnumTests
public abstract class BasicEnumTests
{
private static Type _type;

[ClassInitialize]
public static void ClassInit(TestContext context)
protected static void ClassInit(Action<GeneratorOptions> adjustOptions)
{
_type = CompiledStrongTypeFromEnumSourceCode("enum CowboyType {Good,Bad,Ugly};");
_type = CompiledStrongTypeFromEnumSourceCode(adjustOptions);
EnumMembers = _type.GetEnumMembers();
EnumValues = _type.GetEnumMemberValues();
}


private const string SourceCode = "enum CowboyType {Good,Bad,Ugly};";

/// <summary>
/// Compiles enum source code to an in-memory strongly typed Type
/// </summary>
/// <param name="enumSourceCode"></param>
/// <param name="adjustOptions"></param>
/// <returns></returns>
private static Type CompiledStrongTypeFromEnumSourceCode(string enumSourceCode)
private static Type CompiledStrongTypeFromEnumSourceCode(Action<GeneratorOptions> adjustOptions)
{
var converter = new Converter();
var stronglyTypedSourceCode = converter.Convert(enumSourceCode);
var stronglyTypedSourceCode = converter.Convert(SourceCode, adjustOptions);
Console.WriteLine(stronglyTypedSourceCode);

var compiler = new Compiler();
Expand Down
16 changes: 16 additions & 0 deletions StronglyTypedEnumConverter_Tests/MemberEnumTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace StronglyTypedEnumConverter
{
[TestClass]
public class MemberEnumTests : BasicEnumTests
{

[ClassInitialize]
public static void ClassInit(TestContext context)
{
BasicEnumTests.ClassInit(options => options.AdditionPriority = AdditionPriority.Members);
}

}
}
16 changes: 16 additions & 0 deletions StronglyTypedEnumConverter_Tests/PropertyEnumTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace StronglyTypedEnumConverter
{
[TestClass]
public class PropertyEnumTests : BasicEnumTests
{

[ClassInitialize]
public static void ClassInit(TestContext context)
{
BasicEnumTests.ClassInit(options => options.AdditionPriority = AdditionPriority.Properties);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@
<Compile Include="CowboyType.cs" />
<Compile Include="CowboyTypeTests.cs" />
<Compile Include="InitializationTests.cs" />
<Compile Include="MemberEnumTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="PropertyEnumTests.cs" />
<Compile Include="ReflectionExtensions.cs" />
</ItemGroup>
<ItemGroup>
Expand Down

0 comments on commit 5cb8daa

Please sign in to comment.