Exemple #1
0
        public void CreateNewEventFromCommandSourceWithNoMutator()
        {
            var source = new TestCommand
            {
                Id              = Guid.NewGuid(),
                CorrelationId   = "ABC123",
                CurrentUser     = "******",
                OccurredTimeUtc = DateTime.UtcNow.Subtract(TimeSpan.FromMinutes(1)),
                Name            = "Command Name"
            };

            var created = source.CreateNewEvent <TestEvent>();

            created.Should().NotBeNull("because the created instance should exist");

            // Verify new values are populated.

            created.Id.Should().NotBe(source.Id, "because the id should be a new value");
            created.Id.Should().NotBe(default(Guid), "because the id should be populated");
            created.OccurredTimeUtc.Should().NotBe(source.OccurredTimeUtc, "because the occurred time should be a new value");
            created.OccurredTimeUtc.Should().NotBe(default(DateTime), "because the occurred time should be populated");

            // Verify copied values are copied.

            created.CorrelationId.Should().Be(source.CorrelationId, "because the correlation identifier should be copied");
            created.CurrentUser.Should().Be(source.CurrentUser, "because the current user should be copied");

            // Verify non-base values were not set.

            created.Name.Should().Be(default(string), "because non-base values should not be set");
            created.Age.Should().Be(default(int), "because non-base values should not be set");
        }