Commit cf40b515 authored by adnan's avatar adnan

change unit test using xUnitTest instead of MsUnitTest

parent 6b86086a
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using SIX.ApplicationLayer.Student;
using SIX.Web.Controllers;
using Xunit;
namespace SIX.Web.Test
{
[TestClass]
public class StudentControllerTest
public class IndexControllerTest
{
[TestMethod]
public void Index_Student_Number_Grather_Than_Zero()
[Fact]
public void Index_Is_Student_Number_Is_Not_Zero()
{
// Arrange
var mockService = new Mock<IStudentService>();
mockService.Setup(svc => svc.GetAll())
.Returns(new List<Core.Student.Student>
......@@ -26,11 +25,13 @@ namespace SIX.Web.Test
var controller = new StudentController(mockService.Object);
// Act
var result = controller.Index() as ViewResult;
// Assert
Assert.AreEqual(typeof(SIX.Web.Models.StudentPageViewModel), result.Model);
Assert.AreNotEqual(0, (result.Model as SIX.Web.Models.StudentPageViewModel).Students.Count);
var result = controller.Index() as ViewResult;
//Assert
var viewResult = Assert.IsType<ViewResult>(result);
var model = Assert.IsAssignableFrom<SIX.Web.Models.StudentPageViewModel>(
viewResult.ViewData.Model);
Assert.Equal(3, model.Students.Count);
}
}
}
......@@ -8,10 +8,9 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="Moq" Version="4.13.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.ViewFeatures" Version="2.2.0" />
</ItemGroup>
......@@ -19,8 +18,4 @@
<ProjectReference Include="..\SIX.Core\SIX.Core.csproj" />
<ProjectReference Include="..\SIX.Web\SIX.Web.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.AspNetCore.Mvc.Abstractions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60" />
<Reference Include="Microsoft.AspNetCore.Mvc.ViewFeatures, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60" />
</ItemGroup>
</Project>
......@@ -9,7 +9,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SIX.Infrastructure", "SIX.I
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SIX.Web", "SIX.Web\SIX.Web.csproj", "{7DB6F399-DA1C-463E-ABEA-AC6F0897B428}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SIX.Web.Test", "SIX.Web.Test\SIX.Web.Test.csproj", "{AEF7D299-9B77-4D86-9731-0B979B28DF1C}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SIX.Web.Test", "SIX.Web.Test\SIX.Web.Test.csproj", "{41C3CF35-DFD0-4C3F-B944-55E02B307535}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
......@@ -33,9 +33,9 @@ Global
{7DB6F399-DA1C-463E-ABEA-AC6F0897B428}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7DB6F399-DA1C-463E-ABEA-AC6F0897B428}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7DB6F399-DA1C-463E-ABEA-AC6F0897B428}.Release|Any CPU.Build.0 = Release|Any CPU
{AEF7D299-9B77-4D86-9731-0B979B28DF1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AEF7D299-9B77-4D86-9731-0B979B28DF1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AEF7D299-9B77-4D86-9731-0B979B28DF1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AEF7D299-9B77-4D86-9731-0B979B28DF1C}.Release|Any CPU.Build.0 = Release|Any CPU
{41C3CF35-DFD0-4C3F-B944-55E02B307535}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{41C3CF35-DFD0-4C3F-B944-55E02B307535}.Debug|Any CPU.Build.0 = Debug|Any CPU
{41C3CF35-DFD0-4C3F-B944-55E02B307535}.Release|Any CPU.ActiveCfg = Release|Any CPU
{41C3CF35-DFD0-4C3F-B944-55E02B307535}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment