Esempio n. 1
0
        public async Task UniqueIndexActorRemove_ExpectsNewStateWithoutRemovedItems()
        {
            var stateManager = new Mock <IActorStateManager>();
            var list         = new Dictionary <string, string> {
                { "Test1", Guid.NewGuid().ToString() }, { "Test2", Guid.NewGuid().ToString() }, { "Test3", Guid.NewGuid().ToString() }, { "Test4", Guid.NewGuid().ToString() }, { "Test5", Guid.NewGuid().ToString() }, { "Test6", Guid.NewGuid().ToString() }, { "Test7", Guid.NewGuid().ToString() }
            };
            var state = new Dictionary <string, string>(list);

            stateManager.Setup(manager => manager.GetStateAsync <Dictionary <string, string> >(_stateName, It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(state))
            .Verifiable();
            stateManager.Setup(manager => manager.SetStateAsync(_stateName, state, It.IsAny <CancellationToken>()))
            .Verifiable();
            UniqueIndexActor testDemoActor = await CreateActor(stateManager.Object, "Test UniqueIndexActor");

            await testDemoActor.Remove("Test1");

            await testDemoActor.Remove("Test5");

            await testDemoActor.Remove("Test7");

            list.Remove("Test1");
            list.Remove("Test5");
            list.Remove("Test7");
            state.Should().HaveCount(4);
            state.Should().Contain(list);

            stateManager.VerifyAll();
        }