Skip to content

Commit

Permalink
Merge branch 'bcgov:dev' into PSP-9471
Browse files Browse the repository at this point in the history
  • Loading branch information
stairaku authored Dec 27, 2024
2 parents 7f3641e + b71844e commit a51985c
Show file tree
Hide file tree
Showing 138 changed files with 6,995 additions and 2,964 deletions.
31 changes: 31 additions & 0 deletions source/backend/Pims.Scheduler.Test/Pims.Scheduler.Test.csproj
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>
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);
}
}
}
Loading

0 comments on commit a51985c

Please sign in to comment.