-
Notifications
You must be signed in to change notification settings - Fork 102
/
Copy pathStockDynamoDbTests.cs
48 lines (37 loc) · 1.41 KB
/
StockDynamoDbTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using Amazon.DynamoDBv2.DocumentModel;
using GetStock.Adapters;
using GetStock.Adapters.Exceptions;
using GetStock.Adapters.Model;
using GetStock.IntegrationTest.Fixtures;
using GetStock.IntegrationTest.TestUtilities;
namespace GetStock.IntegrationTest.Adapters;
public class StockDynamoDbTests(DynamoDbFixture fixture) : DynamoDbTestBase(fixture)
{
[Fact]
public async Task GetStockValue_With_StockNotInDb_Should_ThrowStockNotFoundException()
{
var config = new TestServiceConfiguration
{
DynamoDbTableName = TableName
};
var target = new StockDynamoDb(Client, config);
await Assert.ThrowsAsync<StockNotFoundException>(() => target.GetStockValueAsync("stock-1"));
}
[Fact]
public async Task GetStockValue_With_StockInDb_Should_ReturnStockData()
{
var config = new TestServiceConfiguration
{
DynamoDbTableName = TableName
};
var item = new Document();
item["StockId"] = "stock-1";
item["Value"] = 100.0;
var table = Table.LoadTable(Client, TableName);
await table.PutItemAsync(item);
var target = new StockDynamoDb(Client, config);
var result = await target.GetStockValueAsync("stock-1");
var expected = new StockData { StockId = "stock-1", Value = 100.0 };
Assert.Equal(expected, result);
}
}