diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Acceptance/GlobalUsings.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Acceptance/GlobalUsings.cs
new file mode 100644
index 00000000..ab67c7ea
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Acceptance/GlobalUsings.cs
@@ -0,0 +1 @@
+global using Microsoft.VisualStudio.TestTools.UnitTesting;
\ No newline at end of file
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Acceptance/OrcaHello.Web.Api.Tests.Acceptance.csproj b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Acceptance/OrcaHello.Web.Api.Tests.Acceptance.csproj
new file mode 100644
index 00000000..b8cb93df
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Acceptance/OrcaHello.Web.Api.Tests.Acceptance.csproj
@@ -0,0 +1,19 @@
+
+
+
+ net7.0
+ enable
+ enable
+
+ false
+ true
+
+
+
+
+
+
+
+
+
+
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/CommentsControllerTests/Default.GetPaginatedNegativeAndUnknownCommentsForGivenTimeframeAsync.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/CommentsControllerTests/Default.GetPaginatedNegativeAndUnknownCommentsForGivenTimeframeAsync.cs
new file mode 100644
index 00000000..090ca176
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/CommentsControllerTests/Default.GetPaginatedNegativeAndUnknownCommentsForGivenTimeframeAsync.cs
@@ -0,0 +1,35 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ public partial class CommentsControllerTests
+ {
+ [TestMethod]
+ public async Task Default_GetGetPaginatedNegativeAndUnknownCommentsForGivenTimeframeAsync_Expect_DetectionListResponse()
+ {
+ CommentListResponse response = new()
+ {
+ Count = 2,
+ FromDate = DateTime.Now,
+ ToDate = DateTime.Now.AddDays(1),
+ Comments = new List { new() }
+ };
+
+ _orchestrationServiceMock.Setup(service =>
+ service.RetrieveNegativeAndUnknownCommentsForGivenTimeframeAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()))
+ .ReturnsAsync(response);
+
+ ActionResult actionResult =
+ await _controller.GetPaginatedNegativeAndUnknownCommentsForGivenTimeframeAsync(DateTime.Now, DateTime.Now.AddDays(1), 1, 10);
+
+ var contentResult = actionResult.Result as ObjectResult;
+ Assert.IsNotNull(contentResult);
+ Assert.AreEqual(200, contentResult.StatusCode);
+
+ Assert.AreEqual(response.Comments.Count(),
+ ((CommentListResponse)contentResult.Value).Comments.Count());
+
+ _orchestrationServiceMock.Verify(service =>
+ service.RetrieveNegativeAndUnknownCommentsForGivenTimeframeAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()),
+ Times.Once);
+ }
+ }
+}
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/CommentsControllerTests/Default.GetPaginatedPositiveCommentsForGivenTimeframeAsync.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/CommentsControllerTests/Default.GetPaginatedPositiveCommentsForGivenTimeframeAsync.cs
new file mode 100644
index 00000000..c3d4d3f3
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/CommentsControllerTests/Default.GetPaginatedPositiveCommentsForGivenTimeframeAsync.cs
@@ -0,0 +1,35 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ public partial class CommentsControllerTests
+ {
+ [TestMethod]
+ public async Task Default_GetGetPaginatedPositiveCommentsForGivenTimeframeAsync_Expect_DetectionListResponse()
+ {
+ CommentListResponse response = new()
+ {
+ Count = 2,
+ FromDate = DateTime.Now,
+ ToDate = DateTime.Now.AddDays(1),
+ Comments = new List { new() }
+ };
+
+ _orchestrationServiceMock.Setup(service =>
+ service.RetrievePositiveCommentsForGivenTimeframeAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()))
+ .ReturnsAsync(response);
+
+ ActionResult actionResult =
+ await _controller.GetPaginatedPositiveCommentsForGivenTimeframeAsync(DateTime.Now, DateTime.Now.AddDays(1), 1, 10);
+
+ var contentResult = actionResult.Result as ObjectResult;
+ Assert.IsNotNull(contentResult);
+ Assert.AreEqual(200, contentResult.StatusCode);
+
+ Assert.AreEqual(response.Comments.Count(),
+ ((CommentListResponse)contentResult.Value).Comments.Count());
+
+ _orchestrationServiceMock.Verify(service =>
+ service.RetrievePositiveCommentsForGivenTimeframeAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()),
+ Times.Once);
+ }
+ }
+}
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/CommentsControllerTests/Setup.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/CommentsControllerTests/Setup.cs
new file mode 100644
index 00000000..b0da317d
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/CommentsControllerTests/Setup.cs
@@ -0,0 +1,24 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ [ExcludeFromCodeCoverage]
+ [TestClass]
+ public partial class CommentsControllerTests
+ {
+ private readonly Mock _orchestrationServiceMock;
+ private readonly CommentsController _controller;
+
+ public CommentsControllerTests()
+ {
+ _orchestrationServiceMock = new Mock();
+
+ _controller = new CommentsController(
+ commentOrchestrationService: _orchestrationServiceMock.Object);
+ }
+
+ [TestCleanup]
+ public void TestTeardown()
+ {
+ _orchestrationServiceMock.VerifyNoOtherCalls();
+ }
+ }
+}
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/CommentsControllerTests/TryCatch.GetPaginatedNegativeAndUnknownCommentsForGivenTimeframeAsync.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/CommentsControllerTests/TryCatch.GetPaginatedNegativeAndUnknownCommentsForGivenTimeframeAsync.cs
new file mode 100644
index 00000000..d5e7e71a
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/CommentsControllerTests/TryCatch.GetPaginatedNegativeAndUnknownCommentsForGivenTimeframeAsync.cs
@@ -0,0 +1,42 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ public partial class CommentsControllerTests
+ {
+ [TestMethod]
+ public async Task TryCatch_GetPaginatedNegativeAndUnknownCommentsForGivenTimeframeAsync_Expect_Exception()
+ {
+ _orchestrationServiceMock
+ .SetupSequence(p => p.RetrieveNegativeAndUnknownCommentsForGivenTimeframeAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()))
+
+ .Throws(new CommentOrchestrationValidationException(new Exception()))
+ .Throws(new CommentOrchestrationDependencyValidationException(new Exception()))
+
+ .Throws(new CommentOrchestrationDependencyException(new Exception()))
+ .Throws(new CommentOrchestrationServiceException(new Exception()))
+
+ .Throws(new Exception());
+
+ await ExecuteRetrieveNegativeComments(2, StatusCodes.Status400BadRequest);
+ await ExecuteRetrieveNegativeComments(3, StatusCodes.Status500InternalServerError);
+
+ _orchestrationServiceMock
+ .Verify(service => service
+ .RetrieveNegativeAndUnknownCommentsForGivenTimeframeAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()),
+ Times.Exactly(5));
+
+ }
+
+ private async Task ExecuteRetrieveNegativeComments(int count, int statusCode)
+ {
+ for (int x = 0; x < count; x++)
+ {
+ ActionResult actionResult =
+ await _controller.GetPaginatedNegativeAndUnknownCommentsForGivenTimeframeAsync(DateTime.Now, DateTime.Now.AddDays(1), 1, 10);
+
+ var contentResult = actionResult.Result as ObjectResult;
+ Assert.IsNotNull(contentResult);
+ Assert.AreEqual(statusCode, contentResult.StatusCode);
+ }
+ }
+ }
+}
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/CommentsControllerTests/TryCatch.GetPaginatedPositiveCommentsForGivenTimeframeAsync.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/CommentsControllerTests/TryCatch.GetPaginatedPositiveCommentsForGivenTimeframeAsync.cs
new file mode 100644
index 00000000..7a97faa3
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/CommentsControllerTests/TryCatch.GetPaginatedPositiveCommentsForGivenTimeframeAsync.cs
@@ -0,0 +1,42 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ public partial class CommentsControllerTests
+ {
+ [TestMethod]
+ public async Task TryCatch_GetPaginatedPositiveCommentsForGivenTimeframeAsync_Expect_Exception()
+ {
+ _orchestrationServiceMock
+ .SetupSequence(p => p.RetrievePositiveCommentsForGivenTimeframeAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()))
+
+ .Throws(new CommentOrchestrationValidationException(new Exception()))
+ .Throws(new CommentOrchestrationDependencyValidationException(new Exception()))
+
+ .Throws(new CommentOrchestrationDependencyException(new Exception()))
+ .Throws(new CommentOrchestrationServiceException(new Exception()))
+
+ .Throws(new Exception());
+
+ await ExecuteRetrieveComments(2, StatusCodes.Status400BadRequest);
+ await ExecuteRetrieveComments(3, StatusCodes.Status500InternalServerError);
+
+ _orchestrationServiceMock
+ .Verify(service => service
+ .RetrievePositiveCommentsForGivenTimeframeAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()),
+ Times.Exactly(5));
+
+ }
+
+ private async Task ExecuteRetrieveComments(int count, int statusCode)
+ {
+ for (int x = 0; x < count; x++)
+ {
+ ActionResult actionResult =
+ await _controller.GetPaginatedPositiveCommentsForGivenTimeframeAsync(DateTime.Now, DateTime.Now.AddDays(1), 1, 10);
+
+ var contentResult = actionResult.Result as ObjectResult;
+ Assert.IsNotNull(contentResult);
+ Assert.AreEqual(statusCode, contentResult.StatusCode);
+ }
+ }
+ }
+}
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/DetectionsControllerTests/Default.GetDetectionByIdAsync.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/DetectionsControllerTests/Default.GetDetectionByIdAsync.cs
new file mode 100644
index 00000000..75af930e
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/DetectionsControllerTests/Default.GetDetectionByIdAsync.cs
@@ -0,0 +1,30 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ public partial class DetectionsControllerTests
+ {
+
+ [TestMethod]
+ public async Task Default_GetDetectionByIdAsync_Expect_Detection()
+ {
+ Detection expectedResult = new();
+
+ _orchestrationServiceMock.Setup(service =>
+ service.RetrieveDetectionByIdAsync(It.IsAny()))
+ .ReturnsAsync(expectedResult);
+
+ ActionResult actionResult =
+ await _controller.GetDetectionByIdAsync(Guid.NewGuid().ToString());
+
+
+ var contentResult = actionResult.Result as ObjectResult;
+ Assert.IsNotNull(contentResult);
+ Assert.AreEqual(200, contentResult.StatusCode);
+
+ Assert.IsNotNull((Detection)contentResult.Value);
+
+ _orchestrationServiceMock.Verify(service =>
+ service.RetrieveDetectionByIdAsync(It.IsAny()),
+ Times.Once);
+ }
+ }
+}
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/DetectionsControllerTests/Default.GetDetectionsForGivenInterestLabelAsync.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/DetectionsControllerTests/Default.GetDetectionsForGivenInterestLabelAsync.cs
new file mode 100644
index 00000000..6dd4fea8
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/DetectionsControllerTests/Default.GetDetectionsForGivenInterestLabelAsync.cs
@@ -0,0 +1,34 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ public partial class DetectionsControllerTests
+ {
+ [TestMethod]
+ public async Task Default_GetDetectionsForGivenInterestLabelAsyncc_Expect_DetectionListForInterestLabelResponse()
+ {
+ DetectionListForInterestLabelResponse response = new()
+ {
+ TotalCount = 1,
+ Detections = new List { new Detection() },
+ InterestLabel = "test"
+ };
+
+ _orchestrationServiceMock.Setup(service =>
+ service.RetrieveDetectionsForGivenInterestLabelAsync(It.IsAny()))
+ .ReturnsAsync(response);
+
+ ActionResult actionResult =
+ await _controller.GetDetectionsForGivenInterestLabelAsync("test");
+
+ var contentResult = actionResult.Result as ObjectResult;
+ Assert.IsNotNull(contentResult);
+ Assert.AreEqual(200, contentResult.StatusCode);
+
+ Assert.AreEqual(response.Detections.Count(),
+ ((DetectionListForInterestLabelResponse)contentResult.Value).Detections.Count());
+
+ _orchestrationServiceMock.Verify(service =>
+ service.RetrieveDetectionsForGivenInterestLabelAsync(It.IsAny()),
+ Times.Once);
+ }
+ }
+}
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/DetectionsControllerTests/Default.GetPaginatedDetectionsAsync.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/DetectionsControllerTests/Default.GetPaginatedDetectionsAsync.cs
new file mode 100644
index 00000000..ada9c2a9
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/DetectionsControllerTests/Default.GetPaginatedDetectionsAsync.cs
@@ -0,0 +1,41 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ public partial class DetectionsControllerTests
+ {
+ [TestMethod]
+ public async Task Default_GetPaginatedDetectionsAsync_Expect_DetectionListResponse()
+ {
+ DetectionListResponse response = new()
+ {
+ Count = 2,
+ FromDate = DateTime.Now,
+ ToDate = DateTime.Now.AddDays(1),
+ Detections = new List { new() },
+ State = "Positive",
+ SortBy = "timestamp",
+ SortOrder = "desc",
+ Location = "location"
+ };
+
+ _orchestrationServiceMock.Setup(service =>
+ service.RetrieveFilteredDetectionsAsync(It.IsAny(), It.IsAny(), It.IsAny(),
+ It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()))
+ .ReturnsAsync(response);
+
+ ActionResult actionResult =
+ await _controller.GetPaginatedDetectionsAsync("Positive", DateTime.Now, DateTime.Now.AddDays(1), "timestamp", true, 1, 10, null);
+
+ var contentResult = actionResult.Result as ObjectResult;
+ Assert.IsNotNull(contentResult);
+ Assert.AreEqual(200, contentResult.StatusCode);
+
+ Assert.AreEqual(response.Detections.Count(),
+ ((DetectionListResponse)contentResult.Value).Detections.Count());
+
+ _orchestrationServiceMock.Verify(service =>
+ service.RetrieveFilteredDetectionsAsync(It.IsAny(), It.IsAny(), It.IsAny(),
+ It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()),
+ Times.Once);
+ }
+ }
+}
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/DetectionsControllerTests/Default.GetPaginatedDetectionsForGivenTimeframeAndTagAsync.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/DetectionsControllerTests/Default.GetPaginatedDetectionsForGivenTimeframeAndTagAsync.cs
new file mode 100644
index 00000000..f2b997e4
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/DetectionsControllerTests/Default.GetPaginatedDetectionsForGivenTimeframeAndTagAsync.cs
@@ -0,0 +1,35 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ public partial class DetectionsControllerTests
+ {
+ [TestMethod]
+ public async Task Default_GetPaginatedDetectionsForGivenTimeframeAndTagAsync_Expect_DetectionListResponse()
+ {
+ DetectionListForTagResponse response = new()
+ {
+ Count = 2,
+ FromDate = DateTime.Now,
+ ToDate = DateTime.Now.AddDays(1),
+ Detections = new List { new Detection() }
+ };
+
+ _orchestrationServiceMock.Setup(service =>
+ service.RetrieveDetectionsForGivenTimeframeAndTagAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()))
+ .ReturnsAsync(response);
+
+ ActionResult actionResult =
+ await _controller.GetPaginatedDetectionsForGivenTimeframeAndTagAsync("tag", DateTime.Now, DateTime.Now.AddDays(1), 1, 10);
+
+ var contentResult = actionResult.Result as ObjectResult;
+ Assert.IsNotNull(contentResult);
+ Assert.AreEqual(200, contentResult.StatusCode);
+
+ Assert.AreEqual(response.Detections.Count,
+ ((DetectionListForTagResponse)contentResult.Value).Detections.Count);
+
+ _orchestrationServiceMock.Verify(service =>
+ service.RetrieveDetectionsForGivenTimeframeAndTagAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()),
+ Times.Once);
+ }
+ }
+}
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/DetectionsControllerTests/Default.PutModeratedInfoAsync.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/DetectionsControllerTests/Default.PutModeratedInfoAsync.cs
new file mode 100644
index 00000000..ab1fdee7
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/DetectionsControllerTests/Default.PutModeratedInfoAsync.cs
@@ -0,0 +1,39 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ public partial class DetectionsControllerTests
+ {
+
+ [TestMethod]
+ public async Task Default_PutModeratedInfoAsync_Expect_Detection()
+ {
+ Detection expectedResult = new();
+
+ _orchestrationServiceMock.Setup(service =>
+ service.ModerateDetectionByIdAsync(It.IsAny(), It.IsAny()))
+ .ReturnsAsync(expectedResult);
+
+ ModerateDetectionRequest request = new()
+ {
+ Id = Guid.NewGuid().ToString(),
+ Moderator = "Ira M. Goober",
+ DateModerated = DateTime.UtcNow,
+ Comments = "Comments",
+ Tags = new List() { "Tag1" }
+ };
+
+ ActionResult actionResult =
+ await _controller.PutModeratedInfoAsync(Guid.NewGuid().ToString(), request);
+
+
+ var contentResult = actionResult.Result as ObjectResult;
+ Assert.IsNotNull(contentResult);
+ Assert.AreEqual(200, contentResult.StatusCode);
+
+ Assert.IsNotNull((Detection)contentResult.Value);
+
+ _orchestrationServiceMock.Verify(service =>
+ service.ModerateDetectionByIdAsync(It.IsAny(), It.IsAny()),
+ Times.Once);
+ }
+ }
+}
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/DetectionsControllerTests/Setup.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/DetectionsControllerTests/Setup.cs
new file mode 100644
index 00000000..385040c5
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/DetectionsControllerTests/Setup.cs
@@ -0,0 +1,24 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ [TestClass]
+ [ExcludeFromCodeCoverage]
+ public partial class DetectionsControllerTests
+ {
+ private readonly Mock _orchestrationServiceMock;
+ private readonly DetectionsController _controller;
+
+ public DetectionsControllerTests()
+ {
+ _orchestrationServiceMock = new Mock();
+
+ _controller = new DetectionsController(
+ detectionOrchestrationService: _orchestrationServiceMock.Object);
+ }
+
+ [TestCleanup]
+ public void TestTeardown()
+ {
+ _orchestrationServiceMock.VerifyNoOtherCalls();
+ }
+ }
+}
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/DetectionsControllerTests/TryCatch.GetDetectionByIdAsync.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/DetectionsControllerTests/TryCatch.GetDetectionByIdAsync.cs
new file mode 100644
index 00000000..477f8af3
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/DetectionsControllerTests/TryCatch.GetDetectionByIdAsync.cs
@@ -0,0 +1,45 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ public partial class DetectionsControllerTests
+ {
+ [TestMethod]
+ public async Task TryCatch_GetDetectionByIdAsync_Expect_Exception()
+ {
+ _orchestrationServiceMock
+ .SetupSequence(p => p.RetrieveDetectionByIdAsync(It.IsAny()))
+
+ .Throws(new DetectionOrchestrationValidationException(new NotFoundMetadataException("id")))
+
+ .Throws(new DetectionOrchestrationValidationException(new Exception()))
+ .Throws(new DetectionOrchestrationDependencyValidationException(new Exception()))
+
+ .Throws(new DetectionOrchestrationDependencyException(new Exception()))
+ .Throws(new DetectionOrchestrationServiceException(new Exception()))
+
+ .Throws(new Exception());
+
+ await ExecuteRetrieveDetectionById(1, StatusCodes.Status404NotFound);
+ await ExecuteRetrieveDetectionById(2, StatusCodes.Status400BadRequest);
+ await ExecuteRetrieveDetectionById(3, StatusCodes.Status500InternalServerError);
+
+ _orchestrationServiceMock
+ .Verify(service => service
+ .RetrieveDetectionByIdAsync(It.IsAny()),
+ Times.Exactly(6));
+
+ }
+
+ private async Task ExecuteRetrieveDetectionById(int count, int statusCode)
+ {
+ for (int x = 0; x < count; x++)
+ {
+ ActionResult actionResult =
+ await _controller.GetDetectionByIdAsync(It.IsAny());
+
+ var contentResult = actionResult.Result as ObjectResult;
+ Assert.IsNotNull(contentResult);
+ Assert.AreEqual(statusCode, contentResult.StatusCode);
+ }
+ }
+ }
+}
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/DetectionsControllerTests/TryCatch.GetDetectionsForGivenInterestLabelAsync.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/DetectionsControllerTests/TryCatch.GetDetectionsForGivenInterestLabelAsync.cs
new file mode 100644
index 00000000..e643f36e
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/DetectionsControllerTests/TryCatch.GetDetectionsForGivenInterestLabelAsync.cs
@@ -0,0 +1,42 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ public partial class DetectionsControllerTests
+ {
+ [TestMethod]
+ public async Task TryCatch_GetDetectionsForGivenInterestLabelAsync_Expect_Exception()
+ {
+ _orchestrationServiceMock
+ .SetupSequence(p => p.RetrieveDetectionsForGivenInterestLabelAsync(It.IsAny()))
+
+ .Throws(new DetectionOrchestrationValidationException(new Exception()))
+ .Throws(new DetectionOrchestrationDependencyValidationException(new Exception()))
+
+ .Throws(new DetectionOrchestrationDependencyException(new Exception()))
+ .Throws(new DetectionOrchestrationServiceException(new Exception()))
+
+ .Throws(new Exception());
+
+ await ExecuteRetrieveDetectionsByLabel(2, StatusCodes.Status400BadRequest);
+ await ExecuteRetrieveDetectionsByLabel(3, StatusCodes.Status500InternalServerError);
+
+ _orchestrationServiceMock
+ .Verify(service => service
+ .RetrieveDetectionsForGivenInterestLabelAsync(It.IsAny()),
+ Times.Exactly(5));
+
+ }
+
+ private async Task ExecuteRetrieveDetectionsByLabel(int count, int statusCode)
+ {
+ for (int x = 0; x < count; x++)
+ {
+ ActionResult actionResult =
+ await _controller.GetDetectionsForGivenInterestLabelAsync(It.IsAny());
+
+ var contentResult = actionResult.Result as ObjectResult;
+ Assert.IsNotNull(contentResult);
+ Assert.AreEqual(statusCode, contentResult.StatusCode);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/DetectionsControllerTests/TryCatch.GetPaginatedDetectionsAsync.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/DetectionsControllerTests/TryCatch.GetPaginatedDetectionsAsync.cs
new file mode 100644
index 00000000..0ced373c
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/DetectionsControllerTests/TryCatch.GetPaginatedDetectionsAsync.cs
@@ -0,0 +1,47 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ public partial class DetectionsControllerTests
+ {
+
+
+ [TestMethod]
+ public async Task TryCatch_GetPaginatedDetectionsAsync_Expect_Exception()
+ {
+ _orchestrationServiceMock
+ .SetupSequence(p => p.RetrieveFilteredDetectionsAsync(It.IsAny(), It.IsAny(), It.IsAny(),
+ It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()))
+
+ .Throws(new DetectionOrchestrationValidationException(new Exception()))
+ .Throws(new DetectionOrchestrationDependencyValidationException(new Exception()))
+
+ .Throws(new DetectionOrchestrationDependencyException(new Exception()))
+ .Throws(new DetectionOrchestrationServiceException(new Exception()))
+
+ .Throws(new Exception());
+
+ await ExecuteRetrieveDetections(2, StatusCodes.Status400BadRequest);
+ await ExecuteRetrieveDetections(3, StatusCodes.Status500InternalServerError);
+
+ _orchestrationServiceMock
+ .Verify(service => service
+ .RetrieveFilteredDetectionsAsync(It.IsAny(), It.IsAny(), It.IsAny(),
+ It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()),
+ Times.Exactly(5));
+
+ }
+
+ private async Task ExecuteRetrieveDetections(int count, int statusCode)
+ {
+ for (int x = 0; x < count; x++)
+ {
+ ActionResult actionResult =
+ await _controller.GetPaginatedDetectionsAsync("state", DateTime.Now, DateTime.Now.AddDays(1), "sortBy", true,
+ 1, 10, "location");
+
+ var contentResult = actionResult.Result as ObjectResult;
+ Assert.IsNotNull(contentResult);
+ Assert.AreEqual(statusCode, contentResult.StatusCode);
+ }
+ }
+ }
+}
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/DetectionsControllerTests/TryCatch.GetPaginatedDetectionsForGivenTimeframeAndTagAsync.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/DetectionsControllerTests/TryCatch.GetPaginatedDetectionsForGivenTimeframeAndTagAsync.cs
new file mode 100644
index 00000000..98f1a682
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/DetectionsControllerTests/TryCatch.GetPaginatedDetectionsForGivenTimeframeAndTagAsync.cs
@@ -0,0 +1,42 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ public partial class DetectionsControllerTests
+ {
+ [TestMethod]
+ public async Task TryCatch_GetPaginatedDetectionsForGivenTimeframeAndTagAsync_Expect_Exception()
+ {
+ _orchestrationServiceMock
+ .SetupSequence(p => p.RetrieveDetectionsForGivenTimeframeAndTagAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()))
+
+ .Throws(new DetectionOrchestrationValidationException(new Exception()))
+ .Throws(new DetectionOrchestrationDependencyValidationException(new Exception()))
+
+ .Throws(new DetectionOrchestrationDependencyException(new Exception()))
+ .Throws(new DetectionOrchestrationServiceException(new Exception()))
+
+ .Throws(new Exception());
+
+ await ExecuteRetrieveDetectionsForTag(2, StatusCodes.Status400BadRequest);
+ await ExecuteRetrieveDetectionsForTag(3, StatusCodes.Status500InternalServerError);
+
+ _orchestrationServiceMock
+ .Verify(service => service
+ .RetrieveDetectionsForGivenTimeframeAndTagAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()),
+ Times.Exactly(5));
+
+ }
+
+ private async Task ExecuteRetrieveDetectionsForTag(int count, int statusCode)
+ {
+ for (int x = 0; x < count; x++)
+ {
+ ActionResult actionResult =
+ await _controller.GetPaginatedDetectionsForGivenTimeframeAndTagAsync("tag", DateTime.Now, DateTime.Now.AddDays(1), 1, 10);
+
+ var contentResult = actionResult.Result as ObjectResult;
+ Assert.IsNotNull(contentResult);
+ Assert.AreEqual(statusCode, contentResult.StatusCode);
+ }
+ }
+ }
+}
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/DetectionsControllerTests/TryCatch.PutModeratedInfoAsync.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/DetectionsControllerTests/TryCatch.PutModeratedInfoAsync.cs
new file mode 100644
index 00000000..2cb56f87
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/DetectionsControllerTests/TryCatch.PutModeratedInfoAsync.cs
@@ -0,0 +1,49 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ public partial class DetectionsControllerTests
+ {
+ [TestMethod]
+ public async Task TryCatch_PutModeratedInfoAsync_Expect_Exception()
+ {
+ _orchestrationServiceMock
+ .SetupSequence(p => p.ModerateDetectionByIdAsync(It.IsAny(), It.IsAny()))
+
+ .Throws(new DetectionOrchestrationValidationException(new NotFoundMetadataException("id")))
+
+ .Throws(new DetectionOrchestrationValidationException(new DetectionNotDeletedException("id")))
+ .Throws(new DetectionOrchestrationValidationException(new DetectionNotInsertedException("id")))
+
+ .Throws(new DetectionOrchestrationValidationException(new Exception()))
+ .Throws(new DetectionOrchestrationDependencyValidationException(new Exception()))
+
+ .Throws(new DetectionOrchestrationDependencyException(new Exception()))
+ .Throws(new DetectionOrchestrationServiceException(new Exception()))
+
+ .Throws(new Exception());
+
+ await ExecuteModerateDetectionById(1, StatusCodes.Status404NotFound);
+ await ExecuteModerateDetectionById(2, StatusCodes.Status422UnprocessableEntity);
+ await ExecuteModerateDetectionById(2, StatusCodes.Status400BadRequest);
+ await ExecuteModerateDetectionById(3, StatusCodes.Status500InternalServerError);
+
+ _orchestrationServiceMock
+ .Verify(service => service
+ .ModerateDetectionByIdAsync(It.IsAny(), It.IsAny()),
+ Times.Exactly(8));
+
+ }
+
+ private async Task ExecuteModerateDetectionById(int count, int statusCode)
+ {
+ for (int x = 0; x < count; x++)
+ {
+ ActionResult actionResult =
+ await _controller.PutModeratedInfoAsync("id", new ModerateDetectionRequest());
+
+ var contentResult = actionResult.Result as ObjectResult;
+ Assert.IsNotNull(contentResult);
+ Assert.AreEqual(statusCode, contentResult.StatusCode);
+ }
+ }
+ }
+}
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/HydrophoneControllerTests/Default.GetHydrophones.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/HydrophoneControllerTests/Default.GetHydrophones.cs
new file mode 100644
index 00000000..e3fa8eb5
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/HydrophoneControllerTests/Default.GetHydrophones.cs
@@ -0,0 +1,39 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ public partial class HydrophonesControllerTests
+ {
+ [TestMethod]
+ public async Task Default_GetHydrophones_Expect_HydrophoneListResponse()
+ {
+ HydrophoneListResponse response = new()
+ {
+ Hydrophones = new List
+ {
+ new()
+ {
+ Name = "Test"
+ }
+ },
+ Count = 1
+ };
+
+ _orchestrationServiceMock.Setup(service =>
+ service.RetrieveHydrophoneLocations())
+ .ReturnsAsync(response);
+
+ ActionResult actionResult =
+ await _controller.GetHydrophones();
+
+ var contentResult = actionResult.Result as ObjectResult;
+ Assert.IsNotNull(contentResult);
+ Assert.AreEqual(200, contentResult.StatusCode);
+
+ Assert.AreEqual(response.Hydrophones.Count,
+ ((HydrophoneListResponse)contentResult.Value!).Hydrophones.Count);
+
+ _orchestrationServiceMock.Verify(service =>
+ service.RetrieveHydrophoneLocations(),
+ Times.Once);
+ }
+ }
+}
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/HydrophoneControllerTests/Setup.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/HydrophoneControllerTests/Setup.cs
new file mode 100644
index 00000000..255d7a02
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/HydrophoneControllerTests/Setup.cs
@@ -0,0 +1,24 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ [TestClass]
+ [ExcludeFromCodeCoverage]
+ public partial class HydrophonesControllerTests
+ {
+ private readonly Mock _orchestrationServiceMock;
+ private readonly HydrophonesController _controller;
+
+ public HydrophonesControllerTests()
+ {
+ _orchestrationServiceMock = new Mock();
+
+ _controller = new HydrophonesController(
+ hydrophoneOrchestrationService: _orchestrationServiceMock.Object);
+ }
+
+ [TestCleanup]
+ public void TestTeardown()
+ {
+ _orchestrationServiceMock.VerifyNoOtherCalls();
+ }
+ }
+}
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/HydrophoneControllerTests/TryCatch.GetHydrophones.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/HydrophoneControllerTests/TryCatch.GetHydrophones.cs
new file mode 100644
index 00000000..4b469d9d
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/HydrophoneControllerTests/TryCatch.GetHydrophones.cs
@@ -0,0 +1,46 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ public partial class HydrophonesControllerTests
+ {
+
+ [TestMethod]
+ public async Task TryCatch_GetHydrophones_Expect_Exception()
+ {
+ _orchestrationServiceMock
+ .SetupSequence(p => p.RetrieveHydrophoneLocations())
+
+ .Throws(new HydrophoneOrchestrationValidationException(new InvalidHydrophoneException()))
+
+ .Throws(new HydrophoneOrchestrationValidationException(new Exception()))
+ .Throws(new HydrophoneOrchestrationDependencyValidationException(new Exception()))
+
+ .Throws(new HydrophoneOrchestrationDependencyException(new Exception()))
+ .Throws(new HydrophoneOrchestrationServiceException(new Exception()))
+
+ .Throws(new Exception());
+
+ await ExecuteRetrieveHydrophones(1, StatusCodes.Status404NotFound);
+ await ExecuteRetrieveHydrophones(2, StatusCodes.Status400BadRequest);
+ await ExecuteRetrieveHydrophones(3, StatusCodes.Status500InternalServerError);
+
+ _orchestrationServiceMock
+ .Verify(service => service
+ .RetrieveHydrophoneLocations(),
+ Times.Exactly(6));
+
+ }
+
+ private async Task ExecuteRetrieveHydrophones(int count, int statusCode)
+ {
+ for (int x = 0; x < count; x++)
+ {
+ ActionResult actionResult =
+ await _controller.GetHydrophones();
+
+ var contentResult = actionResult.Result as ObjectResult;
+ Assert.IsNotNull(contentResult);
+ Assert.AreEqual(statusCode, contentResult.StatusCode);
+ }
+ }
+ }
+}
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/InterestLabelsControllerTests/Default.AddInterestLabelToDetectionAsync.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/InterestLabelsControllerTests/Default.AddInterestLabelToDetectionAsync.cs
new file mode 100644
index 00000000..a4709084
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/InterestLabelsControllerTests/Default.AddInterestLabelToDetectionAsync.cs
@@ -0,0 +1,29 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ public partial class InterestLabelsControllerTests
+ {
+ [TestMethod]
+ public async Task Default_AddInterestLabelToDetectionAsync_Expect_Detection()
+ {
+ InterestLabelAddResponse expectedResult = new();
+
+ _orchestrationServiceMock.Setup(service =>
+ service.AddInterestLabelToDetectionAsync(It.IsAny(), It.IsAny()))
+ .ReturnsAsync(expectedResult);
+
+ ActionResult actionResult =
+ await _controller.AddInterestLabelToDetectionAsync("id", "label");
+
+
+ var contentResult = actionResult.Result as ObjectResult;
+ Assert.IsNotNull(contentResult);
+ Assert.AreEqual(200, contentResult.StatusCode);
+
+ Assert.IsNotNull((InterestLabelAddResponse)contentResult.Value);
+
+ _orchestrationServiceMock.Verify(service =>
+ service.AddInterestLabelToDetectionAsync(It.IsAny(), It.IsAny()),
+ Times.Once);
+ }
+ }
+}
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/InterestLabelsControllerTests/Default.GetAllInterestLabelsAsync.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/InterestLabelsControllerTests/Default.GetAllInterestLabelsAsync.cs
new file mode 100644
index 00000000..e827b6dd
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/InterestLabelsControllerTests/Default.GetAllInterestLabelsAsync.cs
@@ -0,0 +1,35 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ public partial class InterestLabelsControllerTests
+ {
+ [TestMethod]
+ public async Task Default_GetAllInterestLabelsAsync_Expect_TagRemovalResponse()
+ {
+ InterestLabelListResponse response = new()
+ {
+ InterestLabels = new List() { "Label1", "Label2" },
+ Count = 2
+ };
+
+ _orchestrationServiceMock.Setup(service =>
+ service.RetrieveAllInterestLabelsAsync())
+ .ReturnsAsync(response);
+
+ ActionResult actionResult =
+ await _controller.GetAllInterestLabelsAsync();
+
+ var contentResult = actionResult.Result as ObjectResult;
+ Assert.IsNotNull(contentResult);
+ Assert.AreEqual(200, contentResult.StatusCode);
+
+ var result = (InterestLabelListResponse)contentResult.Value;
+
+ Assert.IsNotNull(result);
+ Assert.AreEqual(2, result.Count);
+
+ _orchestrationServiceMock.Verify(service =>
+ service.RetrieveAllInterestLabelsAsync(),
+ Times.Once);
+ }
+ }
+}
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/InterestLabelsControllerTests/Default.RemoveInterestLabelFromDetectionAsync.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/InterestLabelsControllerTests/Default.RemoveInterestLabelFromDetectionAsync.cs
new file mode 100644
index 00000000..e16006d6
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/InterestLabelsControllerTests/Default.RemoveInterestLabelFromDetectionAsync.cs
@@ -0,0 +1,37 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ public partial class InterestLabelsControllerTests
+ {
+ [TestMethod]
+ public async Task Default_RemoveInterestLabelFromDetectionAsync_Expect_TagRemovalResponse()
+ {
+ var labelToRemove = "labelToRemove";
+
+ InterestLabelRemovalResponse response = new()
+ {
+ Id = "id",
+ LabelRemoved = labelToRemove
+ };
+
+ _orchestrationServiceMock.Setup(service =>
+ service.RemoveInterestLabelFromDetectionAsync(It.IsAny()))
+ .ReturnsAsync(response);
+
+ ActionResult actionResult =
+ await _controller.RemoveInterestLabelFromDetectionAsync("id");
+
+ var contentResult = actionResult.Result as ObjectResult;
+ Assert.IsNotNull(contentResult);
+ Assert.AreEqual(200, contentResult.StatusCode);
+
+ var result = (InterestLabelRemovalResponse)contentResult.Value;
+
+ Assert.IsNotNull(result);
+ Assert.AreEqual(labelToRemove, result.LabelRemoved);
+
+ _orchestrationServiceMock.Verify(service =>
+ service.RemoveInterestLabelFromDetectionAsync(It.IsAny()),
+ Times.Once);
+ }
+ }
+}
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/InterestLabelsControllerTests/Setup.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/InterestLabelsControllerTests/Setup.cs
new file mode 100644
index 00000000..c6fafed7
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/InterestLabelsControllerTests/Setup.cs
@@ -0,0 +1,24 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ [TestClass]
+ [ExcludeFromCodeCoverage]
+ public partial class InterestLabelsControllerTests
+ {
+ private readonly Mock _orchestrationServiceMock;
+ private readonly InterestLabelsController _controller;
+
+ public InterestLabelsControllerTests()
+ {
+ _orchestrationServiceMock = new Mock();
+
+ _controller = new InterestLabelsController(
+ interestLabelOrchestrationService: _orchestrationServiceMock.Object);
+ }
+
+ [TestCleanup]
+ public void TestTeardown()
+ {
+ _orchestrationServiceMock.VerifyNoOtherCalls();
+ }
+ }
+}
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/InterestLabelsControllerTests/TryCatch.AddInterestLabelToDetectionAsync.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/InterestLabelsControllerTests/TryCatch.AddInterestLabelToDetectionAsync.cs
new file mode 100644
index 00000000..9fa6bacd
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/InterestLabelsControllerTests/TryCatch.AddInterestLabelToDetectionAsync.cs
@@ -0,0 +1,47 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ public partial class InterestLabelsControllerTests
+ {
+ [TestMethod]
+ public async Task TryCatch_AddInterestLabelToDetectionAsync_Expect_Exception()
+ {
+ _orchestrationServiceMock
+ .SetupSequence(p => p.AddInterestLabelToDetectionAsync(It.IsAny(), It.IsAny()))
+
+ .Throws(new InterestLabelOrchestrationValidationException(new NotFoundMetadataException("id")))
+
+ .Throws(new InterestLabelOrchestrationValidationException(new Exception()))
+ .Throws(new InterestLabelOrchestrationDependencyValidationException(new Exception()))
+
+ .Throws(new InterestLabelOrchestrationDependencyException(new Exception()))
+ .Throws(new InterestLabelOrchestrationServiceException(new Exception()))
+
+ .Throws(new Exception());
+
+
+ await ExecuteAddLabel(1, StatusCodes.Status404NotFound);
+ await ExecuteAddLabel(2, StatusCodes.Status400BadRequest);
+ await ExecuteAddLabel(3, StatusCodes.Status500InternalServerError);
+
+ _orchestrationServiceMock
+ .Verify(service => service
+ .AddInterestLabelToDetectionAsync(It.IsAny(), It.IsAny()),
+ Times.Exactly(6));
+
+ }
+
+ private async Task ExecuteAddLabel(int count, int statusCode)
+ {
+ for (int x = 0; x < count; x++)
+ {
+ ActionResult actionResult =
+ await _controller.AddInterestLabelToDetectionAsync("id", "label");
+
+ var contentResult = actionResult.Result as ObjectResult;
+ Assert.IsNotNull(contentResult);
+ Assert.AreEqual(statusCode, contentResult.StatusCode);
+ }
+ }
+
+ }
+}
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/InterestLabelsControllerTests/TryCatch.GetAllInterestLabelsAsync.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/InterestLabelsControllerTests/TryCatch.GetAllInterestLabelsAsync.cs
new file mode 100644
index 00000000..b9728f78
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/InterestLabelsControllerTests/TryCatch.GetAllInterestLabelsAsync.cs
@@ -0,0 +1,42 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ public partial class InterestLabelsControllerTests
+ {
+ [TestMethod]
+ public async Task TryCatch_GetAllInterestLabelsAsync_Expect_Exception()
+ {
+ _orchestrationServiceMock
+ .SetupSequence(p => p.RetrieveAllInterestLabelsAsync())
+
+ .Throws(new InterestLabelOrchestrationValidationException(new Exception()))
+ .Throws(new InterestLabelOrchestrationDependencyValidationException(new Exception()))
+
+ .Throws(new InterestLabelOrchestrationDependencyException(new Exception()))
+ .Throws(new InterestLabelOrchestrationServiceException(new Exception()))
+
+ .Throws(new Exception());
+
+ await ExecuteRetrieveAllLabels(2, StatusCodes.Status400BadRequest);
+ await ExecuteRetrieveAllLabels(3, StatusCodes.Status500InternalServerError);
+
+ _orchestrationServiceMock
+ .Verify(service => service
+ .RetrieveAllInterestLabelsAsync(),
+ Times.Exactly(5));
+
+ }
+
+ private async Task ExecuteRetrieveAllLabels(int count, int statusCode)
+ {
+ for (int x = 0; x < count; x++)
+ {
+ ActionResult actionResult =
+ await _controller.GetAllInterestLabelsAsync();
+
+ var contentResult = actionResult.Result as ObjectResult;
+ Assert.IsNotNull(contentResult);
+ Assert.AreEqual(statusCode, contentResult.StatusCode);
+ }
+ }
+ }
+}
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/InterestLabelsControllerTests/TryCatch.RemoveInterestLabelFromDetectionAsync.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/InterestLabelsControllerTests/TryCatch.RemoveInterestLabelFromDetectionAsync.cs
new file mode 100644
index 00000000..92fe1e59
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/InterestLabelsControllerTests/TryCatch.RemoveInterestLabelFromDetectionAsync.cs
@@ -0,0 +1,48 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ public partial class InterestLabelsControllerTests
+ {
+ [TestMethod]
+ public async Task TryCatch_RemoveInterestLabelFromDetectionAsync_Expect_Exception()
+ {
+ _orchestrationServiceMock
+ .SetupSequence(p => p.RemoveInterestLabelFromDetectionAsync(It.IsAny()))
+
+ .Throws(new InterestLabelOrchestrationValidationException(new NotFoundMetadataException("id")))
+
+ .Throws(new InterestLabelOrchestrationValidationException(new DetectionNotDeletedException("id")))
+ .Throws(new InterestLabelOrchestrationValidationException(new DetectionNotInsertedException("id")))
+
+ .Throws(new InterestLabelOrchestrationValidationException(new Exception()))
+ .Throws(new InterestLabelOrchestrationDependencyValidationException(new Exception()))
+
+ .Throws(new InterestLabelOrchestrationDependencyException(new Exception()))
+ .Throws(new InterestLabelOrchestrationServiceException(new Exception()))
+ .Throws(new Exception());
+
+ await ExecuteRemoveLabel(1, StatusCodes.Status404NotFound);
+ await ExecuteRemoveLabel(2, StatusCodes.Status422UnprocessableEntity);
+ await ExecuteRemoveLabel(2, StatusCodes.Status400BadRequest);
+ await ExecuteRemoveLabel(3, StatusCodes.Status500InternalServerError);
+
+ _orchestrationServiceMock
+ .Verify(service => service
+ .RemoveInterestLabelFromDetectionAsync(It.IsAny()),
+ Times.Exactly(8));
+
+ }
+
+ private async Task ExecuteRemoveLabel(int count, int statusCode)
+ {
+ for (int x = 0; x < count; x++)
+ {
+ ActionResult actionResult =
+ await _controller.RemoveInterestLabelFromDetectionAsync("id");
+
+ var contentResult = actionResult.Result as ObjectResult;
+ Assert.IsNotNull(contentResult);
+ Assert.AreEqual(statusCode, contentResult.StatusCode);
+ }
+ }
+ }
+}
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/MetricsControllerTests/Default.GetMetricsAsync.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/MetricsControllerTests/Default.GetMetricsAsync.cs
new file mode 100644
index 00000000..4844fedd
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/MetricsControllerTests/Default.GetMetricsAsync.cs
@@ -0,0 +1,37 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ public partial class MetricsControllerTests
+ {
+ [TestMethod]
+ public async Task Default_GetMetricsAsync_Expect_DetectionListResponse()
+ {
+ MetricsResponse response = new MetricsResponse
+ {
+ FromDate = DateTime.Now,
+ ToDate = DateTime.Now.AddDays(1),
+ Positive = 1,
+ Negative = 3,
+ Unknown = 5,
+ Unreviewed = 10
+ };
+
+ _orchestrationServiceMock.Setup(service =>
+ service.RetrieveMetricsForGivenTimeframeAsync(It.IsAny(), It.IsAny()))
+ .ReturnsAsync(response);
+
+ ActionResult actionResult =
+ await _controller.GetMetricsAsync(DateTime.Now, DateTime.Now.AddDays(1));
+
+ var contentResult = actionResult.Result as ObjectResult;
+ Assert.IsNotNull(contentResult);
+ Assert.AreEqual(200, contentResult.StatusCode);
+
+ Assert.AreEqual(response.Positive,
+ ((MetricsResponse)contentResult.Value).Positive);
+
+ _orchestrationServiceMock.Verify(service =>
+ service.RetrieveMetricsForGivenTimeframeAsync(It.IsAny(), It.IsAny()),
+ Times.Once);
+ }
+ }
+}
\ No newline at end of file
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/MetricsControllerTests/Setup.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/MetricsControllerTests/Setup.cs
new file mode 100644
index 00000000..ed2215ca
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/MetricsControllerTests/Setup.cs
@@ -0,0 +1,24 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ [TestClass]
+ [ExcludeFromCodeCoverage]
+ public partial class MetricsControllerTests
+ {
+ private readonly Mock _orchestrationServiceMock;
+ private readonly MetricsController _controller;
+
+ public MetricsControllerTests()
+ {
+ _orchestrationServiceMock = new Mock();
+
+ _controller = new MetricsController(
+ metricsOrchestrationService: _orchestrationServiceMock.Object);
+ }
+
+ [TestCleanup]
+ public void TestTeardown()
+ {
+ _orchestrationServiceMock.VerifyNoOtherCalls();
+ }
+ }
+}
\ No newline at end of file
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/MetricsControllerTests/TryCatch.GetMetricsAsync.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/MetricsControllerTests/TryCatch.GetMetricsAsync.cs
new file mode 100644
index 00000000..cade9a14
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/MetricsControllerTests/TryCatch.GetMetricsAsync.cs
@@ -0,0 +1,42 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ public partial class MetricsControllerTests
+ {
+ [TestMethod]
+ public async Task TryCatch_GetMetricsAsync_Expect_Exception()
+ {
+ _orchestrationServiceMock
+ .SetupSequence(p => p.RetrieveMetricsForGivenTimeframeAsync(It.IsAny(), It.IsAny()))
+
+ .Throws(new MetricOrchestrationValidationException(new Exception()))
+ .Throws(new MetricOrchestrationDependencyValidationException(new Exception()))
+
+ .Throws(new MetricOrchestrationDependencyException(new Exception()))
+ .Throws(new MetricOrchestrationServiceException(new Exception()))
+
+ .Throws(new Exception());
+
+ await ExecuteRetrieveMetrics(2, StatusCodes.Status400BadRequest);
+ await ExecuteRetrieveMetrics(3, StatusCodes.Status500InternalServerError);
+
+ _orchestrationServiceMock
+ .Verify(service => service
+ .RetrieveMetricsForGivenTimeframeAsync(It.IsAny(), It.IsAny()),
+ Times.Exactly(5));
+
+ }
+
+ private async Task ExecuteRetrieveMetrics(int count, int statusCode)
+ {
+ for (int x = 0; x < count; x++)
+ {
+ ActionResult actionResult =
+ await _controller.GetMetricsAsync(DateTime.Now, DateTime.Now.AddDays(1));
+
+ var contentResult = actionResult.Result as ObjectResult;
+ Assert.IsNotNull(contentResult);
+ Assert.AreEqual(statusCode, contentResult.StatusCode);
+ }
+ }
+ }
+}
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/ModeratorsControllerTests/Default.GetMetricsForGivenTimeframeAndModeratorAsync.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/ModeratorsControllerTests/Default.GetMetricsForGivenTimeframeAndModeratorAsync.cs
new file mode 100644
index 00000000..de4087d6
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/ModeratorsControllerTests/Default.GetMetricsForGivenTimeframeAndModeratorAsync.cs
@@ -0,0 +1,37 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ public partial class ModeratorsControllerTests
+ {
+ [TestMethod]
+ public async Task Default_GetMetricsAsync_Expect_MetricsForModeratorResponse()
+ {
+ MetricsForModeratorResponse response = new MetricsForModeratorResponse
+ {
+ FromDate = DateTime.Now,
+ ToDate = DateTime.Now.AddDays(1),
+ Positive = 1,
+ Negative = 3,
+ Unknown = 5,
+ Moderator = "Moderator"
+ };
+
+ _orchestrationServiceMock.Setup(service =>
+ service.RetrieveMetricsForGivenTimeframeAndModeratorAsync(It.IsAny(), It.IsAny(), It.IsAny()))
+ .ReturnsAsync(response);
+
+ ActionResult actionResult =
+ await _controller.GetMetricsForGivenTimeframeAndModeratorAsync("Moderator", DateTime.Now, DateTime.Now.AddDays(1));
+
+ var contentResult = actionResult.Result as ObjectResult;
+ Assert.IsNotNull(contentResult);
+ Assert.AreEqual(200, contentResult.StatusCode);
+
+ Assert.AreEqual(response.Positive,
+ ((MetricsForModeratorResponse)contentResult.Value).Positive);
+
+ _orchestrationServiceMock.Verify(service =>
+ service.RetrieveMetricsForGivenTimeframeAndModeratorAsync(It.IsAny(), It.IsAny(), It.IsAny()),
+ Times.Once);
+ }
+ }
+}
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/ModeratorsControllerTests/Default.GetModeratorsAsync.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/ModeratorsControllerTests/Default.GetModeratorsAsync.cs
new file mode 100644
index 00000000..97503442
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/ModeratorsControllerTests/Default.GetModeratorsAsync.cs
@@ -0,0 +1,33 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ public partial class ModeratorsControllerTests
+ {
+ [TestMethod]
+ public async Task Default_GetModeratorsAsync_Expect_DetectionListResponse()
+ {
+ ModeratorListResponse response = new ModeratorListResponse
+ {
+ Moderators = new List { "Moderator 1", "Moderator 2" },
+ Count = 2
+ };
+
+ _orchestrationServiceMock.Setup(service =>
+ service.RetrieveModeratorsAsync())
+ .ReturnsAsync(response);
+
+ ActionResult actionResult =
+ await _controller.GetModeratorsAsync();
+
+ var contentResult = actionResult.Result as ObjectResult;
+ Assert.IsNotNull(contentResult);
+ Assert.AreEqual(200, contentResult.StatusCode);
+
+ Assert.AreEqual(response.Moderators.Count(),
+ ((ModeratorListResponse)contentResult.Value).Moderators.Count());
+
+ _orchestrationServiceMock.Verify(service =>
+ service.RetrieveModeratorsAsync(),
+ Times.Once);
+ }
+ }
+}
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/ModeratorsControllerTests/Default.GetPaginatedNegativeAndUnknownCommentsForGivenTimeframeAndModeratorAsync.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/ModeratorsControllerTests/Default.GetPaginatedNegativeAndUnknownCommentsForGivenTimeframeAndModeratorAsync.cs
new file mode 100644
index 00000000..d0c94043
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/ModeratorsControllerTests/Default.GetPaginatedNegativeAndUnknownCommentsForGivenTimeframeAndModeratorAsync.cs
@@ -0,0 +1,36 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ public partial class ModeratorsControllerTests
+ {
+ [TestMethod]
+ public async Task Default_GetGetPaginatedNegativeAndUnknownCommentsForGivenTimeframeAndModeratorAsync_Expect_DetectionListResponse()
+ {
+ CommentListForModeratorResponse response = new CommentListForModeratorResponse
+ {
+ Count = 2,
+ FromDate = DateTime.Now,
+ ToDate = DateTime.Now.AddDays(1),
+ Comments = new List { new Comment() },
+ Moderator = "Moderator"
+ };
+
+ _orchestrationServiceMock.Setup(service =>
+ service.RetrieveNegativeAndUnknownCommentsForGivenTimeframeAndModeratorAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()))
+ .ReturnsAsync(response);
+
+ ActionResult actionResult =
+ await _controller.GetPaginatedNegativeAndUnknownCommentsForGivenTimeframeAndModeratorAsync("Moderator", DateTime.Now, DateTime.Now.AddDays(1), 1, 10);
+
+ var contentResult = actionResult.Result as ObjectResult;
+ Assert.IsNotNull(contentResult);
+ Assert.AreEqual(200, contentResult.StatusCode);
+
+ Assert.AreEqual(response.Comments.Count(),
+ ((CommentListForModeratorResponse)contentResult.Value).Comments.Count());
+
+ _orchestrationServiceMock.Verify(service =>
+ service.RetrieveNegativeAndUnknownCommentsForGivenTimeframeAndModeratorAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()),
+ Times.Once);
+ }
+ }
+}
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/ModeratorsControllerTests/Default.GetPaginatedPositiveCommentsForGivenTimeframeAndModeratorAsync.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/ModeratorsControllerTests/Default.GetPaginatedPositiveCommentsForGivenTimeframeAndModeratorAsync.cs
new file mode 100644
index 00000000..81ace854
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/ModeratorsControllerTests/Default.GetPaginatedPositiveCommentsForGivenTimeframeAndModeratorAsync.cs
@@ -0,0 +1,36 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ public partial class ModeratorsControllerTests
+ {
+ [TestMethod]
+ public async Task Default_GetGetPaginatedPositiveCommentsForGivenTimeframeAndModeratorAsync_Expect_DetectionListResponse()
+ {
+ CommentListForModeratorResponse response = new CommentListForModeratorResponse
+ {
+ Count = 2,
+ FromDate = DateTime.Now,
+ ToDate = DateTime.Now.AddDays(1),
+ Comments = new List { new Comment() },
+ Moderator = "Moderator"
+ };
+
+ _orchestrationServiceMock.Setup(service =>
+ service.RetrievePositiveCommentsForGivenTimeframeAndModeratorAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()))
+ .ReturnsAsync(response);
+
+ ActionResult actionResult =
+ await _controller.GetPaginatedPositiveCommentsForGivenTimeframeAndModeratorAsync("Moderator", DateTime.Now, DateTime.Now.AddDays(1), 1, 10);
+
+ var contentResult = actionResult.Result as ObjectResult;
+ Assert.IsNotNull(contentResult);
+ Assert.AreEqual(200, contentResult.StatusCode);
+
+ Assert.AreEqual(response.Comments.Count(),
+ ((CommentListForModeratorResponse)contentResult.Value).Comments.Count());
+
+ _orchestrationServiceMock.Verify(service =>
+ service.RetrievePositiveCommentsForGivenTimeframeAndModeratorAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()),
+ Times.Once);
+ }
+ }
+}
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/ModeratorsControllerTests/Default.GetTagsForGivenTimeframeAndModeratorAsync.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/ModeratorsControllerTests/Default.GetTagsForGivenTimeframeAndModeratorAsync.cs
new file mode 100644
index 00000000..6a655116
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/ModeratorsControllerTests/Default.GetTagsForGivenTimeframeAndModeratorAsync.cs
@@ -0,0 +1,36 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ public partial class ModeratorsControllerTests
+ {
+ [TestMethod]
+ public async Task Default_GetTagsForGivenTimePeriodAndModerator_Expect_TagListResponse()
+ {
+ TagListForModeratorResponse response = new TagListForModeratorResponse
+ {
+ Count = 2,
+ FromDate = DateTime.Now,
+ ToDate = DateTime.Now.AddDays(1),
+ Tags = new List { "Tag1", "Tag2" },
+ Moderator = "Moderator"
+ };
+
+ _orchestrationServiceMock.Setup(service =>
+ service.RetrieveTagsForGivenTimePeriodAndModeratorAsync(It.IsAny(), It.IsAny(), It.IsAny()))
+ .ReturnsAsync(response);
+
+ ActionResult actionResult =
+ await _controller.GetTagsForGivenTimeframeAndModeratorAsync("Moderator", DateTime.Now, DateTime.Now.AddDays(1));
+
+ var contentResult = actionResult.Result as ObjectResult;
+ Assert.IsNotNull(contentResult);
+ Assert.AreEqual(200, contentResult.StatusCode);
+
+ Assert.AreEqual(response.Tags.Count(),
+ ((TagListResponse)contentResult.Value).Tags.Count());
+
+ _orchestrationServiceMock.Verify(service =>
+ service.RetrieveTagsForGivenTimePeriodAndModeratorAsync(It.IsAny(), It.IsAny(), It.IsAny()),
+ Times.Once);
+ }
+ }
+}
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/ModeratorsControllerTests/Setup.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/ModeratorsControllerTests/Setup.cs
new file mode 100644
index 00000000..132e6064
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/ModeratorsControllerTests/Setup.cs
@@ -0,0 +1,24 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ [TestClass]
+ [ExcludeFromCodeCoverage]
+ public partial class ModeratorsControllerTests
+ {
+ private readonly Mock _orchestrationServiceMock;
+ private readonly ModeratorsController _controller;
+
+ public ModeratorsControllerTests()
+ {
+ _orchestrationServiceMock = new Mock();
+
+ _controller = new ModeratorsController(
+ moderatorOrchestrationService: _orchestrationServiceMock.Object);
+ }
+
+ [TestCleanup]
+ public void TestTeardown()
+ {
+ _orchestrationServiceMock.VerifyNoOtherCalls();
+ }
+ }
+}
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/ModeratorsControllerTests/TryCatch.GetMetricsForGivenTimeframeAndModeratorAsync.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/ModeratorsControllerTests/TryCatch.GetMetricsForGivenTimeframeAndModeratorAsync.cs
new file mode 100644
index 00000000..0f199e93
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/ModeratorsControllerTests/TryCatch.GetMetricsForGivenTimeframeAndModeratorAsync.cs
@@ -0,0 +1,43 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ public partial class ModeratorsControllerTests
+ {
+ [TestMethod]
+ public async Task TryCatch_GetMetricsForGivenTimeframeAndModeratorAsync_Expect_Exception()
+ {
+ _orchestrationServiceMock
+ .SetupSequence(p => p.RetrieveMetricsForGivenTimeframeAndModeratorAsync(It.IsAny(), It.IsAny(), It.IsAny()))
+
+ .Throws(new ModeratorOrchestrationValidationException(new Exception()))
+ .Throws(new ModeratorOrchestrationDependencyValidationException(new Exception()))
+
+ .Throws(new ModeratorOrchestrationDependencyException(new Exception()))
+ .Throws(new ModeratorOrchestrationServiceException(new Exception()))
+
+ .Throws(new Exception());
+
+ await ExecuteRetrieveMetrics(2, StatusCodes.Status400BadRequest);
+ await ExecuteRetrieveMetrics(3, StatusCodes.Status500InternalServerError);
+
+ _orchestrationServiceMock
+ .Verify(service => service
+ .RetrieveMetricsForGivenTimeframeAndModeratorAsync(It.IsAny(), It.IsAny(), It.IsAny()),
+ Times.Exactly(5));
+
+ }
+
+ private async Task ExecuteRetrieveMetrics(int count, int statusCode)
+ {
+ for (int x = 0; x < count; x++)
+ {
+ ActionResult actionResult =
+ await _controller.GetMetricsForGivenTimeframeAndModeratorAsync("Moderator", DateTime.Now, DateTime.Now.AddDays(1));
+
+ var contentResult = actionResult.Result as ObjectResult;
+ Assert.IsNotNull(contentResult);
+ Assert.AreEqual(statusCode, contentResult.StatusCode);
+ }
+ }
+
+ }
+}
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/ModeratorsControllerTests/TryCatch.GetModeratorsAsync.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/ModeratorsControllerTests/TryCatch.GetModeratorsAsync.cs
new file mode 100644
index 00000000..c7f3b0c5
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/ModeratorsControllerTests/TryCatch.GetModeratorsAsync.cs
@@ -0,0 +1,43 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ public partial class ModeratorsControllerTests
+ {
+ [TestMethod]
+ public async Task TryCatch_GetModeratorsAsync_Expect_Exception()
+ {
+ _orchestrationServiceMock
+ .SetupSequence(p => p.RetrieveModeratorsAsync())
+
+ .Throws(new ModeratorOrchestrationValidationException(new Exception()))
+ .Throws(new ModeratorOrchestrationDependencyValidationException(new Exception()))
+
+ .Throws(new ModeratorOrchestrationDependencyException(new Exception()))
+ .Throws(new ModeratorOrchestrationServiceException(new Exception()))
+
+ .Throws(new Exception());
+
+ await ExecuteRetrieveModerators(2, StatusCodes.Status400BadRequest);
+ await ExecuteRetrieveModerators(3, StatusCodes.Status500InternalServerError);
+
+ _orchestrationServiceMock
+ .Verify(service => service
+ .RetrieveModeratorsAsync(),
+ Times.Exactly(5));
+
+ }
+
+ private async Task ExecuteRetrieveModerators(int count, int statusCode)
+ {
+ for (int x = 0; x < count; x++)
+ {
+ ActionResult actionResult =
+ await _controller.GetModeratorsAsync();
+
+ var contentResult = actionResult.Result as ObjectResult;
+ Assert.IsNotNull(contentResult);
+ Assert.AreEqual(statusCode, contentResult.StatusCode);
+ }
+ }
+
+ }
+}
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/ModeratorsControllerTests/TryCatch.GetPaginatedNegativeAndUnknownCommentsForGivenTimeframeAndModeratorAsync.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/ModeratorsControllerTests/TryCatch.GetPaginatedNegativeAndUnknownCommentsForGivenTimeframeAndModeratorAsync.cs
new file mode 100644
index 00000000..e2d1e507
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/ModeratorsControllerTests/TryCatch.GetPaginatedNegativeAndUnknownCommentsForGivenTimeframeAndModeratorAsync.cs
@@ -0,0 +1,79 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ public partial class ModeratorsControllerTests
+ {
+ [TestMethod]
+ public async Task TryCatch_CommentListForModeratorResponse_Positive_Expect_Exception()
+ {
+ _orchestrationServiceMock
+ .SetupSequence(p => p.RetrievePositiveCommentsForGivenTimeframeAndModeratorAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()))
+
+ .Throws(new ModeratorOrchestrationValidationException(new Exception()))
+ .Throws(new ModeratorOrchestrationDependencyValidationException(new Exception()))
+
+ .Throws(new ModeratorOrchestrationDependencyException(new Exception()))
+ .Throws(new ModeratorOrchestrationServiceException(new Exception()))
+
+ .Throws(new Exception());
+
+ await ExecuteRetrievePositiveComments(2, StatusCodes.Status400BadRequest);
+ await ExecuteRetrievePositiveComments(3, StatusCodes.Status500InternalServerError);
+
+ _orchestrationServiceMock
+ .Verify(service => service
+ .RetrievePositiveCommentsForGivenTimeframeAndModeratorAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()),
+ Times.Exactly(5));
+
+ }
+
+ private async Task ExecuteRetrievePositiveComments(int count, int statusCode)
+ {
+ for (int x = 0; x < count; x++)
+ {
+ ActionResult actionResult =
+ await _controller.GetPaginatedPositiveCommentsForGivenTimeframeAndModeratorAsync("Moderator", DateTime.Now, DateTime.Now.AddDays(1), 1, 10);
+
+ var contentResult = actionResult.Result as ObjectResult;
+ Assert.IsNotNull(contentResult);
+ Assert.AreEqual(statusCode, contentResult.StatusCode);
+ }
+ }
+
+ [TestMethod]
+ public async Task TryCatch_GetPaginatedNegativeAndUnknownCommentsForGivenTimeframeAndModeratorAsync_Expect_Exception()
+ {
+ _orchestrationServiceMock
+ .SetupSequence(p => p.RetrieveNegativeAndUnknownCommentsForGivenTimeframeAndModeratorAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()))
+
+ .Throws(new ModeratorOrchestrationValidationException(new Exception()))
+ .Throws(new ModeratorOrchestrationDependencyValidationException(new Exception()))
+
+ .Throws(new ModeratorOrchestrationDependencyException(new Exception()))
+ .Throws(new ModeratorOrchestrationServiceException(new Exception()))
+
+ .Throws(new Exception());
+
+ await ExecuteRetrieveNegativeAndUnknownComments(2, StatusCodes.Status400BadRequest);
+ await ExecuteRetrieveNegativeAndUnknownComments(3, StatusCodes.Status500InternalServerError);
+
+ _orchestrationServiceMock
+ .Verify(service => service
+ .RetrieveNegativeAndUnknownCommentsForGivenTimeframeAndModeratorAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()),
+ Times.Exactly(5));
+
+ }
+
+ private async Task ExecuteRetrieveNegativeAndUnknownComments(int count, int statusCode)
+ {
+ for (int x = 0; x < count; x++)
+ {
+ ActionResult actionResult =
+ await _controller.GetPaginatedNegativeAndUnknownCommentsForGivenTimeframeAndModeratorAsync("Moderator", DateTime.Now, DateTime.Now.AddDays(1), 1, 10);
+
+ var contentResult = actionResult.Result as ObjectResult;
+ Assert.IsNotNull(contentResult);
+ Assert.AreEqual(statusCode, contentResult.StatusCode);
+ }
+ }
+ }
+}
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/ModeratorsControllerTests/TryCatch.GetPaginatedPositiveCommentsForGivenTimeframeAndModeratorAsync.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/ModeratorsControllerTests/TryCatch.GetPaginatedPositiveCommentsForGivenTimeframeAndModeratorAsync.cs
new file mode 100644
index 00000000..ce202440
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/ModeratorsControllerTests/TryCatch.GetPaginatedPositiveCommentsForGivenTimeframeAndModeratorAsync.cs
@@ -0,0 +1,42 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ public partial class ModeratorsControllerTests
+ {
+ [TestMethod]
+ public async Task TryCatch_GetPaginatedPositiveCommentsForGivenTimeframeAndModeratorAsync_Expect_Exception()
+ {
+ _orchestrationServiceMock
+ .SetupSequence(p => p.RetrievePositiveCommentsForGivenTimeframeAndModeratorAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()))
+
+ .Throws(new ModeratorOrchestrationValidationException(new Exception()))
+ .Throws(new ModeratorOrchestrationDependencyValidationException(new Exception()))
+
+ .Throws(new ModeratorOrchestrationDependencyException(new Exception()))
+ .Throws(new ModeratorOrchestrationServiceException(new Exception()))
+
+ .Throws(new Exception());
+
+ await ExecuteRetrievePositiveCommentForModerator(2, StatusCodes.Status400BadRequest);
+ await ExecuteRetrievePositiveCommentForModerator(3, StatusCodes.Status500InternalServerError);
+
+ _orchestrationServiceMock
+ .Verify(service => service
+ .RetrievePositiveCommentsForGivenTimeframeAndModeratorAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()),
+ Times.Exactly(5));
+
+ }
+
+ private async Task ExecuteRetrievePositiveCommentForModerator(int count, int statusCode)
+ {
+ for (int x = 0; x < count; x++)
+ {
+ ActionResult actionResult =
+ await _controller.GetPaginatedPositiveCommentsForGivenTimeframeAndModeratorAsync("Moderator", DateTime.Now, DateTime.Now.AddDays(1), 1, 10);
+
+ var contentResult = actionResult.Result as ObjectResult;
+ Assert.IsNotNull(contentResult);
+ Assert.AreEqual(statusCode, contentResult.StatusCode);
+ }
+ }
+ }
+}
diff --git a/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/ModeratorsControllerTests/TryCatch.GetTagsForGivenTimeframeAndModeratorAsync.cs b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/ModeratorsControllerTests/TryCatch.GetTagsForGivenTimeframeAndModeratorAsync.cs
new file mode 100644
index 00000000..bdcbf033
--- /dev/null
+++ b/ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/ModeratorsControllerTests/TryCatch.GetTagsForGivenTimeframeAndModeratorAsync.cs
@@ -0,0 +1,42 @@
+namespace OrcaHello.Web.Api.Tests.Unit.Controllers
+{
+ public partial class ModeratorsControllerTests
+ {
+ [TestMethod]
+ public async Task TryCatch_GetTagsForGivenTimeframeAndModeratorAsync_Expect_Exception()
+ {
+ _orchestrationServiceMock
+ .SetupSequence(p => p.RetrieveTagsForGivenTimePeriodAndModeratorAsync(It.IsAny(), It.IsAny(), It.IsAny()))
+
+ .Throws(new ModeratorOrchestrationValidationException(new Exception()))
+ .Throws(new ModeratorOrchestrationDependencyValidationException(new Exception()))
+
+ .Throws(new ModeratorOrchestrationDependencyException(new Exception()))
+ .Throws(new ModeratorOrchestrationServiceException(new Exception()))
+
+ .Throws(new Exception());
+
+ await ExecuteRetrieveTags(2, StatusCodes.Status400BadRequest);
+ await ExecuteRetrieveTags(3, StatusCodes.Status500InternalServerError);
+
+ _orchestrationServiceMock
+ .Verify(service => service
+ .RetrieveTagsForGivenTimePeriodAndModeratorAsync(It.IsAny(), It.IsAny(), It.IsAny()),
+ Times.Exactly(5));
+
+ }
+
+ private async Task ExecuteRetrieveTags(int count, int statusCode)
+ {
+ for (int x = 0; x < count; x++)
+ {
+ ActionResult