Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/cleanup #517

Merged
merged 12 commits into from
Feb 13, 2024
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
namespace Dfe.PlanTech.Infrastructure.Contentful.Helpers;
using System.Runtime.Serialization;

namespace Dfe.PlanTech.Infrastructure.Contentful.Helpers;

[Serializable]
public class GetEntitiesException(string? message) : Exception(message)
public class GetEntitiesException(string? message) : Exception(message), ISerializable
{

protected GetEntitiesException(SerializationInfo info, StreamingContext context) : this(null)
jimwashbrook marked this conversation as resolved.
Show resolved Hide resolved
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,5 +156,16 @@ public async Task GetEntityById_Should_Throw_GetEntitiesIDException_When_Duplica

await Assert.ThrowsAsync<GetEntitiesException>(() => repository.GetEntityById<TestClass>(testId));
}

[Fact]
public async Task GetEntityById_Should_Throw_GetEntitiesIDException_With_Correct_Exception_Message_When_DuplicateIds()
{
var testId = "duplicateId";

ContentfulRepository repository = new ContentfulRepository(new NullLoggerFactory(), _clientSubstitute);

var exceptionMessage = await Assert.ThrowsAsync<GetEntitiesException>(() => repository.GetEntityById<TestClass>(testId));
Assert.Equal("Found more than 1 entity with id duplicateId", exceptionMessage.Message);
}
}
}