Skip to content

Commit

Permalink
Refactoring tests
Browse files Browse the repository at this point in the history
  • Loading branch information
David-Desmaisons committed Dec 27, 2015
1 parent 65505f0 commit c96019c
Show file tree
Hide file tree
Showing 14 changed files with 180 additions and 137 deletions.
1 change: 1 addition & 0 deletions .nuget/packages.config
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="xunit.runners" version="1.9.2" />
<package id="xunit.runners" version="2.0.0" />
</packages>
14 changes: 14 additions & 0 deletions MVVM.CEFGlue.sln
Expand Up @@ -52,6 +52,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MVVM.Awesomium", "MVVM.Awes
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MVVM_Awesonium_UI", "MVVM_Awesonium_UI\MVVM_Awesonium_UI.csproj", "{723A4723-FAE8-4B50-B061-A4C599F4722E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MVVM.Component.Test", "MVVM.Component.Test\MVVM.Component.Test.csproj", "{371234C6-4903-4F7D-8283-C0F8DBEF8755}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -290,6 +292,17 @@ Global
{723A4723-FAE8-4B50-B061-A4C599F4722E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{723A4723-FAE8-4B50-B061-A4C599F4722E}.Release|x86.ActiveCfg = Release|x86
{723A4723-FAE8-4B50-B061-A4C599F4722E}.Release|x86.Build.0 = Release|x86
{371234C6-4903-4F7D-8283-C0F8DBEF8755}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{371234C6-4903-4F7D-8283-C0F8DBEF8755}.Debug|Any CPU.Build.0 = Debug|Any CPU
{371234C6-4903-4F7D-8283-C0F8DBEF8755}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{371234C6-4903-4F7D-8283-C0F8DBEF8755}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{371234C6-4903-4F7D-8283-C0F8DBEF8755}.Debug|x86.ActiveCfg = Debug|x86
{371234C6-4903-4F7D-8283-C0F8DBEF8755}.Debug|x86.Build.0 = Debug|x86
{371234C6-4903-4F7D-8283-C0F8DBEF8755}.Release|Any CPU.ActiveCfg = Release|Any CPU
{371234C6-4903-4F7D-8283-C0F8DBEF8755}.Release|Any CPU.Build.0 = Release|Any CPU
{371234C6-4903-4F7D-8283-C0F8DBEF8755}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{371234C6-4903-4F7D-8283-C0F8DBEF8755}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{371234C6-4903-4F7D-8283-C0F8DBEF8755}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -309,6 +322,7 @@ Global
{84916CEB-FEF3-4A42-B1A0-7B43F3D88CCB} = {B3321797-0DAA-40DF-ADD3-13AC511028EF}
{E35B9010-5429-4FFE-A788-E9C40E743E9C} = {6F066820-11A1-4533-A8CF-C7E43891D2BD}
{723A4723-FAE8-4B50-B061-A4C599F4722E} = {0F0F34BE-CD06-4C13-967D-BB0760617486}
{371234C6-4903-4F7D-8283-C0F8DBEF8755} = {B3321797-0DAA-40DF-ADD3-13AC511028EF}
EndGlobalSection
GlobalSection(CodealikeProperties) = postSolution
SolutionGuid = 21ee2d50-c4fe-49f3-a899-1dc535d57fcf
Expand Down
94 changes: 94 additions & 0 deletions MVVM.Component.Test/MVVM.Component.Test.csproj
@@ -0,0 +1,94 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{371234C6-4903-4F7D-8283-C0F8DBEF8755}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MVVM.Component.Test</RootNamespace>
<AssemblyName>MVVM.Component.Test</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</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>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="FluentAssertions">
<HintPath>..\packages\FluentAssertions.4.1.1\lib\net45\FluentAssertions.dll</HintPath>
</Reference>
<Reference Include="FluentAssertions.Core">
<HintPath>..\packages\FluentAssertions.4.1.1\lib\net45\FluentAssertions.Core.dll</HintPath>
</Reference>
<Reference Include="NSubstitute">
<HintPath>..\packages\NSubstitute.1.9.2.0\lib\net45\NSubstitute.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="xunit">
<HintPath>..\packages\xunit.1.9.2\lib\net20\xunit.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RelaySimpleCommandTest.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MVVM.Component\MVVM.Component.csproj">
<Project>{26203c44-279d-4bfe-b17a-f6ada8d240ed}</Project>
<Name>MVVM.Component</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.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>
36 changes: 36 additions & 0 deletions MVVM.Component.Test/Properties/AssemblyInfo.cs
@@ -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("MVVM.Component.Test")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MVVM.Component.Test")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[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("487c5802-213c-423c-b84a-1620cbbb21c2")]

// 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")]
Expand Up @@ -2,12 +2,12 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NSubstitute;
using Xunit;
using FluentAssertions;
using System.Threading.Tasks;
using NSubstitute;

namespace MVVM.Cef.Glue.Test
namespace MVVM.Component.Test
{
public class RelaySimpleCommandTest
{
Expand Down Expand Up @@ -49,6 +49,20 @@ public void RelayResultCommandShouldCallFunctionGeneric()
res.Should().Be(122);
}

[Fact]
public void RelayResultCommandCreate_CreateCommandThatCallFunctionGeneric()
{
var function = Substitute.For<Func<object, int>>();
var arg = new object();
function.Invoke(arg).Returns(122);
var target = RelayResultCommand.Create(function);

var res = target.Execute(arg).Result;

function.Received(1).Invoke(arg);
res.Should().Be(122);
}

[Fact]
public void RelayResultCommandShouldHandleExceptionFunctionGeneric()
{
Expand Down
7 changes: 7 additions & 0 deletions MVVM.Component.Test/packages.config
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FluentAssertions" version="4.1.1" targetFramework="net45" />
<package id="NSubstitute" version="1.9.2.0" targetFramework="net45" />
<package id="xunit" version="1.9.2" targetFramework="net40" />
<package id="xunit.runners" version="1.9.2" targetFramework="net40" />
</packages>
17 changes: 0 additions & 17 deletions MVVM.Component/Infra/TaskHelper.cs

This file was deleted.

1 change: 0 additions & 1 deletion MVVM.Component/MVVM.Component.csproj
Expand Up @@ -63,7 +63,6 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Infra\TaskHelper.cs" />
<Compile Include="IResultCommand.cs" />
<Compile Include="ISimpleCommand.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down
5 changes: 2 additions & 3 deletions MVVM.Component/Relay/RelayResultCommand.cs
Expand Up @@ -3,7 +3,6 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MVVM.Component.Infra;

namespace MVVM.Component
{
Expand Down Expand Up @@ -32,9 +31,9 @@ public RelayResultCommand(Func<Tin, Task<TResult>> iResultBuilder)
_ResultBuilder = iResultBuilder;
}

public Task<object> Execute(object iargument)
public async Task<object> Execute(object iargument)
{
return _ResultBuilder((Tin)iargument).Convert();
return await _ResultBuilder((Tin)iargument);
}
}

Expand Down
10 changes: 6 additions & 4 deletions Tests/MVVM.Cef.Glue.Test.csproj
Expand Up @@ -100,8 +100,6 @@
<Compile Include="CefWindowless\TestCefLoadHandler.cs" />
<Compile Include="CefWindowless\TestCefClient.cs" />
<Compile Include="CefWindowless\TestCefRenderHandler.cs" />
<Compile Include="MVVM.Component\TaskHelperTest.cs" />
<Compile Include="MVVM.Component\RelaySimpleCommandTest.cs" />
<Compile Include="Test.Core\TestInContext.cs" />
<Compile Include="Test_CefTask_Action.cs" />
<Compile Include="Test_HTMLApp.cs" />
Expand Down Expand Up @@ -183,11 +181,15 @@
<Content Include="javascript\empty.html">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Include="app.config" />
<None Include="app.config">
<SubType>Designer</SubType>
</None>
<None Include="Navigation data\js\Ko_Extension.min.js.map">
<DependentUpon>Ko_Extension.min.js</DependentUpon>
</None>
<None Include="packages.config" />
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<Content Include="javascript\navigation_3.html">
Expand Down
52 changes: 0 additions & 52 deletions Tests/MVVM.Component/RelaySimpleCommandTest.cs

This file was deleted.

8 changes: 0 additions & 8 deletions Tests/Test_ConvertToJSO.cs
Expand Up @@ -67,10 +67,6 @@ protected override void Init()
_Tests_NG.Add(_Tests[0]);
}





[Fact]
public void Test_Simple()
{
Expand All @@ -88,7 +84,6 @@ public void Test_Simple()
});
}


[Fact]
public void Test_List()
{
Expand Down Expand Up @@ -155,7 +150,6 @@ public void Test_List_Not_Generic()
});
}


[Fact]
public void Test_Double()
{
Expand Down Expand Up @@ -232,7 +226,6 @@ public void Test_Bool_False()
});
}


[Fact]
public void Test_String()
{
Expand All @@ -258,6 +251,5 @@ public void Test_Object_Double_reference()
_ICSharpMapper.Received().Cache(_Test, Arg.Any<IJSCSGlue>());
});
}

}
}

0 comments on commit c96019c

Please sign in to comment.