Ejemplo n.º 1
0
        public void CreateNewOrderCommandCanMutateCopiedValues()
        {
            var expectedOrderId = "overwritten";

            var source = new TestCommand
            {
                Id              = Guid.NewGuid(),
                CorrelationId   = "ABC123",
                CurrentUser     = "******",
                OccurredTimeUtc = DateTime.UtcNow.Subtract(TimeSpan.FromMinutes(1)),
                PartnerCode     = "UnitTest",
                OrderId         = "Order123",
                Name            = "Command Name"
            };

            var created = source.CreateNewOrderCommand <TestCommand>(e => e.OrderId = expectedOrderId);

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

            created.PartnerCode.Should().Be(source.PartnerCode, "because the current partner code should be copied");
            created.OrderId.Should().Be(expectedOrderId, "because the current order identifier should be mutated");
        }
Ejemplo n.º 2
0
        public void CreateNewOrderCommandWithMutator()
        {
            var newCommandName = "Event Name";

            var source = new TestCommand
            {
                Id              = Guid.NewGuid(),
                CorrelationId   = "ABC123",
                CurrentUser     = "******",
                OccurredTimeUtc = DateTime.UtcNow.Subtract(TimeSpan.FromMinutes(1)),
                PartnerCode     = "UnitTest",
                OrderId         = "Order123",
                Name            = "Command Name"
            };

            var created = source.CreateNewOrderCommand <TestCommand>(e => e.Name = newCommandName);

            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");
            created.PartnerCode.Should().Be(source.PartnerCode, "because the current partner code should be copied");
            created.OrderId.Should().Be(source.OrderId, "because the current order identifier should be copied");

            // Verify mutator values were set.

            created.Name.Should().Be(newCommandName, "because the mutator values should be set");
        }