コード例 #1
0
        public async Task GetOptionalAsyncReturnsEmpty()
        {
            using (var fixture = new MsSqlStreamStoreFixture("dbo"))
            {
                using (var store = await fixture.GetStreamStore())
                {
                    var sut = new RepositoryScenarioBuilder(store)
                              .BuildForAsyncRepository();

                    var result = await sut.GetOptionalAsync(_model.UnknownIdentifier);

                    Assert.Equal(result, Optional <AggregateRootEntityStub> .Empty);
                }
            }
        }
コード例 #2
0
        public async Task GetOptionalAsyncReturnsRootForKnownId()
        {
            using (var fixture = new MsSqlStreamStoreFixture("dbo"))
            {
                using (var store = await fixture.GetStreamStore())
                {
                    var sut = new RepositoryScenarioBuilder(store)
                              .ScheduleAttachToUnitOfWork(new Aggregate(_model.KnownIdentifier, 0, _root))
                              .BuildForAsyncRepository();

                    var result = await sut.GetOptionalAsync(_model.KnownIdentifier);

                    Assert.Equal(result, new Optional <AggregateRootEntityStub>(_root));
                }
            }
        }
コード例 #3
0
        public async Task GetReturnsRootOfKnownId()
        {
            using (var fixture = new MsSqlStreamStoreFixture("dbo"))
            {
                using (var store = await fixture.GetMsSqlStreamStore())
                {
                    var sut = new RepositoryScenarioBuilder(store)
                              .ScheduleAppendToStream(_model.KnownIdentifier, new EventStub(1))
                              .BuildForAsyncRepository();

                    var result = await sut.GetAsync(_model.KnownIdentifier);

                    result.RecordedEvents.ShouldBeEquivalentTo(new[] { new EventStub(1) });
                }
            }
        }
コード例 #4
0
        public async Task AddAttachesToUnitOfWork()
        {
            using (var fixture = new MsSqlStreamStoreFixture("dbo"))
            {
                using (var store = await fixture.GetStreamStore())
                {
                    var sut = new RepositoryScenarioBuilder(store)
                              .BuildForAsyncRepository();

                    sut.Add(_model.KnownIdentifier, _root);

                    Aggregate aggregate;
                    var       result = sut.UnitOfWork.TryGet(_model.KnownIdentifier, out aggregate);
                    Assert.True(result);
                    Assert.Equal(aggregate.Identifier, _model.KnownIdentifier);
                    Assert.Equal(aggregate.Root, _root);
                }
            }
        }
コード例 #5
0
        public async Task GetAsyncThrows()
        {
            using (var fixture = new MsSqlStreamStoreFixture("dbo"))
            {
                using (var store = await fixture.GetStreamStore())
                {
                    var sut = new RepositoryScenarioBuilder(store)
                              .BuildForAsyncRepository();

                    var exception =
                        await Assert.ThrowsAsync <AggregateNotFoundException>(async() =>
                    {
                        var _ = await sut.GetAsync(_model.UnknownIdentifier);
                    });

                    Assert.Equal(exception.Identifier, _model.UnknownIdentifier);
                    Assert.Equal(exception.ClrType, typeof(AggregateRootEntityStub));
                }
            }
        }