public void When_command_is_null_then_mapper_throws_ArgumentNullException() { ChangeCustomerInfo change = null; Action callMapperWithNull = () => New <Order.CustomerInfoChanged> .From(change); callMapperWithNull.ShouldThrow <ArgumentNullException>(); }
public void EnactCommand(ChangeCustomerInfo command) { RecordEvent(new CustomerInfoChanged { CustomerName = command.CustomerName, Address = command.Address, PhoneNumber = command.PhoneNumber, PostalCode = command.PostalCode, RegionOrCountry = command.RegionOrCountry }); }
public void Set_Optional_parameters_are_included_in_json_during_serialization() { var json = new ChangeCustomerInfo { CustomerName = "joe", Address = "100 Main St." }.ToJson(); var command = json.FromJsonTo <ChangeCustomerInfo>(); command.CustomerName.Should().Be("joe"); command.Address.Value.Should().Be("100 Main St."); command.Address.IsSet.Should().BeTrue(); command.PostalCode.IsSet.Should().BeFalse(); command.RegionOrCountry.IsSet.Should().BeFalse(); }
public void Unset_Optional_properties_are_not_included_in_json_during_serialization() { var info = new ChangeCustomerInfo { CustomerName = "joe", PostalCode = "12345", PhoneNumber = Optional <string> .Unset, // both of these properties are optional and excluded // not setting Address at all // both of these properties are optional and excluded }; info.Address.IsSet.Should().BeFalse(); info.PhoneNumber.IsSet.Should().BeFalse(); var json = info.ToJson(); json.Should().NotContain("PhoneNumber"); json.Should().NotContain("Address"); }
public void New_maps_custom_properties_from_command_to_event() { var change = new ChangeCustomerInfo { Address = Any.Paragraph(), CustomerName = Any.Paragraph(2), PhoneNumber = Any.String(10, characterSet: Characters.Digits), PostalCode = Any.String(5, characterSet: Characters.Digits), RegionOrCountry = "U.S." }; var changed = New<Order.CustomerInfoChanged>.From(change); changed.Address.Should().Be(change.Address); changed.CustomerName.Should().Be(change.CustomerName); changed.PhoneNumber.Should().Be(change.PhoneNumber); changed.PostalCode.Should().Be(change.PostalCode); changed.RegionOrCountry.Should().Be(change.RegionOrCountry); }
public void New_maps_custom_properties_from_command_to_event() { var change = new ChangeCustomerInfo { Address = Any.Paragraph(), CustomerName = Any.Paragraph(2), PhoneNumber = Any.String(10, characterSet: Characters.Digits), PostalCode = Any.String(5, characterSet: Characters.Digits), RegionOrCountry = "U.S." }; var changed = New <Order.CustomerInfoChanged> .From(change); changed.Address.Should().Be(change.Address); changed.CustomerName.Should().Be(change.CustomerName); changed.PhoneNumber.Should().Be(change.PhoneNumber); changed.PostalCode.Should().Be(change.PostalCode); changed.RegionOrCountry.Should().Be(change.RegionOrCountry); }