Skip to content

Commit

Permalink
converted unit tests to .net core and added back to solution
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinKa committed Mar 11, 2019
1 parent 1c93994 commit 3a90d08
Show file tree
Hide file tree
Showing 12 changed files with 92 additions and 238 deletions.
12 changes: 12 additions & 0 deletions NetPrints.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetPrints", "NetPrints\NetP
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetPrintsEditor", "NetPrintsEditor\NetPrintsEditor.csproj", "{D967186E-1D97-4CED-BC7B-DE5FBA3D5989}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetPrintsUnitTests", "NetPrintsUnitTests\NetPrintsUnitTests.csproj", "{B45C37E8-A539-48E1-B714-774DB8645F9B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetPrintsEditorUnitTests", "NetPrintsEditorUnitTests\NetPrintsEditorUnitTests.csproj", "{B4288686-0B8A-453C-B654-4257F56BAB33}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -21,6 +25,14 @@ Global
{D967186E-1D97-4CED-BC7B-DE5FBA3D5989}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D967186E-1D97-4CED-BC7B-DE5FBA3D5989}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D967186E-1D97-4CED-BC7B-DE5FBA3D5989}.Release|Any CPU.Build.0 = Release|Any CPU
{B45C37E8-A539-48E1-B714-774DB8645F9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B45C37E8-A539-48E1-B714-774DB8645F9B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B45C37E8-A539-48E1-B714-774DB8645F9B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B45C37E8-A539-48E1-B714-774DB8645F9B}.Release|Any CPU.Build.0 = Release|Any CPU
{B4288686-0B8A-453C-B654-4257F56BAB33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B4288686-0B8A-453C-B654-4257F56BAB33}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B4288686-0B8A-453C-B654-4257F56BAB33}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B4288686-0B8A-453C-B654-4257F56BAB33}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
99 changes: 21 additions & 78 deletions NetPrintsEditorUnitTests/NetPrintsEditorUnitTests.csproj
Original file line number Diff line number Diff line change
@@ -1,79 +1,22 @@
<?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.1.11\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.1.1.11\build\net45\MSTest.TestAdapter.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{B4288686-0B8A-453C-B654-4257F56BAB33}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>NetPrintsEditorUnitTests</RootNamespace>
<AssemblyName>NetPrintsEditorUnitTests</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.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>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworkProfile />
</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.1.11\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.1.11\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="PinTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NetPrintsEditor\NetPrintsEditor.csproj">
<Project>{d967186e-1d97-4ced-bc7b-de5fba3d5989}</Project>
<Name>NetPrintsEditor</Name>
</ProjectReference>
<ProjectReference Include="..\NetPrints\NetPrints.csproj">
<Project>{9f33e024-e65f-4954-9df2-a1a26d68c0ad}</Project>
<Name>NetPrints</Name>
</ProjectReference>
</ItemGroup>
<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.1.11\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.1.11\build\net45\MSTest.TestAdapter.props'))" />
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.1.11\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.1.11\build\net45\MSTest.TestAdapter.targets'))" />
</Target>
<Import Project="..\packages\MSTest.TestAdapter.1.1.11\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.1.1.11\build\net45\MSTest.TestAdapter.targets')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.0-preview-20181205-02" />
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\NetPrintsEditor\NetPrintsEditor.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>

</Project>
19 changes: 0 additions & 19 deletions NetPrintsEditorUnitTests/Properties/AssemblyInfo.cs

This file was deleted.

5 changes: 0 additions & 5 deletions NetPrintsEditorUnitTests/packages.config

This file was deleted.

