Beispiel #1
0
        public void raises_concurrency_issue()
        {
            var aggregate = new SimpleEventSourcedRoot();
            var result    = aggregate.Must().HaveVersion(1);

            result.Should().BeInvalid().WithMessage(ConcurrencyIssue.VersionMismatch(1, 0));
        }
Beispiel #2
0
        public void guards_expected_version()
        {
            var aggregate = new SimpleEventSourcedRoot();
            var result    = aggregate.Must().HaveVersion(0);

            result.Should().BeValid().WithoutMessages();
        }
        public void as_uncommitted_to_the_buffer()
        {
            var origin  = new SimpleEventSourcedRoot();
            var updated = origin.SetName("Jimi Hendrix").Should().BeValid().Value;

            updated.Buffer.Uncommitted.Should().ContainSingle();
        }
        public void with_origin_unchanged()
        {
            var origin = new SimpleEventSourcedRoot();

            origin.SetName("Jimi Hendrix");
            var updated = origin.SetName("Jimi Hendrix").Should().BeValid().Value;

            origin.Name.Should().BeNull();
            updated.Name.Should().Be("Jimi Hendrix");
        }
        public void changes_for_single_event()
        {
            var origin  = new SimpleEventSourcedRoot();
            var updated = origin.SetName("Jimi Hendrix").Should().BeValid().Value;

            updated.Name.Should().Be("Jimi Hendrix");
            updated.Buffer.Uncommitted.Should().BeEquivalentTo(new[] { new NameUpdated {
                                                                           Name = "Jimi Hendrix"
                                                                       } });
        }
        public void changes_for_multiple_events()
        {
            var origin  = new SimpleEventSourcedRoot();
            var updated = origin.SetPerson("Jimi Hendrix", new Date(1942, 11, 27)).Should().BeValid().Value;

            updated.Buffer.Uncommitted.Should().BeEquivalentTo(new object[]
            {
                new NameUpdated {
                    Name = "Jimi Hendrix"
                },
                new DateOfBirthUpdated {
                    DateOfBirth = new Date(1942, 11, 27)
                },
            });
        }