public async Task GetAvailableEmpty()
        {
            var domainObjectStore = new Mock <IDomainObjectStore>(MockBehavior.Strict);

            domainObjectStore.Setup(dos => dos.ReplayObject <ConfigEnvironmentList>(It.IsAny <long>()))
            .ReturnsAsync(() => Result.Success(new ConfigEnvironmentList()))
            .Verifiable();

            var eventStore = new Mock <IEventStore>(MockBehavior.Strict);

            eventStore.Setup(es => es.ReplayEventsAsStream(
                                 It.IsAny <Func <(StoredEvent StoredEvent, DomainEventMetadata Metadata), bool> >(),
                                 It.IsAny <Func <(StoredEvent StoredEvent, DomainEvent DomainEvent), bool> >(),
                                 It.IsAny <int>(),
                                 It.IsAny <StreamDirection>(),
                                 It.IsAny <long>()))
            .Returns(Task.CompletedTask);

            var store = new EnvironmentProjectionStore(eventStore.Object,
                                                       domainObjectStore.Object,
                                                       _logger,
                                                       new ICommandValidator[0]);

            var result = await store.GetAvailable(QueryRange.All);

            Assert.Empty(result.Message);
            Assert.False(result.IsError, "result.IsError");
            Assert.Empty(result.Data);

            domainObjectStore.Verify();
            eventStore.Verify();
        }
        public async Task GetAvailablePaged()
        {
            var domainObjectStore = new Mock <IDomainObjectStore>(MockBehavior.Strict);

            domainObjectStore.Setup(dos => dos.ReplayObject <ConfigEnvironmentList>(It.IsAny <long>()))
            .ReturnsAsync((long v) =>
            {
                var list = new ConfigEnvironmentList();
                list.ApplyEvent(new ReplayedEvent
                {
                    DomainEvent = new EnvironmentCreated(new EnvironmentIdentifier("Foo", "Foo")),
                    UtcTime     = DateTime.UtcNow,
                    Version     = 4710
                });
                list.ApplyEvent(new ReplayedEvent
                {
                    DomainEvent = new EnvironmentCreated(new EnvironmentIdentifier("Foo", "Bar")),
                    UtcTime     = DateTime.UtcNow,
                    Version     = 4711
                });
                list.ApplyEvent(new ReplayedEvent
                {
                    DomainEvent = new EnvironmentCreated(new EnvironmentIdentifier("Foo", "Baz")),
                    UtcTime     = DateTime.UtcNow,
                    Version     = 4712
                });
                return(Result.Success(list));
            })
            .Verifiable();

            var eventStore = new Mock <IEventStore>(MockBehavior.Strict);

            eventStore.Setup(es => es.ReplayEventsAsStream(
                                 It.IsAny <Func <(StoredEvent StoredEvent, DomainEventMetadata Metadata), bool> >(),
                                 It.IsAny <Func <(StoredEvent StoredEvent, DomainEvent DomainEvent), bool> >(),
                                 It.IsAny <int>(),
                                 It.IsAny <StreamDirection>(),
                                 It.IsAny <long>()))
            .Returns(Task.CompletedTask);

            var store = new EnvironmentProjectionStore(eventStore.Object,
                                                       domainObjectStore.Object,
                                                       _logger,
                                                       new ICommandValidator[0]);

            var result = await store.GetAvailable(QueryRange.Make(1, 1));

            Assert.Empty(result.Message);
            Assert.False(result.IsError, "result.IsError");
            Assert.Single(result.Data);

            domainObjectStore.Verify();
            eventStore.Verify();
        }