Skip to content

Commit

Permalink
test: Add ReturnsAbstract compliance test
Browse files Browse the repository at this point in the history
Add the ReturnsAbstract test to the complaince suite. This test ensures that proxy implementations are returned from methods that return a abstract class or interface.
  • Loading branch information
costleya committed Sep 21, 2018
1 parent ad1b15b commit 795ce88
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
using System;
using System.Collections.Generic;
using Amazon.JSII.Runtime.Deputy;
using Amazon.JSII.Runtime.Services;
using Amazon.JSII.Tests.CalculatorNamespace;
using Amazon.JSII.Tests.CalculatorNamespace.composition;
using Amazon.JSII.Tests.CalculatorNamespace.composition.CompositeOperation;
using Amazon.JSII.Tests.CalculatorNamespace.LibNamespace;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using Xunit;
using Xunit.Abstractions;

Expand Down Expand Up @@ -784,14 +781,31 @@ public void ReservedKeywordsAreSlugifiedInMethodNames()
}

[Fact(DisplayName = Prefix + nameof(NodeStandardLibrary))]
public void NodeStandardLibrary() {
public void NodeStandardLibrary()
{
NodeStandardLibrary obj = new NodeStandardLibrary();
Assert.Equal("Hello, resource!", obj.FsReadFile());
Assert.Equal("Hello, resource! SYNC!", obj.FsReadFileSync());
Assert.True(obj.OsPlatform.Length > 0);
Assert.Equal("6a2da20943931e9834fc12cfe5bb47bbd9ae43489a30726962b576f4e3993e50",
obj.CryptoSha256());
}

[Fact(DisplayName = Prefix + nameof(ReturnAbstract))]
public void ReturnAbstract()
{
var obj = new AbstractClassReturner();
var obj2 = obj.GiveMeAbstract();

Assert.Equal("Hello, John!!", obj2.AbstractMethod("John"));
Assert.Equal("propFromInterfaceValue", obj2.PropFromInterface);
Assert.Equal(42, obj2.NonAbstractMethod());

var iface = obj.GiveMeInterface();
Assert.Equal("propFromInterfaceValue", iface.PropFromInterface);

Assert.Equal("hello-abstract-property", obj.ReturnAbstractFromProperty.AbstractProperty);
}


class MulTen : Multiply
Expand Down
6 changes: 6 additions & 0 deletions packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime.sln
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "UnitTests", "UnitTests", "{
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Amazon.JSII.Runtime.UnitTests", "Amazon.JSII.Runtime.UnitTests\Amazon.JSII.Runtime.UnitTests.csproj", "{96CC0C0B-1D90-448F-9BFC-07CE93D2CE29}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Amazon.JSII.Runtime.IntegrationTests", "..\..\jsii-dotnet-runtime-test\test\Amazon.JSII.Runtime.IntegrationTests\Amazon.JSII.Runtime.IntegrationTests.csproj", "{4BD49478-03E5-45DD-97D8-A1281E9DC32C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -28,6 +30,10 @@ Global
{96CC0C0B-1D90-448F-9BFC-07CE93D2CE29}.Debug|Any CPU.Build.0 = Debug|Any CPU
{96CC0C0B-1D90-448F-9BFC-07CE93D2CE29}.Release|Any CPU.ActiveCfg = Release|Any CPU
{96CC0C0B-1D90-448F-9BFC-07CE93D2CE29}.Release|Any CPU.Build.0 = Release|Any CPU
{4BD49478-03E5-45DD-97D8-A1281E9DC32C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4BD49478-03E5-45DD-97D8-A1281E9DC32C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4BD49478-03E5-45DD-97D8-A1281E9DC32C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4BD49478-03E5-45DD-97D8-A1281E9DC32C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down

0 comments on commit 795ce88

Please sign in to comment.