public async Task AssertItemAsync_WhenExistsAndEqual() { AttributeValue key = GenerateKey(); Dictionary <string, AttributeValue> item = new Dictionary <string, AttributeValue> { { "key", key }, { "age", new AttributeValue { N = "111" } } }; await m_db .PutItemAsync(m_tableName, item) .ConfigureAwait(continueOnCapturedContext: false); Assert.DoesNotThrowAsync(async() => { await AmazonDynamoDBAssert .AssertItemAsync( m_db, m_tableName, key: new Dictionary <string, AttributeValue> { { "key", key } }, expectedItem: item ) .ConfigureAwait(continueOnCapturedContext: false); }); }
public void AssertItemAsync_WhenDoesNotExist() { AttributeValue key = GenerateKey(); Dictionary <string, AttributeValue> itemKey = new Dictionary <string, AttributeValue> { { "key", key } }; Dictionary <string, AttributeValue> expectedItem = new Dictionary <string, AttributeValue> { { "key", key }, { "age", new AttributeValue { N = "555" } } }; var err = Assert.Throws <AssertionException>(() => { AmazonDynamoDBAssert .AssertItemAsync( m_db, m_tableName, key: itemKey, expectedItem: expectedItem ) .ConfigureAwait(continueOnCapturedContext: false) .GetAwaiter() .GetResult(); }); Assert.That( err.Message, Is.EqualTo("Item should exist.") ); }
public async Task AssertItemAsync_WhenExistsAndNotEqual() { AttributeValue key = GenerateKey(); Dictionary <string, AttributeValue> item = new Dictionary <string, AttributeValue> { { "key", key }, { "age", new AttributeValue { N = "222" } } }; await m_db .PutItemAsync(m_tableName, item) .ConfigureAwait(continueOnCapturedContext: false); Dictionary <string, AttributeValue> itemKey = new Dictionary <string, AttributeValue> { { "key", key } }; Dictionary <string, AttributeValue> expectedItem = new Dictionary <string, AttributeValue> { { "key", key }, { "age", new AttributeValue { N = "333" } } }; var err = Assert.Throws <AssertionException>(() => { AmazonDynamoDBAssert .AssertItemAsync( m_db, m_tableName, key: itemKey, expectedItem: expectedItem ) .ConfigureAwait(continueOnCapturedContext: false) .GetAwaiter() .GetResult(); }); Assert.That( err.Message, Does.StartWith(" M[age].N must be equal") ); }