20 changes: 11 additions & 9 deletions NetPrintsUnitTests/ClassTranslatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void CreateStringLengthMethod()
{
List<TypeSpecifier> returnTypes = new List<TypeSpecifier>()
{
typeof(int),
TypeSpecifier.FromType<int>(),
};

// Create method
Expand All @@ -34,8 +34,8 @@ public void CreateStringLengthMethod()
stringLengthMethod.ReturnTypes.AddRange(returnTypes);

// Create nodes
VariableGetterNode getStringNode = new VariableGetterNode(stringLengthMethod, cls.Type, "testVariable", typeof(string));
VariableGetterNode getLengthNode = new VariableGetterNode(stringLengthMethod, cls.Type, "Length", typeof(int));
VariableGetterNode getStringNode = new VariableGetterNode(stringLengthMethod, cls.Type, "testVariable", TypeSpecifier.FromType<string>());
VariableGetterNode getLengthNode = new VariableGetterNode(stringLengthMethod, cls.Type, "Length", TypeSpecifier.FromType<int>());

// Connect node execs
GraphUtil.ConnectExecPins(stringLengthMethod.EntryNode.InitialExecutionPin, stringLengthMethod.ReturnNode.ReturnPin);
Expand All @@ -53,12 +53,14 @@ public void CreateMainMethod()
Modifiers = MethodModifiers.Static
};

MethodSpecifier stringLengthSpecifier = new MethodSpecifier("StringLength", new List<TypeSpecifier>(), new List<TypeSpecifier>() { typeof(int) }, MethodModifiers.Public, typeof(string), Array.Empty<BaseType>());
MethodSpecifier writeConsoleSpecifier = typeof(Console).GetMethods().Single(m => m.Name == "WriteLine" && m.GetParameters().Length == 1 && m.GetParameters()[0].ParameterType == typeof(string));
MethodSpecifier stringLengthSpecifier = new MethodSpecifier("StringLength", new List<TypeSpecifier>(), new List<TypeSpecifier>() { TypeSpecifier.FromType<int>() }, MethodModifiers.Public, TypeSpecifier.FromType<string>(), Array.Empty<BaseType>());
//MethodSpecifier writeConsoleSpecifier = typeof(Console).GetMethods().Single(m => m.Name == "WriteLine" && m.GetParameters().Length == 1 && m.GetParameters()[0].ParameterType == typeof(string));
TypeSpecifier stringType = TypeSpecifier.FromType<string>();
MethodSpecifier writeConsoleSpecifier = new MethodSpecifier("WriteLine", new BaseType[] { stringType }, new BaseType[0], MethodModifiers.Public, TypeSpecifier.FromType(typeof(Console)), new BaseType[0]);

// Create nodes
LiteralNode stringLiteralNode = new LiteralNode(mainMethod, typeof(string), "Hello World");
VariableSetterNode setStringNode = new VariableSetterNode(mainMethod, cls.Type, "testVariable", typeof(string));
LiteralNode stringLiteralNode = new LiteralNode(mainMethod, TypeSpecifier.FromType<string>(), "Hello World");
VariableSetterNode setStringNode = new VariableSetterNode(mainMethod, cls.Type, "testVariable", TypeSpecifier.FromType<string>());
CallMethodNode getStringLengthNode = new CallMethodNode(mainMethod, stringLengthSpecifier);
CallMethodNode writeConsoleNode = new CallMethodNode(mainMethod, writeConsoleSpecifier);

Expand All @@ -82,13 +84,13 @@ public void Setup()
{
Name = "TestClass",
Namespace = "TestNamespace",
SuperType = typeof(object)
SuperType = TypeSpecifier.FromType<object>()
};

CreateStringLengthMethod();
CreateMainMethod();

cls.Attributes.Add(new Variable("testVariable", typeof(string)));
cls.Attributes.Add(new Variable("testVariable", TypeSpecifier.FromType<string>()));
cls.Methods.Add(stringLengthMethod);
cls.Methods.Add(mainMethod);
}
Expand Down
8 changes: 4 additions & 4 deletions NetPrintsUnitTests/DelegateTranslatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void TestDelegate()

List<TypeSpecifier> returnTypes = new List<TypeSpecifier>()
{
typeof(Func<int, string, float>)
TypeSpecifier.FromType<Func<int, string, float>>(),
};

// Create method
Expand All @@ -40,10 +40,10 @@ public void TestDelegate()
delegateMethod.ReturnTypes.AddRange(returnTypes);

