public void CreateNewOrderCommandCanMutateCopiedValues() { var expectedOrderId = "overwritten"; var source = new TestEvent { 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"); }
public void CreateNewOrderCommandWithMutator() { var newCommandName = "Event Name"; var source = new TestEvent { 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"); }