public void UsingConstructorWithPartitionReturnsInstanceWithExpectedProperties(
            [ValueSource(typeof (AggregateTestsValueSource), "IdSource")] string identifier,
            [Values(Int32.MinValue, -1, 0, 1, Int32.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));
        }
        public void UsingConstructorWithoutPartitionReturnsInstanceWithExpectedProperties(
            [ValueSource(typeof(AggregateTestsValueSource), "IdSource")] string identifier,
            [Values(long.MinValue, -1, 0, 1, long.MaxValue)] long 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));
        }
        public void UsingDefaultConstructorReturnsInstanceWithExpectedProperties(
            [ValueSource(typeof(AggregateTestsValueSource), "IdSource")] string identifier,
            [Values(Int32.MinValue, -1, 0, 1, Int32.MaxValue)] int version)
        {
            var root = AggregateRootEntityStub.Factory();
            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));
        }
        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 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 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 void BuildReturnsExpectedResult()
        {
            var sut = new AggregateBuilder();
            const string identifier = "identifier";
            const int expectedVersion = 123;
            var root = new AggregateRootEntityStub();

            var result = sut.IdentifiedBy(identifier).ExpectVersion(expectedVersion).WithRoot(root).Build();

            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));
        }
Example #8
0
        public void BuildReturnsExpectedResult()
        {
            var          sut             = new AggregateBuilder();
            const string identifier      = "identifier";
            const int    expectedVersion = 123;
            var          root            = new AggregateRootEntityStub();
            const string partition       = "partition";

            var result = sut.IdentifiedBy(identifier).ExpectVersion(expectedVersion).WithRoot(root).InPartition(partition).Build();

            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));
            Assert.That(sut.Partition, Is.EqualTo(partition));
        }
        public void ToBuilderReturnsExpectedResult()
        {
            const string partition = "partition";
            const string identifier = "identifier";
            const int expectedVersion = 123;
            var root = new AggregateRootEntityStub();
            var sut = new Aggregate(partition, 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));
            Assert.That(result.Partition, Is.EqualTo(partition));
        }
 public void IdentifierCanNotBeNull()
 {
     Assert.
     Throws <ArgumentNullException>(
         () => new Aggregate(null, 0, AggregateRootEntityStub.Factory()));
 }