public async Task Test_AddClaimCommand_ShouldAddClaim() { var service = await TestHelper.GetCosmosDbClaimDocumentService(); AddClaimCommand command = new AddClaimCommand() { Name = "New Application Test Claim", Year = 2014, DamageCost = 13.1M, Type = ClaimType.Fire }; var fakeMediator = new Mock <IMediator>(); var handler = new AddClaimCommandHandler(fakeMediator.Object, service); var result = await handler.Handle(command, CancellationToken.None); Assert.GreaterOrEqual(result, 0); }
public async Task Test_Add_ShouldAddClaimAndReturnsBadRequestIfNotValidData() { var server = new TestServer(new WebHostBuilder().UseStartup <Startup>()); var client = server.CreateClient(); AddClaimCommand command = new AddClaimCommand() { Name = "Integration Test Claim", Year = 2011, DamageCost = 130M, Type = ClaimType.Grounding }; var content = IntegrationTestHelper.GetRequestContent(command); var response = await client.PostAsync($"/api/claim/add", content); Assert.IsTrue(response.StatusCode == System.Net.HttpStatusCode.BadRequest); }
public async Task Test_Add_ShouldAddClaimAndReturnsSuccessCode() { var server = new TestServer(new WebHostBuilder().UseStartup <Startup>()); var client = server.CreateClient(); AddClaimCommand command = new AddClaimCommand() { Name = "Integration Test Claim", Year = 2014, DamageCost = 13M, Type = ClaimType.Grounding }; var content = IntegrationTestHelper.GetRequestContent(command); var response = await client.PostAsync($"/api/claim/add", content); response.EnsureSuccessStatusCode(); }
public async Task <IActionResult> Add(AddClaimCommand command) { await _mediator.Send(command); return(Ok()); }