diff --git a/DamageAssesmentApi/DamageAssesment.Responses.Test/DamageAssesment.Api.Responses.Test.csproj b/DamageAssesmentApi/DamageAssesment.Responses.Test/DamageAssesment.Api.Responses.Test.csproj deleted file mode 100644 index 5190942..0000000 --- a/DamageAssesmentApi/DamageAssesment.Responses.Test/DamageAssesment.Api.Responses.Test.csproj +++ /dev/null @@ -1,30 +0,0 @@ - - - - net6.0 - enable - enable - - false - true - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - - diff --git a/DamageAssesmentApi/DamageAssesment.Responses.Test/MockData.cs b/DamageAssesmentApi/DamageAssesment.Responses.Test/MockData.cs deleted file mode 100644 index c7a52de..0000000 --- a/DamageAssesmentApi/DamageAssesment.Responses.Test/MockData.cs +++ /dev/null @@ -1,30 +0,0 @@ - -using DamageAssesment.Api.Responses.Models; -using System.Collections.Generic; -using System.Text; - -namespace DamageAssesment.Api.Responses.Test -{ - public class MockData - { - public static async Task<(bool, SurveyResponse, string)> getOkResponse(SurveyResponse data) - { - return (true, data, null); - } - - public static async Task<(bool, dynamic, string)> getOkResponse() - { - return (true, new { }, null); - } - - public static async Task<(bool, Models.SurveyResponse, string)> getResponse() - { - return (false, null, null); - } - - public static async Task getSurveyResponseObject() - { - return new Models.SurveyResponse { EmployeeId = 1, LocationId = 1, SurveyId = 1, Id = 1 }; - } - } -} diff --git a/DamageAssesmentApi/DamageAssesment.Responses.Test/ResponsesServiceTest.cs b/DamageAssesmentApi/DamageAssesment.Responses.Test/ResponsesServiceTest.cs deleted file mode 100644 index e586917..0000000 --- a/DamageAssesmentApi/DamageAssesment.Responses.Test/ResponsesServiceTest.cs +++ /dev/null @@ -1,251 +0,0 @@ -using DamageAssesment.Api.Responses.Controllers; -using DamageAssesment.Api.Responses.Interfaces; -using DamageAssesment.Api.Responses.Models; -using DamageAssesment.Api.Responses.Test; -using Microsoft.AspNetCore.Mvc; -using Moq; -using Xunit; - - -namespace DamageAssesment.SurveyResponses.Test -{ - public class ResponsesServiceTest - { - private Mock mockSurveyResponseService; - private string token { get; set; } - public ResponsesServiceTest() - { - mockSurveyResponseService = new Mock(); - token = Guid.NewGuid().ToString(); - } - - [Fact(DisplayName = "Get Responses - Ok case")] - public async Task GetSurveyResponsesAsync_ShouldReturnStatusCode200() - { - SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject(); - var mockResponse = await MockData.getOkResponse(mockRequestObject); - mockSurveyResponseService.Setup(service => service.GetSurveyResponsesAsync()).ReturnsAsync(mockResponse); - var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object); - var result = (OkObjectResult)await surveyResponseProvider.GetSurveyResponsesAsync(); - Assert.Equal(200, result.StatusCode); - } - - [Fact(DisplayName = "Get Responses - BadRequest case")] - public async Task GetSurveyResponsesAsync_ShouldReturnStatusCode204() - { - var mockResponse = await MockData.getResponse(); - mockSurveyResponseService.Setup(service => service.GetSurveyResponsesAsync()).ReturnsAsync(mockResponse); - var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object); - var result = (BadRequestObjectResult)await surveyResponseProvider.GetSurveyResponsesAsync(); - Assert.Equal(400, result.StatusCode); - } - - [Fact(DisplayName = "Get Responses by surveyId - Ok case")] - public async Task GetSurveyResponsesBySurveyAsync_ShouldReturnStatusCode200() - { - SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject(); - var mockResponse = await MockData.getOkResponse(); -<<<<<<<< HEAD:DamageAssesmentApi/DamageAssesment.Api.Responses.Test/SurveyResponsesServiceTest.cs - mockSurveyResponseService.Setup(service => service.GetSurveyResponsesBySurveyAsync(1,1)).ReturnsAsync(mockResponse); - var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object); - var result = (OkObjectResult)await surveyResponseProvider.GetSurveyResponsesAsync(1,1); -======== - mockSurveyResponseService.Setup(service => service.GetSurveyResponsesBySurveyAsync(1)).ReturnsAsync(mockResponse); - var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object); - var result = (OkObjectResult)await surveyResponseProvider.GetSurveyResponsesAsync(1); ->>>>>>>> Azure-Integration:DamageAssesmentApi/DamageAssesment.Responses.Test/ResponsesServiceTest.cs - Assert.Equal(200, result.StatusCode); - } - - [Fact(DisplayName = "Get Responses by surveyId - NoContent case")] - public async Task GetSurveyResponsesBySurveyAsync_ShouldReturnStatusCode204() - { - var mockResponse = await MockData.getResponse(); -<<<<<<<< HEAD:DamageAssesmentApi/DamageAssesment.Api.Responses.Test/SurveyResponsesServiceTest.cs - mockSurveyResponseService.Setup(service => service.GetSurveyResponsesBySurveyAsync(1,1)).ReturnsAsync(mockResponse); - var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object); - var result = (NoContentResult)await surveyResponseProvider.GetSurveyResponsesAsync(1,1); -======== - mockSurveyResponseService.Setup(service => service.GetSurveyResponsesBySurveyAsync(1)).ReturnsAsync(mockResponse); - var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object); - var result = (NoContentResult)await surveyResponseProvider.GetSurveyResponsesAsync(1); ->>>>>>>> Azure-Integration:DamageAssesmentApi/DamageAssesment.Responses.Test/ResponsesServiceTest.cs - Assert.Equal(204, result.StatusCode); - } - - - - - [Fact(DisplayName = "Get Responses by surveyId and locationId - Ok case")] - public async Task GetSurveyResponsesBySurveyLocationAsync_ShouldReturnStatusCode200() - { - SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject(); - var mockResponse = await MockData.getOkResponse(); - mockSurveyResponseService.Setup(service => service.GetSurveyResponsesBySurveyAndLocationAsync(1, 1)).ReturnsAsync(mockResponse); - var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object); - var result = (OkObjectResult)await surveyResponseProvider.GetSurveyResponsesBySurveyAndLocationAsync(1, 1); - Assert.Equal(200, result.StatusCode); - } - - [Fact(DisplayName = "Get Responses by surveyId and locationId - NoContent case")] - public async Task GetSurveyResponsesBySurveyLocationAsync_ShouldReturnStatusCode204() - { - var mockResponse = await MockData.getResponse(); - mockSurveyResponseService.Setup(service => service.GetSurveyResponsesBySurveyAndLocationAsync(1, 1)).ReturnsAsync(mockResponse); - var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object); - var result = (NoContentResult)await surveyResponseProvider.GetSurveyResponsesBySurveyAndLocationAsync(1, 1); - Assert.Equal(204, result.StatusCode); - } - - [Fact(DisplayName = "Get Responses by surveyId and QuestionId and Answer - Ok case")] - public async Task GetSurveyResponsesBySurveyQuestionAnswerAsync_ShouldReturnStatusCode200() - { - SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject(); - var mockResponse = await MockData.getOkResponse(); - mockSurveyResponseService.Setup(service => service.GetResponsesByAnswerAsync(1, 1, "Yes")).ReturnsAsync(mockResponse); - var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object); - var result = (OkObjectResult)await surveyResponseProvider.GetSurveyResponsesByAnswerAsyncAsync(1, 1, "Yes"); - Assert.Equal(200, result.StatusCode); - } - - [Fact(DisplayName = "Get Responses by surveyId and QuestionId and Answer - NoContent case")] - public async Task GetSurveyResponsesBySurveyQuestionAnswerAsync_ShouldReturnStatusCode204() - { - var mockResponse = await MockData.getResponse(); - mockSurveyResponseService.Setup(service => service.GetResponsesByAnswerAsync(1, 1, "Yes")).ReturnsAsync(mockResponse); - var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object); - var result = (NoContentResult)await surveyResponseProvider.GetSurveyResponsesByAnswerAsyncAsync(1, 1, "Yes"); - Assert.Equal(204, result.StatusCode); - } - - - [Fact(DisplayName = "Get Responses by region and surveyId - Ok case")] - public async Task GetSurveyResponsesByRegionSurveyAsync_ShouldReturnStatusCode200() - { - SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject(); - var mockResponse = await MockData.getOkResponse(); - mockSurveyResponseService.Setup(service => service.GetAnswersByRegionAsync(1)).ReturnsAsync(mockResponse); - var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object); - var result = (OkObjectResult)await surveyResponseProvider.GetAnswersByRegionAsync(1); - Assert.Equal(200, result.StatusCode); - } - - [Fact(DisplayName = "Get Responses by region and surveyId - NoContent Case")] - public async Task GetSurveyResponsesByRegionSurveyAsync_ShouldReturnStatusCode204() - { - var mockResponse = await MockData.getResponse(); - mockSurveyResponseService.Setup(service => service.GetAnswersByRegionAsync(1)).ReturnsAsync(mockResponse); - var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object); - var result = (NoContentResult)await surveyResponseProvider.GetAnswersByRegionAsync(1); - Assert.Equal(204, result.StatusCode); - } - - [Fact(DisplayName = "Get Responses by maintenanceCenter and surveyId - Ok case")] - public async Task GetSurveyResponsesMaintenanceCenterSurveyAsync_ShouldReturnStatusCode200() - { - SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject(); - var mockResponse = await MockData.getOkResponse(); - mockSurveyResponseService.Setup(service => service.GetSurveyResponsesByMaintenanceCenterAsync(1)).ReturnsAsync(mockResponse); - var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object); - var result = (OkObjectResult)await surveyResponseProvider.GetAnswersByMaintenaceCentersync(1); - Assert.Equal(200, result.StatusCode); - } - - [Fact(DisplayName = "Get Responses by maintenanceCenter and surveyId - No Content Case")] - public async Task GetSurveyResponsesMaintenanceCenterSurveyAsync_ShouldReturnStatusCode204() - { - var mockResponse = await MockData.getResponse(); - mockSurveyResponseService.Setup(service => service.GetSurveyResponsesByMaintenanceCenterAsync(1)).ReturnsAsync(mockResponse); - var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object); - var result = (NoContentResult)await surveyResponseProvider.GetAnswersByMaintenaceCentersync(1); - Assert.Equal(204, result.StatusCode); - } - - [Fact(DisplayName = "Get SurveyResponse by responseId- Ok case")] - public async Task GetSurveyResponsesByResponseIdyAsync_ShouldReturnStatusCode200() - { - SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject(); - var mockResponse = await MockData.getOkResponse(); - mockSurveyResponseService.Setup(service => service.GetSurveyResponseByIdAsync(1)).ReturnsAsync(mockResponse); - var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object); - var result = (OkObjectResult)await surveyResponseProvider.GetSurveyResponseByIdAsync(1); - Assert.Equal(200, result.StatusCode); - } - - [Fact(DisplayName = "Get Responses by maintenanceCenter and surveyId - NoContent Case")] - public async Task GetSurveyResponsesByResponseIdyAsync_ShouldReturnStatusCode204() - { - var mockResponse = await MockData.getResponse(); - mockSurveyResponseService.Setup(service => service.GetSurveyResponseByIdAsync(1)).ReturnsAsync(mockResponse); - var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object); - var result = (NoContentResult)await surveyResponseProvider.GetSurveyResponseByIdAsync(1); - Assert.Equal(204, result.StatusCode); - } - - - [Fact(DisplayName = "Post Responses - Ok case")] - public async Task PostSurveyAsync_ShouldReturnStatusCode200() - { - SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject(); - var mockResponse = await MockData.getOkResponse(mockRequestObject); - mockSurveyResponseService.Setup(service => service.PostSurveyResponseAsync(mockRequestObject)).ReturnsAsync(mockResponse); - var surveyResponseController = new ResponsesController(mockSurveyResponseService.Object); - var result = (OkObjectResult)await surveyResponseController.PostSurveysAsync(mockRequestObject); - Assert.Equal(200, result.StatusCode); - } - - [Fact(DisplayName = "Post Responses - BadRequest case")] - public async Task PostSurveyAsync_ShouldReturnStatusCode400() - { - SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject(); - var mockResponse = await MockData.getResponse(); - mockSurveyResponseService.Setup(service => service.PostSurveyResponseAsync(mockRequestObject)).ReturnsAsync(mockResponse); - var surveyResponseController = new ResponsesController(mockSurveyResponseService.Object); - var result = (BadRequestObjectResult)await surveyResponseController.PostSurveysAsync(mockRequestObject); - Assert.Equal(400, result.StatusCode); - } - - [Fact(DisplayName = "Put Responses - Ok case")] - public async Task PutSurveyAsync_ShouldReturnStatusCode200() - { - SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject(); - var mockResponse = await MockData.getOkResponse(mockRequestObject); - mockSurveyResponseService.Setup(service => service.PutSurveyResponseAsync(1, mockRequestObject)).ReturnsAsync(mockResponse); - var surveyResponseController = new ResponsesController(mockSurveyResponseService.Object); - var result = (OkObjectResult)await surveyResponseController.PutSurveyResponseAsync(1, mockRequestObject); - Assert.Equal(200, result.StatusCode); - } - - [Fact(DisplayName = "Put Responses - BadRequest case")] - public async Task PutSurveyAsync_ShouldReturnStatusCode404() - { - SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject(); - var mockResponse = await MockData.getResponse(); - mockSurveyResponseService.Setup(service => service.PutSurveyResponseAsync(1, mockRequestObject)).ReturnsAsync(mockResponse); ; - var surveyResponseController = new ResponsesController(mockSurveyResponseService.Object); - var result = (BadRequestObjectResult)await surveyResponseController.PutSurveyResponseAsync(1, mockRequestObject); - Assert.Equal(400, result.StatusCode); - } - - [Fact(DisplayName = "Delete Responses - Ok case")] - public async Task DeleteSurveyAsync_ShouldReturnStatusCode200() - { - SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject(); - var mockResponse = await MockData.getOkResponse(mockRequestObject); - mockSurveyResponseService.Setup(service => service.DeleteSurveyResponseAsync(1)).ReturnsAsync(mockResponse); - var surveyResponseController = new ResponsesController(mockSurveyResponseService.Object); - var result = (OkObjectResult)await surveyResponseController.DeleteSurveyResponseAsync(1); - Assert.Equal(200, result.StatusCode); - } - - [Fact(DisplayName = "Delete Responses - NotFound case")] - public async Task DeleteSurveyAsync_ShouldReturnStatusCode404() - { - var mockResponse = await MockData.getResponse(); - mockSurveyResponseService.Setup(service => service.DeleteSurveyResponseAsync(1)).ReturnsAsync(mockResponse); ; - var surveyResponseController = new ResponsesController(mockSurveyResponseService.Object); - var result = (NotFoundResult)await surveyResponseController.DeleteSurveyResponseAsync(1); - Assert.Equal(404, result.StatusCode); - } - } -} \ No newline at end of file