diff --git a/tests/Dynatello.Tests/HandlerTests/DeleteRequestHandlerTests.cs b/tests/Dynatello.Tests/HandlerTests/DeleteRequestHandlerTests.cs new file mode 100644 index 0000000..8e35e16 --- /dev/null +++ b/tests/Dynatello.Tests/HandlerTests/DeleteRequestHandlerTests.cs @@ -0,0 +1,52 @@ +using Amazon.DynamoDBv2; +using Amazon.DynamoDBv2.Model; +using AutoFixture; +using Dynatello.Builders; +using Dynatello.Handlers; +using NSubstitute; + +namespace Dynatello.Tests.HandlerTests; +public class DeleteRequestHandlerTests +{ + + + [Fact] + public async Task Send_SuccessMock_ShouldReturnItem() + { + var amazonDynamoDB = Substitute.For(); + var expected = Cat.Fixture.Create(); + + amazonDynamoDB + .DeleteItemAsync(Arg.Any()) + .Returns(new DeleteItemResponse + { + HttpStatusCode = System.Net.HttpStatusCode.OK, + Attributes = Cat.GetById.Marshall(expected) + }); + + var actual = await Cat.GetById + .OnTable("TABLE") + .ToDeleteRequestHandler(x => x.ToDeleteRequestBuilder(), x => x.AmazonDynamoDB = amazonDynamoDB) + .Send(expected.Id, default); + + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Send_MissingValue_ShouldReturnNull() + { + var amazonDynamoDB = Substitute.For(); + var expected = Cat.Fixture.Create(); + + amazonDynamoDB + .DeleteItemAsync(Arg.Any()) + .Returns(new DeleteItemResponse { }); + + var actual = await Cat.GetById + .OnTable("TABLE") + .ToDeleteRequestHandler(x => x.ToDeleteRequestBuilder(), x => x.AmazonDynamoDB = amazonDynamoDB) + .Send(expected.Id, default); + + Assert.Null(actual); + } +}