Beispiel #1
0
 public void SetUp()
 {
     _root       = AggregateRootEntityStub.Factory();
     _unitOfWork = new UnitOfWork();
     _unitOfWork.Attach(new Aggregate(Model.KnownIdentifier, 0, _root));
     _sut = new Repository <AggregateRootEntityStub>(AggregateRootEntityStub.Factory, _unitOfWork,
                                                     new EmptyEventStreamReader());
 }
 public void SetUp()
 {
     _model = new Model();
     _root  = AggregateRootEntityStub.Factory();
     _sut   = new RepositoryScenarioBuilder().
              ScheduleAttachToUnitOfWork(new Aggregate(_model.KnownIdentifier, 0, _root)).
              BuildForRepository();
 }
Beispiel #3
0
 public void SetUp()
 {
     EmbeddedEventStore.Connection.DeleteAllStreams();
     _model = new Model();
     _root  = AggregateRootEntityStub.Factory();
     _sut   = new RepositoryScenarioBuilder().
              ScheduleAttachToUnitOfWork(new Aggregate(_model.KnownIdentifier, 0, _root)).
              BuildForRepository();
 }
Beispiel #4
0
            public void ConstructorIsSetInResultingSpecification()
            {
                var ctor = new AggregateRootEntityStub();
                Func <AggregateRootEntityStub> factory = () => ctor;

                var result = new ConstructorScenarioFor <AggregateRootEntityStub>(factory).
                             Then(new object[0]).Build().SutFactory;

                Assert.That(result(), Is.SameAs(ctor));
            }
            public void ConstructorIsSetInResultingSpecification()
            {
                var ctor = new AggregateRootEntityStub();
                Func<AggregateRootEntityStub> factory = () => ctor;

                var result = new ConstructorScenarioFor<AggregateRootEntityStub>(factory).
                    Then(new object[0]).Build().SutFactory;

                Assert.That(result(), Is.SameAs(ctor));
            }
        public void UsingConstructorWithoutPartitionReturnsInstanceWithExpectedProperties(
            [ValueSource(typeof(AggregateTestsValueSource), nameof(AggregateTestsValueSource.IdSource))] string identifier,
            [Values(int.MinValue, -1, 0, 1, int.MaxValue)] int version)
        {
            var root = new AggregateRootEntityStub();
            var sut  = new Aggregate(identifier, version, root);

            Assert.That(sut.Identifier, Is.EqualTo(identifier));
            Assert.That(sut.ExpectedVersion, Is.EqualTo(version));
            Assert.That(sut.Root, Is.SameAs(root));
        }
Beispiel #7
0
        public void SetUp()
        {
            var eventDeserializer = new EventDeserializer(SimpleJson.DeserializeObject);
            var eventMapping      = new EventMapping(new Dictionary <string, Type>());

            _model = new Model();
            _root  = AggregateRootEntityStub.Factory();
            _sut   = new RepositoryScenarioBuilder(eventMapping, eventDeserializer).
                     ScheduleAttachToUnitOfWork(new Aggregate(_model.KnownIdentifier, 0, _root)).
                     BuildForRepository();
        }
Beispiel #8
0
 public void SetUp()
 {
     _root       = AggregateRootEntityStub.Factory();
     _unitOfWork = new UnitOfWork();
     _sut        = new Repository <AggregateRootEntityStub>(
         () => _root,
         _unitOfWork,
         new FilledEventStreamReader(new Dictionary <string, IList <object> >
     {
         { Model.KnownIdentifier, new List <object>() }
     }));
 }
Beispiel #9
0
        public void AddAttachesToUnitOfWork()
        {
            var root = AggregateRootEntityStub.Factory();

            _sut.Add(_model.KnownIdentifier, root);

            var result = _sut.UnitOfWork.TryGet(_model.KnownIdentifier, out var aggregate);

            Assert.That(result, Is.True);
            Assert.That(aggregate.Identifier, Is.EqualTo(_model.KnownIdentifier));
            Assert.That(aggregate.Root, Is.SameAs(root));
        }
