From 4a9f2e51bbfe10aad43d4388ccc6de9f081167a5 Mon Sep 17 00:00:00 2001 From: Denis Nutiu Date: Wed, 2 Jun 2021 22:58:46 +0300 Subject: [PATCH] Add unit tests for DELETE in FeedbackReceiverController. --- .../TestFeedbackReceiverController.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Retroactiune.UnitTests/Retroactiune.WebAPI/Controllers/TestFeedbackReceiverController.cs b/Retroactiune.UnitTests/Retroactiune.WebAPI/Controllers/TestFeedbackReceiverController.cs index c50d4d3..29e7adc 100644 --- a/Retroactiune.UnitTests/Retroactiune.WebAPI/Controllers/TestFeedbackReceiverController.cs +++ b/Retroactiune.UnitTests/Retroactiune.WebAPI/Controllers/TestFeedbackReceiverController.cs @@ -15,6 +15,7 @@ namespace Retroactiune.Tests.Retroactiune.WebAPI.Controllers [Fact] public async Task Post_Fail_Creation_No_items() { + // Arrange var mapper = TestUtils.GetMapper(); var mockService = new Mock(); @@ -30,6 +31,7 @@ namespace Retroactiune.Tests.Retroactiune.WebAPI.Controllers [Theory, AutoData] public async Task Post_Successful_Creation_Two_items(IEnumerable items) { + // Arrange var mapper = TestUtils.GetMapper(); var mockService = new Mock(); @@ -41,5 +43,22 @@ namespace Retroactiune.Tests.Retroactiune.WebAPI.Controllers Assert.IsType(result); mockService.Verify(s => s.CreateManyAsync(It.IsAny>()), Times.Once); } + + [Fact] + public async Task Delete_Successful() + { + // Arrange + var mapper = TestUtils.GetMapper(); + var mockService = new Mock(); + + // Test + var controller = new FeedbackReceiversController(mockService.Object, mapper, null); + var result = await controller.Delete("bad_guid_but_unit_test_works_cause_validation_doesnt"); + + // Assert + Assert.IsType(result); + mockService.Verify(s => s.DeleteOneAsync("bad_guid_but_unit_test_works_cause_validation_doesnt"), + Times.Once); + } } } \ No newline at end of file