added e2e test - zad.3 lab 9 #39

Merged
s426134 merged 2 commits from frontend-tests into dev 2020-12-21 20:39:23 +01:00
4 changed files with 112 additions and 1 deletions
Showing only changes of commit d6da8436bc - Show all commits

View File

@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="1.3.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>

View File

@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="Moq" Version="4.15.2" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="1.3.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SessionCompanion.Database\SessionCompanion.Database.csproj" />
<ProjectReference Include="..\SessionCompanion.Extensions\SessionCompanion.Extensions.csproj" />
<ProjectReference Include="..\SessionCompanion.Services\SessionCompanion.Services.csproj" />
<ProjectReference Include="..\SessionCompanion.ViewModels\SessionCompanion.ViewModels.csproj" />
<ProjectReference Include="..\SessionCompanion\SessionCompanion.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,50 @@
using System;
using Xunit;
namespace SessionCompanion.XUnitTests
{
using System.Threading.Tasks;
using Moq;
using NUnit.Framework;
using SessionCompanion.Controllers;
using SessionCompanion.Extensions.EitherType;
using SessionCompanion.Services.Interfaces;
using SessionCompanion.ViewModels.ApiResponses;
using SessionCompanion.ViewModels.UserViewModels;
public class UserServiceTest
{
private UserController userController;
private Mock<IUserService> userServiceMock;
[SetUp]
public void Setup()
{
userServiceMock = new Mock<IUserService>();
UserViewModel test = new UserViewModel(){ Id = 1, Password = "123", Username = "test"};
this.userServiceMock.Setup(p => p.SearchUserByUsername("test")).ReturnsAsync(test);
this.userController = new UserController(this.userServiceMock.Object);
}
[Test]
public void ShouldReturnUserId()
{
var result = this.userController.Login("test", "123").Result;
Assert.AreEqual(1,result.Left);
}
[Test]
public void ShouldReturnUserName()
{
var result = this.userController.GetUserName(1).Result;
Assert.AreEqual("test", result.Left);
}
}
}

View File

@ -11,7 +11,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SessionCompanion.ViewModels
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SessionCompanion.Services", "SessionCompanion.Services\SessionCompanion.Services.csproj", "{C0A172ED-0F4C-4E78-8B64-28E2A756F62F}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SessionCompanion.Services", "SessionCompanion.Services\SessionCompanion.Services.csproj", "{C0A172ED-0F4C-4E78-8B64-28E2A756F62F}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SessionCompanion.Extensions", "SessionCompanion.Extensions\SessionCompanion.Extensions.csproj", "{1EE35EB3-C703-407C-B390-5605A0A46884}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SessionCompanion.Extensions", "SessionCompanion.Extensions\SessionCompanion.Extensions.csproj", "{1EE35EB3-C703-407C-B390-5605A0A46884}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SessionCompanion.XUnitTests", "SessionCompanion.XUnitTests\SessionCompanion.XUnitTests.csproj", "{B8A4DAF6-DD33-4B35-99B8-A1D060EE1869}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -39,6 +41,10 @@ Global
{1EE35EB3-C703-407C-B390-5605A0A46884}.Debug|Any CPU.Build.0 = Debug|Any CPU {1EE35EB3-C703-407C-B390-5605A0A46884}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1EE35EB3-C703-407C-B390-5605A0A46884}.Release|Any CPU.ActiveCfg = Release|Any CPU {1EE35EB3-C703-407C-B390-5605A0A46884}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1EE35EB3-C703-407C-B390-5605A0A46884}.Release|Any CPU.Build.0 = Release|Any CPU {1EE35EB3-C703-407C-B390-5605A0A46884}.Release|Any CPU.Build.0 = Release|Any CPU
{B8A4DAF6-DD33-4B35-99B8-A1D060EE1869}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B8A4DAF6-DD33-4B35-99B8-A1D060EE1869}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B8A4DAF6-DD33-4B35-99B8-A1D060EE1869}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B8A4DAF6-DD33-4B35-99B8-A1D060EE1869}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE