Esempio n. 1
0
        public async Task CreateCommand_CheckValue()
        {
            var stateManager = new Mock <IActorStateManager>();
            var messageQueue = new Mock <IEventPublisher>();
            var state        = new FakeState {
                FakeGuid = Guid.NewGuid(), FakeString = "hello world", FakeInt = 2000
            };

            stateManager.Setup(manager => manager.SetStateAsync(_stateName, state, It.IsAny <CancellationToken>())).Verifiable();
            FakeDispatchActor testDemoActor = await CreateActor(stateManager.Object, messageQueue.Object, state.FakeGuid);

            await testDemoActor.Tell(new CreateFakeDispatch(state.FakeGuid, state.FakeInt, state.FakeString));

            stateManager.VerifyAll();
        }
Esempio n. 2
0
        public async Task ActorBaseIsInitialized_ExpectTrue()
        {
            var stateManager = new Mock <IActorStateManager>();
            var state        = new FakeState {
                FakeGuid = Guid.NewGuid(), FakeString = "hello world", FakeInt = 2000
            };

            stateManager.Setup(manager => manager.GetStateAsync <FakeState>(_stateName, It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(state))
            .Verifiable();
            // stateManager.Setup(manager => manager.SetStateAsync("FakeBase", state, It.IsAny<CancellationToken>())).Verifiable();
            FakeBaseActor testDemoActor = await CreateActor(stateManager.Object, state.FakeGuid);

            bool result = await testDemoActor.IsInitialized();

            result.Should().BeTrue();

            stateManager.VerifyAll();
        }
Esempio n. 3
0
        public async Task GetFakeInt_CheckValue()
        {
            var stateManager = new Mock <IActorStateManager>();
            var messageQueue = new Mock <IEventPublisher>();
            var state        = new FakeState {
                FakeGuid = Guid.NewGuid(), FakeString = "hello world", FakeInt = 2000
            };

            stateManager.Setup(manager => manager.GetStateAsync <FakeState>(_stateName, It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(state))
            .Verifiable();
            // stateManager.Setup(manager => manager.SetStateAsync("FakeBase", state, It.IsAny<CancellationToken>())).Verifiable();
            FakeDispatchActor testDemoActor = await CreateActor(stateManager.Object, messageQueue.Object, state.FakeGuid);

            int result = await testDemoActor.Ask(new GetFakeDispatchInt(state.FakeGuid));

            result.Should().Be(state.FakeInt);

            stateManager.VerifyAll();
        }
Esempio n. 4
0
        public async Task CreateCommand_ExpectCreatedEvent()
        {
            var stateManager = new Mock <IActorStateManager>();
            var messageQueue = new Mock <IEventPublisher>();
            var id           = Guid.NewGuid();
            var state        = new FakeState {
                FakeGuid = Guid.NewGuid(), FakeString = "hello world", FakeInt = 2000
            };
            var events = new List <IEvent>(new[] { new FakeDispatchCreated(state.FakeGuid, state.FakeInt, state.FakeString) });

            messageQueue
            .Setup(messageQueue => messageQueue.Publish(events, It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(id))
            .Verifiable();
            FakeDispatchActor testDemoActor = await CreateActor(stateManager.Object, messageQueue.Object, state.FakeGuid);

            await testDemoActor.Tell(new CreateFakeDispatch(state.FakeGuid, state.FakeInt, state.FakeString));

            stateManager.VerifyAll();
        }