예제 #1
0
        public void AssertItemDoesNotExistAsync_WhenDoesNotExist()
        {
            AttributeValue key = GenerateKey();

            Dictionary <string, AttributeValue> itemKey = new Dictionary <string, AttributeValue> {
                { "key", key }
            };

            Assert.DoesNotThrowAsync(async() => {
                await AmazonDynamoDBAssert
                .AssertItemDoesNotExistAsync(
                    m_db,
                    m_tableName,
                    key: itemKey
                    )
                .ConfigureAwait(continueOnCapturedContext: false);
            });
        }
예제 #2
0
        public async Task AssertItemDoesNotExistAsync_WhenExists()
        {
            AttributeValue key = GenerateKey();

            await m_db
            .PutItemAsync(
                m_tableName,
                item : new Dictionary <string, AttributeValue> {
                { "key", key },
                { "age", new AttributeValue {
                      N = "111"
                  } }
            }
                )
            .ConfigureAwait(continueOnCapturedContext: false);

            Dictionary <string, AttributeValue> itemKey = new Dictionary <string, AttributeValue> {
                { "key", key }
            };

            var err = Assert.Throws <AssertionException>(() => {
                AmazonDynamoDBAssert
                .AssertItemDoesNotExistAsync(
                    m_db,
                    m_tableName,
                    key: itemKey
                    )
                .ConfigureAwait(continueOnCapturedContext: false)
                .GetAwaiter()
                .GetResult();
            });

            Assert.That(
                err.Message,
                Is.EqualTo("Item should not exist.")
                );
        }