|
|
|
|
@@ -179,7 +179,7 @@ internal class RequestControllerTests : BaseWebApiControllerTest
|
|
|
|
|
public async Task GetElement_ById_WhenHaveRecord_ShouldSuccess_Test()
|
|
|
|
|
{
|
|
|
|
|
//Arrange
|
|
|
|
|
var request = SmallSoftwareDbContext.InsertRequestToDatabaseAndReturn(_workerId, "", 10, true, softwares: [(_softwareId, 10, 1.1)]);
|
|
|
|
|
var request = SmallSoftwareDbContext.InsertRequestToDatabaseAndReturn(_workerId, "test", sum: 10, true, softwares: [(_softwareId, 10, 1.1)]);
|
|
|
|
|
//Act
|
|
|
|
|
var response = await HttpClient.GetAsync($"/api/requests/getrecord/{request.Id}");
|
|
|
|
|
//Assert
|
|
|
|
|
@@ -233,13 +233,13 @@ internal class RequestControllerTests : BaseWebApiControllerTest
|
|
|
|
|
var requestModelWithCountIncorrect = new RequestBindingModel {Id = requestId, WorkerId = _workerId , Softwares = [new InstallationRequestBindingModel { RequestId = requestId, SoftwareId = _softwareId, Count = -10, Price = 1.1 }] };
|
|
|
|
|
var requestModelWithPriceIncorrect = new RequestBindingModel {Id = requestId, WorkerId = _workerId, Softwares = [new InstallationRequestBindingModel { RequestId = requestId, SoftwareId = _softwareId, Count = 10, Price = -1.1 }] };
|
|
|
|
|
//Act
|
|
|
|
|
var responseWithIdIncorrect = await HttpClient.PostAsync($"/api/requests/request", MakeContent(requestModelWithIdIncorrect));
|
|
|
|
|
var responseWithWorkerIdIncorrect = await HttpClient.PostAsync($"/api/requests/request", MakeContent(requestModelWithWorkerIdIncorrect));
|
|
|
|
|
var responseWithBuyerIdIncorrect = await HttpClient.PostAsync($"/api/requests/request", MakeContent(requestModelWithBuyerIdIncorrect));
|
|
|
|
|
var responseWithSoftwaresIncorrect = await HttpClient.PostAsync($"/api/requests/request", MakeContent(requestModelWithSoftwaresIncorrect));
|
|
|
|
|
var responseWithSoftwareIdIncorrect = await HttpClient.PostAsync($"/api/requests/request", MakeContent(requestModelWithSoftwareIdIncorrect));
|
|
|
|
|
var responseWithCountIncorrect = await HttpClient.PostAsync($"/api/requests/request", MakeContent(requestModelWithCountIncorrect));
|
|
|
|
|
var responseWithPriceIncorrect = await HttpClient.PostAsync($"/api/requests/request", MakeContent(requestModelWithPriceIncorrect));
|
|
|
|
|
var responseWithIdIncorrect = await HttpClient.PostAsync($"/api/posts", MakeContent(requestModelWithIdIncorrect));
|
|
|
|
|
var responseWithWorkerIdIncorrect = await HttpClient.PostAsync($"/api/posts", MakeContent(requestModelWithWorkerIdIncorrect));
|
|
|
|
|
var responseWithBuyerIdIncorrect = await HttpClient.PostAsync($"/api/posts", MakeContent(requestModelWithBuyerIdIncorrect));
|
|
|
|
|
var responseWithSoftwaresIncorrect = await HttpClient.PostAsync($"/api/posts", MakeContent(requestModelWithSoftwaresIncorrect));
|
|
|
|
|
var responseWithSoftwareIdIncorrect = await HttpClient.PostAsync($"/api/posts", MakeContent(requestModelWithSoftwareIdIncorrect));
|
|
|
|
|
var responseWithCountIncorrect = await HttpClient.PostAsync($"/api/posts", MakeContent(requestModelWithCountIncorrect));
|
|
|
|
|
var responseWithPriceIncorrect = await HttpClient.PostAsync($"/api/posts", MakeContent(requestModelWithPriceIncorrect));
|
|
|
|
|
//Assert
|
|
|
|
|
Assert.Multiple(() =>
|
|
|
|
|
{
|
|
|
|
|
@@ -257,8 +257,9 @@ internal class RequestControllerTests : BaseWebApiControllerTest
|
|
|
|
|
public async Task Post_WhenSendEmptyData_ShouldBadRequest_Test()
|
|
|
|
|
{
|
|
|
|
|
//Act
|
|
|
|
|
var response = await HttpClient.PostAsync($"/api/requests/request", MakeContent(string.Empty));
|
|
|
|
|
var response = await HttpClient.PostAsync($"/api/posts", MakeContent(string.Empty));
|
|
|
|
|
//Assert
|
|
|
|
|
|
|
|
|
|
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -266,7 +267,7 @@ internal class RequestControllerTests : BaseWebApiControllerTest
|
|
|
|
|
public async Task Post_WhenSendWrongFormatData_ShouldBadRequest_Test()
|
|
|
|
|
{
|
|
|
|
|
//Act
|
|
|
|
|
var response = await HttpClient.PostAsync($"/api/requests/request", MakeContent(new { Data = "test", Position = 10 }));
|
|
|
|
|
var response = await HttpClient.PostAsync($"/api/posts", MakeContent(new { Data = "test", Position = 10 }));
|
|
|
|
|
//Assert
|
|
|
|
|
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
|
|
|
|
}
|
|
|
|
|
@@ -336,7 +337,7 @@ internal class RequestControllerTests : BaseWebApiControllerTest
|
|
|
|
|
{
|
|
|
|
|
Assert.Multiple(() =>
|
|
|
|
|
{
|
|
|
|
|
Assert.That(actual.Softwares[i].SoftwareName, Is.EqualTo(expected.InstallationRequests[i].Software!.SoftwareName));
|
|
|
|
|
Assert.That(actual.Softwares[i].SoftwareId, Is.EqualTo(expected.InstallationRequests[i].SoftwareId));
|
|
|
|
|
Assert.That(actual.Softwares[i].Count, Is.EqualTo(expected.InstallationRequests[i].Count));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|