public async Task CanBeUsed() { var dictionary = await stateManager.GetOrAddAsync <IReliableDictionary <string, string> >("test4", TimeSpan.FromSeconds(5)); using (var tx = stateManager.CreateTransaction()) { var testableSession = new TestableServiceFabricStorageSession(stateManager, tx); var handlerContext = new TestableInvokeHandlerContext { SynchronizedStorageSession = testableSession }; var handler = new HandlerUsingSynchronizedStorageSessionExtension(); await handler.Handle(new MyMessage(), handlerContext); await tx.CommitAsync(); } using (var tx = stateManager.CreateTransaction()) { var value = await dictionary.TryGetValueAsync(tx, "Key"); Assert.True(value.HasValue); Assert.AreEqual("Value", value.Value); } }
public async Task CanBeUsed() { var transactionalBatch = new FakeTransactionalBatch(); var testableSession = new TestableCosmosSynchronizedStorageSession(new PartitionKey("mypartitionkey")) { TransactionalBatch = transactionalBatch }; var handlerContext = new TestableInvokeHandlerContext { SynchronizedStorageSession = testableSession }; var handler = new HandlerUsingSynchronizedStorageSessionExtension(); await handler.Handle(new MyMessage(), handlerContext); Assert.IsNotEmpty(transactionalBatch.CreatedItems.OfType <MyItem>()); }