コード例 #1
0
        public async Task ExecuteAsync_Updates_The_Active_Property()
        {
            var wish = new Wish {
                RowKey = "123", Active = false
            };

            _table.SetupSequence(t => t.ExecuteAsync(It.IsAny <TableOperation>()))
            .ReturnsAsync(new TableResult
            {
                Etag           = "new",
                HttpStatusCode = 200,
                Result         = new DynamicTableEntity(wish.PartitionKey, wish.RowKey, "new", new Dictionary <string, EntityProperty> {
                    { "Active", new EntityProperty(false) }
                })
            })
            .ReturnsAsync(new TableResult
            {
                Etag           = "new",
                HttpStatusCode = 200,
                Result         = new DynamicTableEntity(wish.PartitionKey, wish.RowKey, "new", new Dictionary <string, EntityProperty> {
                    { "Active", new EntityProperty(true) }
                })
            });

            var cmd = new ToggleWishCommand(wish.RowKey, true);
            await cmd.ExecuteAsync(_table.Object);

            _table.Verify(t => t.ExecuteAsync(It.Is <TableOperation>(op => op.OperationType == TableOperationType.Retrieve)), Times.Once());
            _table.Verify(t => t.ExecuteAsync(It.Is <TableOperation>(op => op.OperationType == TableOperationType.Merge)), Times.Once());
        }