Merged PR 69: fixed attachment test case issues

fixed attachment test case issues
This commit is contained in:
Uppu, Vijay 2023-11-22 21:54:53 +00:00
commit 6575c2f219
3 changed files with 17 additions and 17 deletions

View File

@ -33,7 +33,7 @@ namespace DamageAssesment.Api.Attachments.Test
public async Task GetAttachmentsAsync_ShouldReturnStatusCode204()
{
var mockAttachmentService = new Mock<IAttachmentsProvider>();
var mockUploadService = new Mock<UploadService>();
var mockUploadService = new Mock<IUploadService>();
var mockResponse = await MockData.getNoContentResponse();
mockAttachmentService.Setup(service => service.GetAttachmentsAsync()).ReturnsAsync(mockResponse);
@ -47,7 +47,7 @@ namespace DamageAssesment.Api.Attachments.Test
public async Task GetAttachmentAsync_ShouldReturnStatusCode200()
{
var mockAttachmentService = new Mock<IAttachmentsProvider>();
var mockUploadService = new Mock<UploadService>();
var mockUploadService = new Mock<IUploadService>();
var mockResponse = await MockData.getOkResponse(1);
mockAttachmentService.Setup(service => service.GetAttachmentByIdAsync(1)).ReturnsAsync(mockResponse);
@ -61,7 +61,7 @@ namespace DamageAssesment.Api.Attachments.Test
public async Task GetAttachmentAsync_ShouldReturnStatusCode404()
{
var mockAttachmentService = new Mock<IAttachmentsProvider>();
var mockUploadService = new Mock<UploadService>();
var mockUploadService = new Mock<IUploadService>();
var mockResponse = await MockData.getNotFoundResponse();
mockAttachmentService.Setup(service => service.GetAttachmentByIdAsync(99)).ReturnsAsync(mockResponse);
var AttachmentProvider = new AttachmentsController(mockAttachmentService.Object, mockUploadService.Object);
@ -73,14 +73,14 @@ namespace DamageAssesment.Api.Attachments.Test
public async Task PostAttachmentAsync_ShouldReturnStatusCode200()
{
var mockAttachmentService = new Mock<IAttachmentsProvider>();
var mockUploadService = new Mock<UploadService>();
var mockUploadService = new Mock<IUploadService>();
var mockResponse = await MockData.getOkResponse();
var AttachmentResponse = await MockData.GetAttachmentInfo(0);
var mockInputAttachment = await MockData.getInputAttachmentData();
mockAttachmentService.Setup(service => service.PostAttachmentAsync(mockInputAttachment)).ReturnsAsync(mockResponse);
var AttachmentProvider = new AttachmentsController(mockAttachmentService.Object, mockUploadService.Object);
var result = (NoContentResult) await AttachmentProvider.UploadAttachmentAsync(AttachmentResponse);
var result = (NoContentResult)await AttachmentProvider.UploadAttachmentAsync(AttachmentResponse);
Assert.Equal(204, result.StatusCode);
}
@ -89,14 +89,14 @@ namespace DamageAssesment.Api.Attachments.Test
public async Task PostAttachmentAsync_ShouldReturnStatusCode400()
{
var mockAttachmentService = new Mock<IAttachmentsProvider>();
var mockUploadService = new Mock<UploadService>();
var mockUploadService = new Mock<IUploadService>();
var mockInputAttachment = await MockData.getInputAttachmentData();
var mockResponse = await MockData.getBadRequestResponse();
mockAttachmentService.Setup(service => service.PostAttachmentAsync(mockInputAttachment)).ReturnsAsync(mockResponse);
var AttachmentProvider = new AttachmentsController(mockAttachmentService.Object, mockUploadService.Object);
AttachmentInfo attachmentInfo=new AttachmentInfo();
var result = (BadRequestObjectResult) await AttachmentProvider.UploadAttachmentAsync(attachmentInfo);
AttachmentInfo attachmentInfo = new AttachmentInfo();
var result = (BadRequestObjectResult)await AttachmentProvider.UploadAttachmentAsync(attachmentInfo);
Assert.Equal(400, result.StatusCode);
}
@ -105,14 +105,14 @@ namespace DamageAssesment.Api.Attachments.Test
public async Task PutAttachmentAsync_ShouldReturnStatusCode200()
{
var mockAttachmentService = new Mock<IAttachmentsProvider>();
var mockUploadService = new Mock<UploadService>();
var mockUploadService = new Mock<IUploadService>();
var mockResponse = await MockData.getOkResponse();
var AttachmentResponse = await MockData.GetAttachmentInfo(1);
var mockInputAttachment = await MockData.getInputAttachmentData();
mockAttachmentService.Setup(service => service.PostAttachmentAsync(mockInputAttachment)).ReturnsAsync(mockResponse);
var AttachmentProvider = new AttachmentsController(mockAttachmentService.Object, mockUploadService.Object);
var result = (NoContentResult) await AttachmentProvider.UpdateAttachmentAsync(AttachmentResponse);
var result = (NoContentResult)await AttachmentProvider.UpdateAttachmentAsync(AttachmentResponse);
Assert.Equal(204, result.StatusCode);
}
@ -121,14 +121,14 @@ namespace DamageAssesment.Api.Attachments.Test
public async Task PutAttachmentAsync_ShouldReturnStatusCode400()
{
var mockAttachmentService = new Mock<IAttachmentsProvider>();
var mockUploadService = new Mock<UploadService>();
var mockUploadService = new Mock<IUploadService>();
var mockInputAttachment = await MockData.getInputAttachmentData();
var mockResponse = await MockData.getBadRequestResponse();
mockAttachmentService.Setup(service => service.PostAttachmentAsync(mockInputAttachment)).ReturnsAsync(mockResponse);
var AttachmentProvider = new AttachmentsController(mockAttachmentService.Object, mockUploadService.Object);
AttachmentInfo attachmentInfo = new AttachmentInfo();
var result = (BadRequestObjectResult) await AttachmentProvider.UpdateAttachmentAsync(attachmentInfo);
var result = (BadRequestObjectResult)await AttachmentProvider.UpdateAttachmentAsync(attachmentInfo);
Assert.Equal(400, result.StatusCode);
}
@ -136,7 +136,7 @@ namespace DamageAssesment.Api.Attachments.Test
public async Task DeleteAttachmentAsync_ShouldReturnStatusCode200()
{
var mockAttachmentService = new Mock<IAttachmentsProvider>();
var mockUploadService = new Mock<UploadService>();
var mockUploadService = new Mock<IUploadService>();
var mockResponse = await MockData.getOkResponse(1);
mockAttachmentService.Setup(service => service.DeleteAttachmentAsync(1)).ReturnsAsync(mockResponse);
mockUploadService.Setup(service => service.Deletefile(""));
@ -150,7 +150,7 @@ namespace DamageAssesment.Api.Attachments.Test
public async Task DeleteAttachmentAsync_ShouldReturnStatusCode404()
{
var mockAttachmentService = new Mock<IAttachmentsProvider>();
var mockUploadService = new Mock<UploadService>();
var mockUploadService = new Mock<IUploadService>();
var mockResponse = await MockData.getNotFoundResponse();
mockAttachmentService.Setup(service => service.DeleteAttachmentAsync(1)).ReturnsAsync(mockResponse);
var AttachmentProvider = new AttachmentsController(mockAttachmentService.Object, mockUploadService.Object);

View File

@ -11,7 +11,7 @@
"AllowedHosts": "*",
"ConnectionStrings": {
//"EmployeeConnection": "Server=DESKTOP-OF5DPLQ\\SQLEXPRESS;Database=da_survey_dev;Trusted_Connection=True;TrustServerCertificate=True;"
"EmployeeConnection": "Server=tcp:da-dev.database.windows.net,1433;Initial Catalog=da-dev-db;Encrypt=True;User ID=admin-dev;Password=b3tgRABw8LGE75k;TrustServerCertificate=False;Connection Timeout=30;"
"EmployeeConnection": "Server=207.180.248.35;Database=da_survey_dev;User Id=sa;Password=YourStrongPassw0rd;TrustServerCertificate=True;"
}
}

View File

@ -11,7 +11,7 @@
"AllowedHosts": "*",
"ConnectionStrings": {
//"QuestionConnection": "Server=DESKTOP-OF5DPLQ\\SQLEXPRESS;Database=da_survey_dev;Trusted_Connection=True;TrustServerCertificate=True;"
"QuestionConnection": "Server=tcp:da-dev.database.windows.net,1433;Initial Catalog=da-dev-db;Encrypt=True;User ID=admin-dev;Password=b3tgRABw8LGE75k;TrustServerCertificate=False;Connection Timeout=30;"
"QuestionConnection": "Server=207.180.248.35;Database=da_survey_dev;User Id=sa;Password=YourStrongPassw0rd;TrustServerCertificate=True;"
}
}