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()); }
public async Task ExecuteAsync_Does_Nothing_With_No_Wishes() { var wishes = Enumerable.Empty <Wish>(); var cmd = new UpdateLastSearchDateCommand(wishes); await cmd.ExecuteAsync(_table.Object); _table.Verify(t => t.ExecuteBatchAsync(It.IsAny <TableBatchOperation>()), Times.Never()); }
public async Task ExecuteAsync_Does_Nothing_With_No_Results() { var results = Enumerable.Empty <WishResult>(); var cmd = new AddWishResultsCommand(results); await cmd.ExecuteAsync(_table.Object); _table.Verify(t => t.ExecuteBatchAsync(It.IsAny <TableBatchOperation>()), Times.Never()); }
public async Task SearchOrchestrationAsync_Does_Nothing_When_There_Are_No_Providers() { var searchContext = new SearchContext { Providers = Enumerable.Empty <Provider>(), Wishes = Enumerable.Empty <Wish>() }; var context = new Mock <DurableOrchestrationContextBase>(MockBehavior.Strict); var notifications = new Mock <IAsyncCollector <PushoverNotification> >(MockBehavior.Strict); context.Setup(c => c.GetInput <SearchContext>()).Returns(searchContext); await _function.SearchOrchestrationAsync(context.Object, _wishTable.Object, notifications.Object); context.Verify(c => c.GetInput <SearchContext>(), Times.Once()); context.Verify(c => c.CallSubOrchestratorAsync <IEnumerable <WishResult> >("ProviderOrchestration", It.IsAny <object>()), Times.Never()); notifications.Verify(n => n.AddAsync(It.IsAny <PushoverNotification>(), CancellationToken.None), Times.Never()); _wishTable.Verify(t => t.ExecuteBatchAsync(It.IsAny <TableBatchOperation>()), Times.Never()); }