Exemplo n.º 1
0
        public async Task CheckUpdateItemDataModel()
        {
            var clientConfig = new AmazonDynamoDBConfig();

            clientConfig.ServiceURL = _endpointURL;
            var client = new AmazonDynamoDBClient(clientConfig);

            output.WriteLine("Created client with endpoint URL: " + _endpointURL);

            IDynamoDBContext context = CreateMockDynamoDBContext(client);

            // Create the table.
            var makeTableResult = CreateTable.MakeTableAsync(client, _tableName);

            output.WriteLine("Created table " + makeTableResult.Result.TableDescription.TableName);

            // Add an item to the table.
            var result = AddItem.AddItemAsync(client, _tableName, _id, _keys, _values);

            if (result.Result)
            {
                output.WriteLine("Added item to " + _tableName);
            }
            else
            {
                output.WriteLine("Did not add item to " + _tableName);
            }

            // Update the item.
            var updateResult = await UpdateItemDataModel.UpdateTableItemAsync(context, _id, _status);

            // Make sure it was updated correctly.
            bool gotResult = updateResult != null;

            Assert.True(gotResult, "Could NOT get result");

            bool ok = (updateResult.ID == _id) && (updateResult.Order_Status == _status);

            Assert.True(ok, "Could NOT update item");

            output.WriteLine("Updated item");

            // Delete the table.
            var removeResult = DeleteTable.RemoveTableAsync(client, _tableName);

            if (removeResult.Result.HttpStatusCode == System.Net.HttpStatusCode.OK)
            {
                output.WriteLine("Removed table " + _tableName);
            }
            else
            {
                output.WriteLine("Could not remove table " + _tableName);
            }
        }
        public async Task CheckDeleteTable()
        {
            IAmazonDynamoDB client = CreateMockDynamoDBClient();

            var result = await DeleteTable.RemoveTableAsync(client, _tableName);

            bool gotResult = result != null;

            Assert.True(gotResult, "Could NOT get result");

            bool ok = result.HttpStatusCode == HttpStatusCode.OK;

            Assert.True(ok, "Could NOT delete table " + _tableName);

            output.WriteLine("Deleted table");
        }