Beispiel #10
0
            public void SutIsSetInResultingSpecification()
            {
                var ctor = new AggregateRootEntityStub();

                var result = new FactoryScenarioFor <AggregateRootEntityStub>(ctor).
                             When(_ => new AggregateRootEntityStub()).
                             ThenNone().
                             Build().
                             SutFactory;

                Assert.That(result(), Is.SameAs(ctor));
            }
            public void SutFactoryIsSetInResultingSpecification()
            {
                var ctor = new AggregateRootEntityStub();
                Func <AggregateRootEntityStub> factory = () => ctor;

                var result = new QueryScenarioFor <AggregateRootEntityStub>(factory).
                             When(_ => 0).
                             Then(0).
                             Build().
                             SutFactory;

                Assert.That(result(), Is.SameAs(ctor));
            }
Beispiel #12
0
        public void WithRootReturnsExpectedResult()
        {
            var sut             = new AggregateBuilder();
            var identifier      = sut.Identifier;
            var expectedVersion = sut.ExpectedVersion;
            var root            = new AggregateRootEntityStub();

            var result = sut.WithRoot(root);

            Assert.That(result, Is.SameAs(sut));
            Assert.That(sut.Identifier, Is.EqualTo(identifier));
            Assert.That(sut.ExpectedVersion, Is.EqualTo(expectedVersion));
            Assert.That(sut.Root, Is.SameAs(root));
        }
            public async Task AddAttachesToUnitOfWork()
            {
                var sut  = await _sut;
                var root = AggregateRootEntityStub.Factory();

                sut.Add(_model.KnownIdentifier, root);

                Aggregate aggregate;
                var       result = sut.UnitOfWork.TryGet(_model.KnownIdentifier, out aggregate);

                Assert.That(result, Is.True);
                Assert.That(aggregate.Identifier, Is.EqualTo(_model.KnownIdentifier));
                Assert.That(aggregate.Root, Is.SameAs(root));
            }
        public void ToBuilderReturnsExpectedResult()
        {
            const string identifier      = "identifier";
            const int    expectedVersion = 123;
            var          root            = new AggregateRootEntityStub();
            var          sut             = new Aggregate(identifier, expectedVersion, root);

            var result = sut.ToBuilder();

            Assert.That(result, Is.Not.Null);
            Assert.That(result.Identifier, Is.EqualTo(identifier));
            Assert.That(result.ExpectedVersion, Is.EqualTo(expectedVersion));
            Assert.That(result.Root, Is.SameAs(root));
        }
 public void SetUp()
 {
     _root = AggregateRootEntityStub.Factory();
     _unitOfWork = new UnitOfWork();
     _sut = new Repository<AggregateRootEntityStub>(
         () => _root,
         _unitOfWork,
         new FilledEventStreamReader(new Dictionary<string, IList<object>>
         {
             {Model.KnownIdentifier, new List<object>()}
         }));
 }
 public void SetUp()
 {
     _root = AggregateRootEntityStub.Factory();
     _unitOfWork = new UnitOfWork();
     _unitOfWork.Attach(new Aggregate(Model.KnownIdentifier, 0, _root));
     _sut = new Repository<AggregateRootEntityStub>(AggregateRootEntityStub.Factory, _unitOfWork,
                                                    new EmptyEventStreamReader());
 }
 public void SetUp()
 {
     _model = new Model();
     _root = AggregateRootEntityStub.Factory();
     _sut = new RepositoryScenarioBuilder().
         ScheduleAttachToUnitOfWork(new Aggregate(_model.KnownIdentifier, 0, _root)).
         BuildForRepository();
 }
 public void SetUp()
 {
     EmbeddedEventStore.Connection.DeleteAllStreams();
     _model = new Model();
     _root = AggregateRootEntityStub.Factory();
     _sut = new RepositoryScenarioBuilder().
         ScheduleAttachToUnitOfWork(new Aggregate(_model.KnownIdentifier, 0, _root)).
         BuildForRepository();
 }
Beispiel #19
0
 public void AddIdentifierCanNotBeNull()
 {
     Assert.Throws <ArgumentNullException>(() => _sut.Add(null, AggregateRootEntityStub.Factory()));
 }
Beispiel #20
0
 public WithEmptyStoreAndEmptyUnitOfWork()
 {
     _model = new Model();
     _root  = AggregateRootEntityStub.Factory();
 }