MethodSpecifier delegateMethodSpecifier = new MethodSpecifier("TestMethod",
new BaseType[] { typeof(int), typeof(string) },
new BaseType[] { typeof(float) },
new BaseType[] { TypeSpecifier.FromType<int>(), TypeSpecifier.FromType<string>() },
new BaseType[] { TypeSpecifier.FromType<float>() },
MethodModifiers.Static,
typeof(double),
TypeSpecifier.FromType<double>(),
Array.Empty<BaseType>());

// Create nodes
Expand Down
4 changes: 2 additions & 2 deletions NetPrintsUnitTests/GenericsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void TestGenerics()
openClass.Namespace = "Namespace";
openClass.DeclaredGenericArguments.Add(genericClassArg);

TypeSpecifier listType = typeof(List<>);
TypeSpecifier listType = TypeSpecifier.FromType(typeof(List<>));

Assert.AreEqual(listType.GenericArguments.Count, 1);

Expand All @@ -43,7 +43,7 @@ public void TestGenerics()
closedClass.Name = "ClosedClass";
closedClass.Namespace = "Namespace";

TypeSpecifier closedListType = typeof(List<string>);
TypeSpecifier closedListType = TypeSpecifier.FromType<string>();

Method closedMethod = new Method("ClosedMethod");
closedMethod.ArgumentTypes.Add(closedListType);
Expand Down
16 changes: 8 additions & 8 deletions NetPrintsUnitTests/MethodTranslatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ public void CreateStringLengthMethod()
{
List<TypeSpecifier> argumentTypes = new List<TypeSpecifier>()
{
typeof(string),
TypeSpecifier.FromType<string>(),
};

List<TypeSpecifier> returnTypes = new List<TypeSpecifier>()
{
typeof(int),
TypeSpecifier.FromType<int>(),
};

// Create method
Expand All @@ -47,7 +47,7 @@ public void CreateStringLengthMethod()
stringLengthMethod.ReturnTypes.AddRange(returnTypes);

// Create nodes
VariableGetterNode getLengthNode = new VariableGetterNode(stringLengthMethod, typeof(string), "Length", typeof(int));
VariableGetterNode getLengthNode = new VariableGetterNode(stringLengthMethod, TypeSpecifier.FromType<string>(), "Length", TypeSpecifier.FromType<int>());

// Connect node execs
GraphUtil.ConnectExecPins(stringLengthMethod.EntryNode.InitialExecutionPin, stringLengthMethod.ReturnNode.ReturnPin);
Expand All @@ -61,13 +61,13 @@ public void CreateIfElseMethod()
{
List<TypeSpecifier> argumentTypes = new List<TypeSpecifier>()
{
typeof(int),
typeof(bool),
TypeSpecifier.FromType<int>(),
TypeSpecifier.FromType<bool>(),
};

List<TypeSpecifier> returnTypes = new List<TypeSpecifier>()
{
typeof(int),
TypeSpecifier.FromType<int>(),
};

// Create method
Expand All @@ -80,7 +80,7 @@ public void CreateIfElseMethod()

// Create nodes
IfElseNode ifElseNode = new IfElseNode(ifElseMethod);
LiteralNode literalNode = new LiteralNode(ifElseMethod, typeof(int), 123);
LiteralNode literalNode = new LiteralNode(ifElseMethod, TypeSpecifier.FromType<int>(), 123);

// Connect exec nodes
GraphUtil.ConnectExecPins(ifElseMethod.EntryNode.InitialExecutionPin, ifElseNode.ExecutionPin);
Expand All @@ -102,7 +102,7 @@ public void CreateForLoopMethod()
};

// Create nodes
LiteralNode maxIndexLiteralNode = new LiteralNode(forLoopMethod, typeof(int), 10);
LiteralNode maxIndexLiteralNode = new LiteralNode(forLoopMethod, TypeSpecifier.FromType<int>(), 10);
ForLoopNode forLoopNode = new ForLoopNode(forLoopMethod);

// Connect exec nodes
Expand Down
Loading

0 comments on commit 3a90d08

Please sign in to comment.