Skip to content
This repository has been archived by the owner on Jun 10, 2023. It is now read-only.

Commit

Permalink
add WPF tests
Browse files Browse the repository at this point in the history
  • Loading branch information
j2ghz committed Aug 15, 2018
1 parent 674af3a commit 6df1cf4
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ModSink.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ModSink.CLI", "src\ModSink.
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ModSink.WPF", "src\ModSink.WPF\ModSink.WPF.csproj", "{09EF7B2D-08FB-4320-A945-F2276D337509}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModSink.WPF.Tests", "src\ModSink.WPF.Tests\ModSink.WPF.Tests.csproj", "{E81DD4A7-D3F1-41E0-B143-FD729E45FA85}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -33,6 +35,10 @@ Global
{09EF7B2D-08FB-4320-A945-F2276D337509}.Debug|Any CPU.Build.0 = Debug|Any CPU
{09EF7B2D-08FB-4320-A945-F2276D337509}.Release|Any CPU.ActiveCfg = Release|Any CPU
{09EF7B2D-08FB-4320-A945-F2276D337509}.Release|Any CPU.Build.0 = Release|Any CPU
{E81DD4A7-D3F1-41E0-B143-FD729E45FA85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E81DD4A7-D3F1-41E0-B143-FD729E45FA85}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E81DD4A7-D3F1-41E0-B143-FD729E45FA85}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E81DD4A7-D3F1-41E0-B143-FD729E45FA85}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 2 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ artifacts:
test_script:
- cmd: dotnet test "src\ModSink.Common.Tests\ModSink.Common.Tests.csproj" --configuration Release --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
- cmd: codecov -f "src\ModSink.Common.Tests\coverage.opencover.xml" -t 78e056d7-ce59-4f6d-b177-85fa3501d898
- cmd: dotnet test "src\ModSink.WPF.Tests\ModSink.WPF.Tests.csproj" --configuration Release --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
- cmd: codecov -f "src\ModSink.WPF.Tests\coverage.opencover.xml" -t 78e056d7-ce59-4f6d-b177-85fa3501d898

deploy:
- provider: GitHub
Expand Down
23 changes: 23 additions & 0 deletions src/ModSink.WPF.Tests/ModSink.WPF.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net462</TargetFramework>

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

<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="2.2.1" />
<PackageReference Include="FluentAssertions" Version="5.4.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
<PackageReference Include="ReactiveUI.Testing" Version="8.3.1" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ModSink.WPF\ModSink.WPF.csproj" />
</ItemGroup>

</Project>
34 changes: 34 additions & 0 deletions src/ModSink.WPF.Tests/ViewModel/LibraryViewModelTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;
using DynamicData;
using FluentAssertions;
using ModSink.Common.Models.Repo;
using ModSink.WPF.ViewModel;
using Xunit;

namespace ModSink.WPF.Tests.ViewModel
{
public class LibraryViewModelTests
{
[Fact]
public void ModpacksContructorInitialization()
{
var source = new SourceCache<Modpack, Guid>(_ => Guid.NewGuid());
var vm = new LibraryViewModel(source);
vm.Modpacks.Should().HaveCount(0);
source.AddOrUpdate(new Modpack());
vm.Modpacks.Should().HaveCount(1);
}

[Fact]
public void SelectedModpackNotifies()
{
var source = new SourceCache<Modpack, Guid>(_ => Guid.NewGuid());
var vm = new LibraryViewModel(source);
using (var monitor = vm.Monitor())
{
vm.SelectedModpack = new Modpack();
monitor.Should().RaisePropertyChangeFor(x => x.SelectedModpack);
}
}
}
}

0 comments on commit 6df1cf4

Please sign in to comment.