Пример #1
0
        public void CreateNewCommandFromEventSourceWithNoMutator()
        {
            var source = new TestEvent
            {
                Id              = Guid.NewGuid(),
                CorrelationId   = "ABC123",
                CurrentUser     = "******",
                OccurredTimeUtc = DateTime.UtcNow.Subtract(TimeSpan.FromMinutes(1)),
                Name            = "EventName",
                Age             = 15
            };

            var created = source.CreateNewCommand <TestCommand>();

            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");
        }