using SmallSoftwareContracts.BindingModels; using SmallSoftwareContracts.Enums; using SmallSoftwareContracts.ViewModels; using SmallSoftwareDatabase.Models; using SmallSoftwareTests.Infrastructure; using System.Net; namespace SmallSoftwareTests.WebApiControllersApi; [TestFixture] internal class SoftwareControllerTests : BaseWebApiControllerTest { private string _manufacturerId; [SetUp] public void SetUp() { _manufacturerId = SmallSoftwareDbContext.InsertManufacturerToDatabaseAndReturn().Id; } [TearDown] public void TearDown() { SmallSoftwareDbContext.RemoveSoftwaresFromDatabase(); SmallSoftwareDbContext.RemoveManufacturersFromDatabase(); } [Test] public async Task GetList_WhenHaveRecords_ShouldSuccess_Test() { //Arrange var software = SmallSoftwareDbContext.InsertSoftwareToDatabaseAndReturn(_manufacturerId, softwareName: "name 1"); SmallSoftwareDbContext.InsertSoftwareToDatabaseAndReturn(_manufacturerId, softwareName: "name 2"); SmallSoftwareDbContext.InsertSoftwareToDatabaseAndReturn(_manufacturerId, softwareName: "name 3"); //Act var response = await HttpClient.GetAsync("/api/softwares/getrecords?includeDeleted=false"); //Assert Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK)); var data = await GetModelFromResponseAsync>(response); Assert.Multiple(() => { Assert.That(data, Is.Not.Null); Assert.That(data, Has.Count.EqualTo(3)); }); AssertElement(data.First(x => x.Id == software.Id), software); } [Test] public async Task GetList_WhenNoRecords_ShouldSuccess_Test() { //Act var response = await HttpClient.GetAsync("/api/softwares/getrecords?includeDeleted=false"); //Assert Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK)); var data = await GetModelFromResponseAsync>(response); Assert.Multiple(() => { Assert.That(data, Is.Not.Null); Assert.That(data, Has.Count.EqualTo(0)); }); } [Test] public async Task GetList_OnlyActual_ShouldSuccess_Test() { //Arrange SmallSoftwareDbContext.InsertSoftwareToDatabaseAndReturn(_manufacturerId, softwareName: "name 1", isDeleted: true); SmallSoftwareDbContext.InsertSoftwareToDatabaseAndReturn(_manufacturerId, softwareName: "name 2", isDeleted: false); SmallSoftwareDbContext.InsertSoftwareToDatabaseAndReturn(_manufacturerId, softwareName: "name 3", isDeleted: false); //Act var response = await HttpClient.GetAsync("/api/softwares/getrecords?includeDeleted=false"); //Assert Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK)); var data = await GetModelFromResponseAsync>(response); Assert.That(data, Is.Not.Null); Assert.Multiple(() => { Assert.That(data, Has.Count.EqualTo(2)); Assert.That(data.All(x => !x.IsDeleted)); }); } [Test] public async Task GetList_IncludeNoActual_ShouldSuccess_Test() { //Arrange SmallSoftwareDbContext.InsertSoftwareToDatabaseAndReturn(_manufacturerId, softwareName: "name 1", isDeleted: true); SmallSoftwareDbContext.InsertSoftwareToDatabaseAndReturn(_manufacturerId, softwareName: "name 2", isDeleted: true); SmallSoftwareDbContext.InsertSoftwareToDatabaseAndReturn(_manufacturerId, softwareName: "name 3", isDeleted: false); //Act var response = await HttpClient.GetAsync("/api/softwares/getrecords?includeDeleted=true"); //Assert Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK)); var data = await GetModelFromResponseAsync>(response); Assert.That(data, Is.Not.Null); Assert.Multiple(() => { Assert.That(data, Has.Count.EqualTo(3)); Assert.That(data.Any(x => x.IsDeleted)); Assert.That(data.Any(x => !x.IsDeleted)); }); } [Test] public async Task GetList_ByManufacturer_ShouldSuccess_Test() { //Arrange var manufacruer = SmallSoftwareDbContext.InsertManufacturerToDatabaseAndReturn(manufacturerName: "name 2"); var software = SmallSoftwareDbContext.InsertSoftwareToDatabaseAndReturn(_manufacturerId, softwareName: "name 1", isDeleted: true); SmallSoftwareDbContext.InsertSoftwareToDatabaseAndReturn(_manufacturerId, softwareName: "name 2", isDeleted: false); SmallSoftwareDbContext.InsertSoftwareToDatabaseAndReturn(manufacruer.Id, softwareName: "name 3", isDeleted: false); //Act var response = await HttpClient.GetAsync($"/api/softwares/getmanufacturerrecords?id={_manufacturerId}&includeDeleted=true"); //Assert Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK)); var data = await GetModelFromResponseAsync>(response); Assert.That(data, Is.Not.Null); Assert.Multiple(() => { Assert.That(data, Has.Count.EqualTo(2)); Assert.That(data.All(x => x.ManufacturerId == _manufacturerId)); }); AssertElement(data.First(x => x.Id == software.Id), software); } [Test] public async Task GetList_ByManufacturerOnlyActual_ShouldSuccess_Test() { //Arrange var manufacruer = SmallSoftwareDbContext.InsertManufacturerToDatabaseAndReturn(manufacturerName: "name 2"); SmallSoftwareDbContext.InsertSoftwareToDatabaseAndReturn(_manufacturerId, softwareName: "name 1", isDeleted: true); SmallSoftwareDbContext.InsertSoftwareToDatabaseAndReturn(_manufacturerId, softwareName: "name 2", isDeleted: false); SmallSoftwareDbContext.InsertSoftwareToDatabaseAndReturn(manufacruer.Id, softwareName: "name 3", isDeleted: false); //Act var response = await HttpClient.GetAsync($"/api/softwares/getmanufacturerrecords?id={_manufacturerId}&includeDeleted = false"); //Assert Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK)); var data = await GetModelFromResponseAsync>(response); Assert.That(data, Is.Not.Null); Assert.Multiple(() => { Assert.That(data, Has.Count.EqualTo(1)); Assert.That(data.All(x => x.ManufacturerId == _manufacturerId && !x.IsDeleted)); }); } [Test] public async Task GetList_ManufacturerIdIsNotGuid_ShouldBadRequest_Test() { //Act var response = await HttpClient.GetAsync($"/api/softwares/getmanufacturerrecords?id=id&includeDeleted=false"); //Assert Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); } [Test] public async Task GetHistoryBySoftwareId_WhenHaveRecords_ShouldSuccess_Test() { //Arrange var software = SmallSoftwareDbContext.InsertSoftwareToDatabaseAndReturn(_manufacturerId); SmallSoftwareDbContext.InsertSoftwareHistoryToDatabaseAndReturn(software.Id, 20, DateTime.UtcNow.AddDays(-1)); SmallSoftwareDbContext.InsertSoftwareHistoryToDatabaseAndReturn(software.Id, 30, DateTime.UtcNow.AddMinutes(-10)); var history = SmallSoftwareDbContext.InsertSoftwareHistoryToDatabaseAndReturn(software.Id, 40, DateTime.UtcNow.AddDays(1)); //Act var response = await HttpClient.GetAsync($"/api/softwares/gethistory?id={software.Id}"); //Assert Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK)); var data = await GetModelFromResponseAsync>(response); Assert.That(data, Is.Not.Null); Assert.That(data, Has.Count.EqualTo(3)); AssertElement(data[0], history); } [Test] public async Task GetHistoryBySoftwareId_WhenNoRecords_ShouldSuccess_Test() { //Arrange var software = SmallSoftwareDbContext.InsertSoftwareToDatabaseAndReturn(_manufacturerId); SmallSoftwareDbContext.InsertSoftwareHistoryToDatabaseAndReturn(software.Id, 20, DateTime.UtcNow.AddDays(-1)); SmallSoftwareDbContext.InsertSoftwareHistoryToDatabaseAndReturn(software.Id, 30, DateTime.UtcNow.AddMinutes(-10)); SmallSoftwareDbContext.InsertSoftwareHistoryToDatabaseAndReturn(software.Id, 40, DateTime.UtcNow.AddDays(1)); //Act var response = await HttpClient.GetAsync($"/api/softwares/gethistory?id={Guid.NewGuid()}"); //Assert Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK)); var data = await GetModelFromResponseAsync>(response); Assert.That(data, Is.Not.Null); Assert.That(data, Has.Count.EqualTo(0)); } [Test] public async Task GetHistoryBySoftwareId_SoftwareIdIsNotGuid_ShouldBadRequest_Test() { //Act var response = await HttpClient.GetAsync($"/api/softwares/gethistory?id=id"); //Assert Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); } [Test] public async Task GetElement_ById_WhenHaveRecord_ShouldSuccess_Test() { //Arrange var software = SmallSoftwareDbContext.InsertSoftwareToDatabaseAndReturn(_manufacturerId); //Act var response = await HttpClient.GetAsync($"/api/softwares/getrecord/{software.Id}"); //Assert Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK)); AssertElement(await GetModelFromResponseAsync(response), software); } [Test] public async Task GetElement_ById_WhenNoRecord_ShouldNotFound_Test() { //Arrange SmallSoftwareDbContext.InsertSoftwareToDatabaseAndReturn(_manufacturerId); //Act var response = await HttpClient.GetAsync($"/api/softwares/getrecord/{Guid.NewGuid()}"); //Assert Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.NotFound)); } [Test] public async Task GetElement_ById_WhenRecordWasDeleted_ShouldNotFound_Test() { //Arrange var software = SmallSoftwareDbContext.InsertSoftwareToDatabaseAndReturn(_manufacturerId, isDeleted: true); //Act var response = await HttpClient.GetAsync($"/api/softwares/getrecord/{software.Id}"); //Assert Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.NotFound)); } [Test] public async Task GetElement_ByName_WhenHaveRecord_ShouldSuccess_Test() { //Arrange var software = SmallSoftwareDbContext.InsertSoftwareToDatabaseAndReturn(_manufacturerId); //Act var response = await HttpClient.GetAsync($"/api/softwares/getrecord/{software.SoftwareName}"); //Assert Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK)); AssertElement(await GetModelFromResponseAsync(response), software); } [Test] public async Task GetElement_ByName_WhenNoRecord_ShouldNotFound_Test() { //Arrange SmallSoftwareDbContext.InsertSoftwareToDatabaseAndReturn(_manufacturerId); //Act var response = await HttpClient.GetAsync($"/api/softwares/getrecord/New%20Name"); //Assert Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.NotFound)); } [Test] public async Task GetElement_ByName_WhenRecordWasDeleted_ShouldNotFound_Test() { //Arrange var software = SmallSoftwareDbContext.InsertSoftwareToDatabaseAndReturn(_manufacturerId, isDeleted: true); //Act var response = await HttpClient.GetAsync($"/api/softwares/getrecord/{software.SoftwareName}"); //Assert Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.NotFound)); } [Test] public async Task Post_ShouldSuccess_Test() { //Arrange SmallSoftwareDbContext.InsertSoftwareToDatabaseAndReturn(_manufacturerId); var softwareModel = CreateModel(_manufacturerId); //Act var response = await HttpClient.PostAsync($"/api/softwares/register", MakeContent(softwareModel)); //Assert Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.NoContent)); AssertElement(SmallSoftwareDbContext.GetSoftwareFromDatabaseById(softwareModel.Id!), softwareModel); } [Test] public async Task Post_WhenHaveRecordWithSameId_ShouldBadRequest_Test() { //Arrange var softwareModel = CreateModel(_manufacturerId); SmallSoftwareDbContext.InsertSoftwareToDatabaseAndReturn(_manufacturerId, softwareModel.Id); //Act var response = await HttpClient.PostAsync($"/api/softwares/register", MakeContent(softwareModel)); //Assert Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); } [Test] public async Task Post_WhenHaveRecordWithSameName_ShouldBadRequest_Test() { //Arrange var softwareModel = CreateModel(_manufacturerId, softwareName: "unique name"); SmallSoftwareDbContext.InsertSoftwareToDatabaseAndReturn(_manufacturerId, softwareName: softwareModel.SoftwareName!); //Act var response = await HttpClient.PostAsync($"/api/softwares/register", MakeContent(softwareModel)); //Assert Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); } [Test] public async Task Post_WhenDataIsIncorrect_ShouldBadRequest_Test() { //Arrange var softwareModelWithIdIncorrect = new SoftwareBindingModel { Id = "Id", ManufacturerId = _manufacturerId, SoftwareName = "name", Price = 100, SoftwareType = SoftwareType.Windows.ToString() }; var softwareModelWithNameIncorrect = new SoftwareBindingModel { Id = Guid.NewGuid().ToString(), ManufacturerId = _manufacturerId, SoftwareName = string.Empty, Price = 100, SoftwareType = SoftwareType.Windows.ToString() }; var softwareModelWithSoftwareTypeIncorrect = new SoftwareBindingModel { Id = Guid.NewGuid().ToString(), ManufacturerId = _manufacturerId, SoftwareName = "name", Price = 100, SoftwareType = string.Empty }; var softwareModelWithPriceIncorrect = new SoftwareBindingModel { Id = Guid.NewGuid().ToString(), ManufacturerId = _manufacturerId, SoftwareName = "name", Price = 0, SoftwareType = SoftwareType.Windows.ToString() }; //Act var responseWithIdIncorrect = await HttpClient.PostAsync($"/api/softwares/register", MakeContent(softwareModelWithIdIncorrect)); var responseWithNameIncorrect = await HttpClient.PostAsync($"/api/softwares/register", MakeContent(softwareModelWithNameIncorrect)); var responseWithSoftwareTypeIncorrect = await HttpClient.PostAsync($"/api/softwares/register", MakeContent(softwareModelWithSoftwareTypeIncorrect)); var responseWithPriceIncorrect = await HttpClient.PostAsync($"/api/softwares/register", MakeContent(softwareModelWithPriceIncorrect)); //Assert Assert.Multiple(() => { Assert.That(responseWithIdIncorrect.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest), "Id is incorrect"); Assert.That(responseWithNameIncorrect.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest), "Name is incorrect"); Assert.That(responseWithSoftwareTypeIncorrect.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest), "Name is incorrect"); Assert.That(responseWithPriceIncorrect.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest), "Name is incorrect"); }); } [Test] public async Task Post_WhenSendEmptyData_ShouldBadRequest_Test() { //Act var response = await HttpClient.PostAsync($"/api/softwares/register",MakeContent(string.Empty)); //Assert Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); } [Test] public async Task Post_WhenSendWrongFormatData_ShouldBadRequest_Test() { //Act var response = await HttpClient.PostAsync($"/api/softwares/register", MakeContent(new { Data = "test", Position = 10 })); //Assert Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); } [Test] public async Task Put_ShouldSuccess_Test() { //Arrange var softwareModel = CreateModel(_manufacturerId); SmallSoftwareDbContext.InsertSoftwareToDatabaseAndReturn(_manufacturerId, softwareModel.Id); //Act var response = await HttpClient.PutAsync($"/api/softwares/changeinfo", MakeContent(softwareModel)); //Assert Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.NoContent)); SmallSoftwareDbContext.ChangeTracker.Clear(); AssertElement(SmallSoftwareDbContext.GetSoftwareFromDatabaseById(softwareModel.Id!), softwareModel); } [Test] public async Task Put_WhenNoFoundRecord_ShouldBadRequest_Test() { //Arrange var softwareModel = CreateModel(_manufacturerId); SmallSoftwareDbContext.InsertSoftwareToDatabaseAndReturn(_manufacturerId); //Act var response = await HttpClient.PutAsync($"/api/softwares/changeinfo", MakeContent(softwareModel)); //Assert Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); } [Test] public async Task Put_WhenHaveRecordWithSameName_ShouldBadRequest_Test() { //Arrange var softwareModel = CreateModel(_manufacturerId, softwareName: "unique name"); SmallSoftwareDbContext.InsertSoftwareToDatabaseAndReturn(_manufacturerId, softwareModel.Id); SmallSoftwareDbContext.InsertSoftwareToDatabaseAndReturn(_manufacturerId, softwareName: softwareModel.SoftwareName!); //Act var response = await HttpClient.PutAsync($"/api/softwares/changeinfo", MakeContent(softwareModel)); //Assert Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); } [Test] public async Task Put_WhenRecordWasDeleted_ShouldBadRequest_Test() { //Arrange var softwareModel = CreateModel(_manufacturerId); SmallSoftwareDbContext.InsertSoftwareToDatabaseAndReturn(_manufacturerId, softwareModel.Id, isDeleted: true); //Act var response = await HttpClient.PutAsync($"/api/softwares/changeinfo", MakeContent(softwareModel)); //Assert Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); } [Test] public async Task Put_WhenDataIsIncorrect_ShouldBadRequest_Test() { //Arrange var softwareModelWithIdIncorrect = new SoftwareBindingModel { Id = "Id", ManufacturerId = _manufacturerId, SoftwareName = "name", Price = 100, SoftwareType = SoftwareType.Windows.ToString() }; var softwareModelWithNameIncorrect = new SoftwareBindingModel { Id = Guid.NewGuid().ToString(), ManufacturerId = _manufacturerId, SoftwareName = string.Empty, Price = 100, SoftwareType = SoftwareType.Windows.ToString() }; var softwareModelWithSoftwareTypeIncorrect = new SoftwareBindingModel { Id = Guid.NewGuid().ToString(), ManufacturerId = _manufacturerId, SoftwareName = "name", Price = 100, SoftwareType = string.Empty }; var softwareModelWithPriceIncorrect = new SoftwareBindingModel { Id = Guid.NewGuid().ToString(), ManufacturerId = _manufacturerId, SoftwareName = "name", Price = 0, SoftwareType = SoftwareType.Windows.ToString() }; //Act var responseWithIdIncorrect = await HttpClient.PutAsync($"/api/softwares/changeinfo", MakeContent(softwareModelWithIdIncorrect)); var responseWithNameIncorrect = await HttpClient.PutAsync($"/api/softwares/changeinfo", MakeContent(softwareModelWithNameIncorrect)); var responseWithSoftwareTypeIncorrect = await HttpClient.PutAsync($"/api/softwares/changeinfo", MakeContent(softwareModelWithSoftwareTypeIncorrect)); var responseWithPriceIncorrect = await HttpClient.PutAsync($"/api/softwares/changeinfo", MakeContent(softwareModelWithPriceIncorrect)); //Assert Assert.Multiple(() => { Assert.That(responseWithIdIncorrect.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest), "Id is incorrect"); Assert.That(responseWithNameIncorrect.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest), "Name is incorrect"); Assert.That(responseWithSoftwareTypeIncorrect.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest), "Name is incorrect"); Assert.That(responseWithPriceIncorrect.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest), "Name is incorrect"); }); } [Test] public async Task Put_WhenSendEmptyData_ShouldBadRequest_Test() { //Act var response = await HttpClient.PutAsync($"/api/softwares/changeinfo", MakeContent(string.Empty)); //Assert Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); } [Test] public async Task Put_WhenSendWrongFormatData_ShouldBadRequest_Test() { //Act var response = await HttpClient.PutAsync($"/api/softwares/changeinfo", MakeContent(new { Data = "test", Position = 10 })); //Assert Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); } [Test] public async Task Delete_ShouldSuccess_Test() { //Arrange var softwareId = Guid.NewGuid().ToString(); SmallSoftwareDbContext.InsertSoftwareToDatabaseAndReturn(_manufacturerId, softwareId); //Act var response = await HttpClient.DeleteAsync($"/api/softwares/delete/{softwareId}"); SmallSoftwareDbContext.ChangeTracker.Clear(); //Assert Assert.Multiple(() => { Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.NoContent)); Assert.That(SmallSoftwareDbContext.GetSoftwareFromDatabaseById(softwareId)!.IsDeleted); }); } [Test] public async Task Delete_WhenNoFoundRecord_ShouldBadRequest_Test() { //Arrange SmallSoftwareDbContext.InsertSoftwareToDatabaseAndReturn(_manufacturerId); //Act var response = await HttpClient.DeleteAsync($"/api/softwares/delete/{Guid.NewGuid()}"); //Assert Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); } [Test] public async Task Delete_WhenRecordWasDeleted_ShouldBadRequest_Test() { //Arrange var softwareId = SmallSoftwareDbContext.InsertSoftwareToDatabaseAndReturn(_manufacturerId, isDeleted: true).Id; //Act var response = await HttpClient.DeleteAsync($"/api/softwares/delete/{softwareId}"); //Assert Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); } [Test] public async Task Delete_WhenSendWrongFormatData_ShouldBadRequest_Test() { //Act var response = await HttpClient.DeleteAsync($"/api/softwares/delete/id"); //Assert Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); } private static void AssertElement(SoftwareViewModel? actual, Software expected) { Assert.That(actual, Is.Not.Null); Assert.Multiple(() => { Assert.That(actual.Id, Is.EqualTo(expected.Id)); Assert.That(actual.ManufacturerId, Is.EqualTo(expected.ManufacturerId)); Assert.That(actual.SoftwareName, Is.EqualTo(expected.SoftwareName)); Assert.That(actual.SoftwareType, Is.EqualTo(expected.SoftwareType.ToString())); Assert.That(actual.Price, Is.EqualTo(expected.Price)); Assert.That(actual.IsDeleted, Is.EqualTo(expected.IsDeleted)); Assert.That(actual.ManufacturerName, Is.EqualTo(expected.Manufacturer!.ManufacturerName)); }); } private static void AssertElement(SoftwareHistoryViewModel? actual, SoftwareHistory expected) { Assert.That(actual, Is.Not.Null); Assert.Multiple(() => { Assert.That(actual.SoftwareName, Is.EqualTo(expected.Software!.SoftwareName)); Assert.That(actual.OldPrice, Is.EqualTo(expected.OldPrice)); Assert.That(actual.ChangeDate.ToString(), Is.EqualTo(expected.ChangeDate.ToString())); }); } private static SoftwareBindingModel CreateModel(string manufacturerId, string? id = null, string softwareName = "name", SoftwareType softwareType = SoftwareType.Windows, double price = 1) => new() { Id = id ?? Guid.NewGuid().ToString(), ManufacturerId = manufacturerId, SoftwareName = softwareName, SoftwareType = softwareType.ToString(), Price = price }; private static void AssertElement(Software? actual, SoftwareBindingModel expected) { Assert.That(actual, Is.Not.Null); Assert.Multiple(() => { Assert.That(actual.Id, Is.EqualTo(expected.Id)); Assert.That(actual.ManufacturerId, Is.EqualTo(expected.ManufacturerId)); Assert.That(actual.SoftwareName, Is.EqualTo(expected.SoftwareName)); Assert.That(actual.SoftwareType.ToString(), Is.EqualTo(expected.SoftwareType)); Assert.That(actual.Price, Is.EqualTo(expected.Price)); Assert.That(!actual.IsDeleted); }); } }