-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d29c9c4
commit ebe8f13
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
tests/Dynatello.Tests/HandlerTests/DeleteRequestHandlerTests.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,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<IAmazonDynamoDB>(); | ||
var expected = Cat.Fixture.Create<Cat>(); | ||
|
||
amazonDynamoDB | ||
.DeleteItemAsync(Arg.Any<DeleteItemRequest>()) | ||
.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<IAmazonDynamoDB>(); | ||
var expected = Cat.Fixture.Create<Cat>(); | ||
|
||
amazonDynamoDB | ||
.DeleteItemAsync(Arg.Any<DeleteItemRequest>()) | ||
.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); | ||
} | ||
} |