Deleted DamageAssesment.Responses.Test
This commit is contained in:
parent
6575c2f219
commit
ede178042f
@ -1,30 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
|
||||
<PackageReference Include="Moq" Version="4.18.4" />
|
||||
<PackageReference Include="xunit" Version="2.4.2" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="coverlet.collector" Version="3.2.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DamageAssesment.Api.Responses\DamageAssesment.Api.Responses.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -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<Models.SurveyResponse> getSurveyResponseObject()
|
||||
{
|
||||
return new Models.SurveyResponse { EmployeeId = 1, LocationId = 1, SurveyId = 1, Id = 1 };
|
||||
}
|
||||
}
|
||||
}
|
@ -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<ISurveysResponse> mockSurveyResponseService;
|
||||
private string token { get; set; }
|
||||
public ResponsesServiceTest()
|
||||
{
|
||||
mockSurveyResponseService = new Mock<ISurveysResponse>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user