-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* V2 Moderator Front End. This check in is the new API. * Added new schema document * Hydrophones now come from the external service and not appsettings.json --------- Co-authored-by: catskids3 <[email protected]>
- Loading branch information
Showing
235 changed files
with
10,169 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api.Tests.Acceptance/GlobalUsings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
global using Microsoft.VisualStudio.TestTools.UnitTesting; |
19 changes: 19 additions & 0 deletions
19
...nd/OrcaHello/OrcaHello.Web.Api.Tests.Acceptance/OrcaHello.Web.Api.Tests.Acceptance.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" /> | ||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" /> | ||
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" /> | ||
<PackageReference Include="coverlet.collector" Version="3.2.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |
35 changes: 35 additions & 0 deletions
35
...tsControllerTests/Default.GetPaginatedNegativeAndUnknownCommentsForGivenTimeframeAsync.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Comment> { new() } | ||
}; | ||
|
||
_orchestrationServiceMock.Setup(service => | ||
service.RetrieveNegativeAndUnknownCommentsForGivenTimeframeAsync(It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<int>(), It.IsAny<int>())) | ||
.ReturnsAsync(response); | ||
|
||
ActionResult<CommentListResponse> 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<DateTime>(), It.IsAny<DateTime>(), It.IsAny<int>(), It.IsAny<int>()), | ||
Times.Once); | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...ers/CommentsControllerTests/Default.GetPaginatedPositiveCommentsForGivenTimeframeAsync.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Comment> { new() } | ||
}; | ||
|
||
_orchestrationServiceMock.Setup(service => | ||
service.RetrievePositiveCommentsForGivenTimeframeAsync(It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<int>(), It.IsAny<int>())) | ||
.ReturnsAsync(response); | ||
|
||
ActionResult<CommentListResponse> 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<DateTime>(), It.IsAny<DateTime>(), It.IsAny<int>(), It.IsAny<int>()), | ||
Times.Once); | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...ntEnd/OrcaHello/OrcaHello.Web.Api.Tests.Unit/Controllers/CommentsControllerTests/Setup.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
namespace OrcaHello.Web.Api.Tests.Unit.Controllers | ||
{ | ||
[ExcludeFromCodeCoverage] | ||
[TestClass] | ||
public partial class CommentsControllerTests | ||
{ | ||
private readonly Mock<ICommentOrchestrationService> _orchestrationServiceMock; | ||
private readonly CommentsController _controller; | ||
|
||
public CommentsControllerTests() | ||
{ | ||
_orchestrationServiceMock = new Mock<ICommentOrchestrationService>(); | ||
|
||
_controller = new CommentsController( | ||
commentOrchestrationService: _orchestrationServiceMock.Object); | ||
} | ||
|
||
[TestCleanup] | ||
public void TestTeardown() | ||
{ | ||
_orchestrationServiceMock.VerifyNoOtherCalls(); | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...sControllerTests/TryCatch.GetPaginatedNegativeAndUnknownCommentsForGivenTimeframeAsync.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<DateTime>(), It.IsAny<DateTime>(), It.IsAny<int>(), It.IsAny<int>())) | ||
|
||
.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<DateTime>(), It.IsAny<DateTime>(), It.IsAny<int>(), It.IsAny<int>()), | ||
Times.Exactly(5)); | ||
|
||
} | ||
|
||
private async Task ExecuteRetrieveNegativeComments(int count, int statusCode) | ||
{ | ||
for (int x = 0; x < count; x++) | ||
{ | ||
ActionResult<CommentListResponse> 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); | ||
} | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...rs/CommentsControllerTests/TryCatch.GetPaginatedPositiveCommentsForGivenTimeframeAsync.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<DateTime>(), It.IsAny<DateTime>(), It.IsAny<int>(), It.IsAny<int>())) | ||
|
||
.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<DateTime>(), It.IsAny<DateTime>(), It.IsAny<int>(), It.IsAny<int>()), | ||
Times.Exactly(5)); | ||
|
||
} | ||
|
||
private async Task ExecuteRetrieveComments(int count, int statusCode) | ||
{ | ||
for (int x = 0; x < count; x++) | ||
{ | ||
ActionResult<CommentListResponse> 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); | ||
} | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...Web.Api.Tests.Unit/Controllers/DetectionsControllerTests/Default.GetDetectionByIdAsync.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<string>())) | ||
.ReturnsAsync(expectedResult); | ||
|
||
ActionResult<Detection> 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<string>()), | ||
Times.Once); | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
.../Controllers/DetectionsControllerTests/Default.GetDetectionsForGivenInterestLabelAsync.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Detection> { new Detection() }, | ||
InterestLabel = "test" | ||
}; | ||
|
||
_orchestrationServiceMock.Setup(service => | ||
service.RetrieveDetectionsForGivenInterestLabelAsync(It.IsAny<string>())) | ||
.ReturnsAsync(response); | ||
|
||
ActionResult<DetectionListForInterestLabelResponse> 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<string>()), | ||
Times.Once); | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...i.Tests.Unit/Controllers/DetectionsControllerTests/Default.GetPaginatedDetectionsAsync.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Detection> { new() }, | ||
State = "Positive", | ||
SortBy = "timestamp", | ||
SortOrder = "desc", | ||
Location = "location" | ||
}; | ||
|
||
_orchestrationServiceMock.Setup(service => | ||
service.RetrieveFilteredDetectionsAsync(It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<string>(), | ||
It.IsAny<string>(), It.IsAny<bool>(), It.IsAny<string>(), It.IsAny<int>(), It.IsAny<int>())) | ||
.ReturnsAsync(response); | ||
|
||
ActionResult<DetectionListResponse> 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<DateTime>(), It.IsAny<DateTime>(), It.IsAny<string>(), | ||
It.IsAny<string>(), It.IsAny<bool>(), It.IsAny<string>(), It.IsAny<int>(), It.IsAny<int>()), | ||
Times.Once); | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...s/DetectionsControllerTests/Default.GetPaginatedDetectionsForGivenTimeframeAndTagAsync.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Detection> { new Detection() } | ||
}; | ||
|
||
_orchestrationServiceMock.Setup(service => | ||
service.RetrieveDetectionsForGivenTimeframeAndTagAsync(It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<string>(), It.IsAny<int>(), It.IsAny<int>())) | ||
.ReturnsAsync(response); | ||
|
||
ActionResult<DetectionListForTagResponse> 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<DateTime>(), It.IsAny<DateTime>(), It.IsAny<string>(), It.IsAny<int>(), It.IsAny<int>()), | ||
Times.Once); | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...Web.Api.Tests.Unit/Controllers/DetectionsControllerTests/Default.PutModeratedInfoAsync.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<string>(), It.IsAny<ModerateDetectionRequest>())) | ||
.ReturnsAsync(expectedResult); | ||
|
||
ModerateDetectionRequest request = new() | ||
{ | ||
Id = Guid.NewGuid().ToString(), | ||
Moderator = "Ira M. Goober", | ||
DateModerated = DateTime.UtcNow, | ||
Comments = "Comments", | ||
Tags = new List<string>() { "Tag1" } | ||
}; | ||
|
||
ActionResult<Detection> 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<string>(), It.IsAny<ModerateDetectionRequest>()), | ||
Times.Once); | ||
} | ||
} | ||
} |
Oops, something went wrong.