-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'bcgov:dev' into PSP-9471
- Loading branch information
Showing
138 changed files
with
6,995 additions
and
2,964 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
source/backend/Pims.Scheduler.Test/Pims.Scheduler.Test.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,31 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="FluentAssertions" Version="6.10.0" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" /> | ||
<PackageReference Include="Moq" Version="4.20.70" /> | ||
<PackageReference Include="xunit" Version="2.4.2" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="6.0.0"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\scheduler\Pims.Scheduler.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
105 changes: 105 additions & 0 deletions
105
source/backend/Pims.Scheduler.Test/Repositories/PimsDocumentQueueRepositoryTests.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,105 @@ | ||
using FluentAssertions; | ||
using Moq; | ||
using Pims.Api.Models.CodeTypes; | ||
using Pims.Api.Models.Concepts.Document; | ||
using Pims.Api.Models.Requests.Http; | ||
using Pims.Dal.Entities.Models; | ||
using Pims.Scheduler.Repositories; | ||
using Xunit; | ||
|
||
namespace Pims.Scheduler.Test.Repositories | ||
{ | ||
public class PimsDocumentQueueRepositoryTest | ||
{ | ||
[Fact] | ||
public async Task PollQueuedDocument_ValidDocument_ReturnsExternalResponse() | ||
{ | ||
// Arrange | ||
var document = new DocumentQueueModel { Id = 1 }; | ||
var expectedResponse = new ExternalResponse<DocumentQueueModel> { Status = ExternalResponseStatus.Success }; | ||
var repositoryMock = new Mock<IPimsDocumentQueueRepository>(); | ||
repositoryMock.Setup(x => x.PollQueuedDocument(document)).ReturnsAsync(expectedResponse); | ||
|
||
// Act | ||
var result = await repositoryMock.Object.PollQueuedDocument(document); | ||
|
||
// Assert | ||
result.Should().NotBeNull(); | ||
result.Status.Should().Be(ExternalResponseStatus.Success); | ||
repositoryMock.Verify(x => x.PollQueuedDocument(document), Times.Once); | ||
} | ||
|
||
[Fact] | ||
public async Task UploadQueuedDocument_ValidDocument_ReturnsExternalResponse() | ||
{ | ||
// Arrange | ||
var document = new DocumentQueueModel { Id = 1 }; | ||
var expectedResponse = new ExternalResponse<DocumentQueueModel> { Status = ExternalResponseStatus.Success }; | ||
var repositoryMock = new Mock<IPimsDocumentQueueRepository>(); | ||
repositoryMock.Setup(x => x.UploadQueuedDocument(document)).ReturnsAsync(expectedResponse); | ||
|
||
// Act | ||
var result = await repositoryMock.Object.UploadQueuedDocument(document); | ||
|
||
// Assert | ||
result.Should().NotBeNull(); | ||
result.Status.Should().Be(ExternalResponseStatus.Success); | ||
repositoryMock.Verify(x => x.UploadQueuedDocument(document), Times.Once); | ||
} | ||
|
||
[Fact] | ||
public async Task UpdateQueuedDocument_ValidDocument_ReturnsExternalResponse() | ||
{ | ||
// Arrange | ||
var documentQueueId = 1; | ||
var document = new DocumentQueueModel { Id = documentQueueId }; | ||
var expectedResponse = new ExternalResponse<DocumentQueueModel> { Status = ExternalResponseStatus.Success }; | ||
var repositoryMock = new Mock<IPimsDocumentQueueRepository>(); | ||
repositoryMock.Setup(x => x.UpdateQueuedDocument(documentQueueId, document)).ReturnsAsync(expectedResponse); | ||
|
||
// Act | ||
var result = await repositoryMock.Object.UpdateQueuedDocument(documentQueueId, document); | ||
|
||
// Assert | ||
result.Should().NotBeNull(); | ||
result.Status.Should().Be(ExternalResponseStatus.Success); | ||
repositoryMock.Verify(x => x.UpdateQueuedDocument(documentQueueId, document), Times.Once); | ||
} | ||
|
||
[Fact] | ||
public async Task SearchQueuedDocumentsAsync_ValidFilter_ReturnsExternalResponse() | ||
{ | ||
// Arrange | ||
var filter = new DocumentQueueFilter(); | ||
var expectedResponse = new ExternalResponse<List<DocumentQueueModel>> { Status = ExternalResponseStatus.Success }; | ||
var repositoryMock = new Mock<IPimsDocumentQueueRepository>(); | ||
repositoryMock.Setup(x => x.SearchQueuedDocumentsAsync(filter)).ReturnsAsync(expectedResponse); | ||
|
||
// Act | ||
var result = await repositoryMock.Object.SearchQueuedDocumentsAsync(filter); | ||
|
||
// Assert | ||
result.Should().NotBeNull(); | ||
result.Status.Should().Be(ExternalResponseStatus.Success); | ||
repositoryMock.Verify(x => x.SearchQueuedDocumentsAsync(filter), Times.Once); | ||
} | ||
|
||
[Fact] | ||
public async Task GetById_ValidDocumentQueueId_ReturnsExternalResponse() | ||
{ | ||
// Arrange | ||
var documentQueueId = 1; | ||
var expectedResponse = new ExternalResponse<DocumentQueueModel> { Status = ExternalResponseStatus.Success }; | ||
var repositoryMock = new Mock<IPimsDocumentQueueRepository>(); | ||
repositoryMock.Setup(x => x.GetById(documentQueueId)).ReturnsAsync(expectedResponse); | ||
|
||
// Act | ||
var result = await repositoryMock.Object.GetById(documentQueueId); | ||
|
||
// Assert | ||
result.Should().NotBeNull(); | ||
result.Status.Should().Be(ExternalResponseStatus.Success); | ||
repositoryMock.Verify(x => x.GetById(documentQueueId), Times.Once); | ||
} | ||
} | ||
} |
Oops, something went wrong.