Assertions:
--Actual
--Expectation
using Visual Studio Framework:
--Create New Class Library Project as 'BankAccountLibrary'
--In that same Project add New XUnit Project as 'BankAccountXUnitTesting'
--In that same Project add New NUnit Project as 'BankAccountNUnitTesting'
--In that same Project add New MSTest Project as 'BankAccountMSTest'
--Then add reference of 'BankAccountLibrary' to all 3 Test Projects as Right click>>Add Project reference..
--Then do the coding..
using VSCode CLI:
>cd C:\Subas\DotNetUnitTestingJun2023\UnitTestingusingVSCode
>dotnet new sln -o TestingSolution
>cd TestingSolution
>dotnet new classlib -o BankAccountLibrary
>dotnet sln add ./BankAccountLibrary/BankAccountLibrary.csproj
>dotnet new xunit -o BankAccountXUnitLibrary
>dotnet sln add ./BankAccountXUnitLibrary/BankAccountXUnitLibrary.csproj
>dotnet new nunit -o BankAccountNUnitLibrary
>dotnet sln add ./BankAccountNUnitLibrary/BankAccountNUnitLibrary.csproj
>dotnet new mstest -o BankAccountMSUnitLibrary
>dotnet sln add ./BankAccountMSUnitLibrary/BankAccountMSUnitLibrary.csproj
BankAccountLibrary>dotnet build
>cd..
>cd BankAccountMSUnitLibrary
BankAccountMSUnitLibrary>dotnet add reference ../BankAccountLibrary/BankAccountLibrary.csproj
>cd..
>cd BankAccountNUnitLibrary
BankAccountNUnitLibrary>dotnet add reference ../BankAccountLibrary/BankAccountLibrary.csproj
>cd..
>cd BankAccountXUnitLibrary
BankAccountXUnitLibrary>dotnet add reference ../BankAccountLibrary/BankAccountLibrary.csproj
>dotnet build
>dotnet test
//OR
I)Class Library Project:
--Install from Nugate Package:
---Microsoft.EntityFrameworkcore
---Microsoft.EntityFrameworkcore.Tools
---Microsoft.EntityFrameworkcore.SqlServer
--Add Models and Repository and write Logic
--Open Package Console:
--Build Project
PM> add-migration
Name: CartService_V1
>update-database
II)API Project:
--Install from Nugate Package:
---Microsoft.AspNetCore.Mvc.NewtonsoftJson 6.0.4
---Newtonsoft.Json 13.0.3
--Add Class Library Reference
--Add Controller and write logics
--Add connection Strings in appsettings and DB Context
--Then test in Postman
III)API NUNit Test Project:
--Install from Nugate Package:
---MOQ
--Write logic
Install below Package from Nugate for MSTest:
Microsoft.AspNet.WebApi.Core
No comments:
Post a Comment