Skip to content

Commit

Permalink
Consumed inheritance test projects from TestWinRT and added basic tes…
Browse files Browse the repository at this point in the history
…t cases (#600)

* Added test_component_base

* Added tests for derived classes

* Update get_testwinrt.cmd

* Added test cases for overridden methods
  • Loading branch information
ujjwalchadha committed Nov 25, 2020
1 parent d9f1d21 commit b6ebcbb
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Projections/Test/Test.csproj
Expand Up @@ -8,6 +8,8 @@
<ItemGroup>
<ProjectReference Include="..\..\TestComponentCSharp\TestComponentCSharp.vcxproj" />
<ProjectReference Include="..\..\TestWinRT\TestComponent\TestComponent.vcxproj" />
<ProjectReference Include="..\..\TestWinRT\test_component_base\test_component_base.vcxproj" />
<ProjectReference Include="..\..\TestWinRT\test_component_derived\test_component_derived.vcxproj" />
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
<ProjectReference Include="..\..\WinRT.Runtime\WinRT.Runtime.csproj" />
<ProjectReference Include="..\..\cswinrt\cswinrt.vcxproj" />
Expand All @@ -17,7 +19,7 @@
</ItemGroup>

<PropertyGroup>
<CsWinRTIncludes>TestComponent;TestComponentCSharp</CsWinRTIncludes>
<CsWinRTIncludes>TestComponent;TestComponentCSharp;test_component_base;test_component_derived;</CsWinRTIncludes>
<!--PkgMicrosoft_WinUI is set in in obj\*.csproj.nuget.g.props with TargetFramework condition, doesn't support multi-targeting-->
<PkgMicrosoft_WinUI Condition="'$(PkgMicrosoft_WinUI)'==''">$([MSBuild]::NormalizeDirectory('$(NuGetPackageRoot)', 'microsoft.winui', '$(MicrosoftWinUIVersion)'))</PkgMicrosoft_WinUI>
</PropertyGroup>
Expand Down
30 changes: 30 additions & 0 deletions UnitTest/TestComponent_Tests.cs
Expand Up @@ -2,6 +2,8 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using test_component_base;
using test_component_derived.Nested;
using TestComponent; // Error CS0246? run get_testwinrt.cmd
using Windows.Foundation;
using WinRT;
Expand Down Expand Up @@ -741,5 +743,33 @@ public void Z_Check_Coverage()
Tests.Simple();
//Assert.Equal((double)Tests.Percentage, (double)100);
}

