Ejemplo n.º 1
0
        public async Task Should_provide_state_from_services_and_add_to_cache()
        {
            var actualObject = await sut.GetSingleAsync <MyStatefulObject, string>(key);

            Assert.Same(statefulObject, actualObject);
            Assert.NotNull(cache.Get <object>(key));
        }
Ejemplo n.º 2
0
        public async Task Should_read_from_store()
        {
            statefulObject.ExpectedVersion = 1;

            A.CallTo(() => snapshotStore.ReadAsync(key))
            .Returns((123, 1));

            var actualObject = await sut.GetSingleAsync <MyStatefulObject, string>(key);

            Assert.Same(statefulObject, actualObject);
            Assert.NotNull(cache.Get <object>(key));

            Assert.Equal(123, statefulObject.State);
        }
Ejemplo n.º 3
0
        public async Task Should_read_from_store()
        {
            statefulObject.ExpectedVersion = 1;

            var event1 = new MyEvent();
            var event2 = new MyEvent();

            SetupEventStore(event1, event2);

            var actualObject = await sut.GetSingleAsync <MyStatefulObject>(key);

            Assert.Same(statefulObject, actualObject);
            Assert.NotNull(cache.Get <object>(key));

            Assert.Equal(actualObject.AppliedEvents, new[] { event1, event2 });
        }