[Fact]
public void TestComposable()
{
HierarchyA hierarchyA = new HierarchyA();
Assert.Equal("HierarchyA.HierarchyA_Method", hierarchyA.HierarchyA_Method());

HierarchyA hierarchyBAsHierarchyA = new HierarchyB();
Assert.Equal("HierarchyB.HierarchyA_Method", hierarchyBAsHierarchyA.HierarchyA_Method());

HierarchyB hierarchyB = new HierarchyB();
Assert.Equal("HierarchyB.HierarchyB_Method", hierarchyB.HierarchyB_Method());

HierarchyC hierarchyC = new HierarchyC();
Assert.Equal("HierarchyC.HierarchyB_Method", hierarchyC.HierarchyB_Method());

HierarchyB hierarchyCAsHierarchyB = new HierarchyC();
Assert.Equal("HierarchyC.HierarchyB_Method", hierarchyCAsHierarchyB.HierarchyB_Method());
Assert.Equal("HierarchyB.HierarchyA_Method", hierarchyCAsHierarchyB.HierarchyA_Method());

HierarchyD hierarchyD = new HierarchyD();
hierarchyD.HierarchyD_Method();

var hierarchyDAsHierarchyA = (HierarchyA)hierarchyD;
Assert.Equal("HierarchyB.HierarchyA_Method", hierarchyDAsHierarchyA.HierarchyA_Method());

Assert.True(hierarchyDAsHierarchyA == hierarchyD);
}
}
}
43 changes: 43 additions & 0 deletions cswinrt.sln
Expand Up @@ -80,6 +80,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AuthoringSample", "Authorin
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AuthoringConsumptionTest", "Authoring\AuthoringConsumptionTest\AuthoringConsumptionTest.vcxproj", "{0212A7C5-8D3F-443C-9EBC-1F28091FDF88}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_component_base", "TestWinRT\test_component_base\test_component_base.vcxproj", "{13333A6F-6A4A-48CD-865C-0F65135EB018}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_component_derived", "TestWinRT\test_component_derived\test_component_derived.vcxproj", "{0080F6D1-AEC3-4F89-ADE1-3D22A7EBF99E}"
ProjectSection(ProjectDependencies) = postProject
{13333A6F-6A4A-48CD-865C-0F65135EB018} = {13333A6F-6A4A-48CD-865C-0F65135EB018}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -390,6 +397,42 @@ Global
{0212A7C5-8D3F-443C-9EBC-1F28091FDF88}.Release|x64.Build.0 = Release|x64
{0212A7C5-8D3F-443C-9EBC-1F28091FDF88}.Release|x86.ActiveCfg = Release|Win32
{0212A7C5-8D3F-443C-9EBC-1F28091FDF88}.Release|x86.Build.0 = Release|Win32
{13333A6F-6A4A-48CD-865C-0F65135EB018}.Debug|Any CPU.ActiveCfg = Debug|Win32
{13333A6F-6A4A-48CD-865C-0F65135EB018}.Debug|ARM.ActiveCfg = Debug|ARM
{13333A6F-6A4A-48CD-865C-0F65135EB018}.Debug|ARM.Build.0 = Debug|ARM
{13333A6F-6A4A-48CD-865C-0F65135EB018}.Debug|ARM64.ActiveCfg = Debug|ARM64
{13333A6F-6A4A-48CD-865C-0F65135EB018}.Debug|ARM64.Build.0 = Debug|ARM64
{13333A6F-6A4A-48CD-865C-0F65135EB018}.Debug|x64.ActiveCfg = Debug|x64
{13333A6F-6A4A-48CD-865C-0F65135EB018}.Debug|x64.Build.0 = Debug|x64
{13333A6F-6A4A-48CD-865C-0F65135EB018}.Debug|x86.ActiveCfg = Debug|Win32
{13333A6F-6A4A-48CD-865C-0F65135EB018}.Debug|x86.Build.0 = Debug|Win32
{13333A6F-6A4A-48CD-865C-0F65135EB018}.Release|Any CPU.ActiveCfg = Release|Win32
{13333A6F-6A4A-48CD-865C-0F65135EB018}.Release|ARM.ActiveCfg = Release|ARM
{13333A6F-6A4A-48CD-865C-0F65135EB018}.Release|ARM.Build.0 = Release|ARM
{13333A6F-6A4A-48CD-865C-0F65135EB018}.Release|ARM64.ActiveCfg = Release|ARM64
{13333A6F-6A4A-48CD-865C-0F65135EB018}.Release|ARM64.Build.0 = Release|ARM64
{13333A6F-6A4A-48CD-865C-0F65135EB018}.Release|x64.ActiveCfg = Release|x64
{13333A6F-6A4A-48CD-865C-0F65135EB018}.Release|x64.Build.0 = Release|x64
{13333A6F-6A4A-48CD-865C-0F65135EB018}.Release|x86.ActiveCfg = Release|Win32
{13333A6F-6A4A-48CD-865C-0F65135EB018}.Release|x86.Build.0 = Release|Win32
{0080F6D1-AEC3-4F89-ADE1-3D22A7EBF99E}.Debug|Any CPU.ActiveCfg = Debug|Win32
{0080F6D1-AEC3-4F89-ADE1-3D22A7EBF99E}.Debug|ARM.ActiveCfg = Debug|ARM
{0080F6D1-AEC3-4F89-ADE1-3D22A7EBF99E}.Debug|ARM.Build.0 = Debug|ARM
{0080F6D1-AEC3-4F89-ADE1-3D22A7EBF99E}.Debug|ARM64.ActiveCfg = Debug|ARM64
{0080F6D1-AEC3-4F89-ADE1-3D22A7EBF99E}.Debug|ARM64.Build.0 = Debug|ARM64
{0080F6D1-AEC3-4F89-ADE1-3D22A7EBF99E}.Debug|x64.ActiveCfg = Debug|x64
{0080F6D1-AEC3-4F89-ADE1-3D22A7EBF99E}.Debug|x64.Build.0 = Debug|x64
{0080F6D1-AEC3-4F89-ADE1-3D22A7EBF99E}.Debug|x86.ActiveCfg = Debug|Win32
{0080F6D1-AEC3-4F89-ADE1-3D22A7EBF99E}.Debug|x86.Build.0 = Debug|Win32
{0080F6D1-AEC3-4F89-ADE1-3D22A7EBF99E}.Release|Any CPU.ActiveCfg = Release|Win32
{0080F6D1-AEC3-4F89-ADE1-3D22A7EBF99E}.Release|ARM.ActiveCfg = Release|ARM
{0080F6D1-AEC3-4F89-ADE1-3D22A7EBF99E}.Release|ARM.Build.0 = Release|ARM
{0080F6D1-AEC3-4F89-ADE1-3D22A7EBF99E}.Release|ARM64.ActiveCfg = Release|ARM64
{0080F6D1-AEC3-4F89-ADE1-3D22A7EBF99E}.Release|ARM64.Build.0 = Release|ARM64
{0080F6D1-AEC3-4F89-ADE1-3D22A7EBF99E}.Release|x64.ActiveCfg = Release|x64
{0080F6D1-AEC3-4F89-ADE1-3D22A7EBF99E}.Release|x64.Build.0 = Release|x64
{0080F6D1-AEC3-4F89-ADE1-3D22A7EBF99E}.Release|x86.ActiveCfg = Release|Win32
{0080F6D1-AEC3-4F89-ADE1-3D22A7EBF99E}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion get_testwinrt.cmd
Expand Up @@ -12,7 +12,7 @@ git checkout -f master
if ErrorLevel 1 popd & exit /b !ErrorLevel!
git fetch -f
if ErrorLevel 1 popd & exit /b !ErrorLevel!
git reset -q --hard 5df065fd3bccf314079e39e1bf2644fd239615c1
git reset -q --hard 24ce20296dd656813b1857115f4e134eab91c2cf
if ErrorLevel 1 popd & exit /b !ErrorLevel!
echo Restoring Nuget
..\.nuget\nuget.exe restore
Expand Down

0 comments on commit b6ebcbb

Please sign in to comment.