public void TestThatGetSourceValueThrowsDeliveryEngineSystemExceptionIfGenericTargetTypeIsInvalid() { var fixture = new Fixture(); var fieldMock = MockRepository.GenerateMock <IField>(); var fieldData = new FieldData <int, string>(fieldMock, fixture.CreateAnonymous <int>()); Assert.That(fieldData, Is.Not.Null); Assert.Throws <DeliveryEngineSystemException>(() => fieldData.GetSourceValue <decimal>()); }
public void TestThatUpdateSourceValueCanSetSourceValueToNull() { var fixture = new Fixture(); var fieldMock = MockRepository.GenerateMock <IField>(); var fieldData = new FieldData <string, string>(fieldMock, fixture.CreateAnonymous <string>()); Assert.That(fieldData, Is.Not.Null); fieldData.UpdateSourceValue <object>(null); Assert.That(fieldData.GetSourceValue <string>(), Is.Null); }
public void TestThatGetSourceValueGetsTheSourceValue() { var fixture = new Fixture(); var fieldMock = MockRepository.GenerateMock <IField>(); var fieldData = new FieldData <int, string>(fieldMock, fixture.CreateAnonymous <int>()); Assert.That(fieldData, Is.Not.Null); var sourceValue = fieldData.GetSourceValue <int>(); Assert.That(sourceValue, Is.EqualTo(fieldData.SourceValue)); }
public void TestThatUpdateSourceValueCanSetNullableSourceValue() { var fixture = new Fixture(); var fieldMock = MockRepository.GenerateMock <IField>(); var fieldData = new FieldData <int?, int?>(fieldMock, fixture.CreateAnonymous <int>()); Assert.That(fieldData, Is.Not.Null); var newValue = fixture.CreateAnonymous <int>(); fieldData.UpdateSourceValue(newValue.ToString(CultureInfo.InvariantCulture)); Assert.That(fieldData.GetSourceValue <int?>(), Is.EqualTo(newValue)); }
public void TestThatUpdateSourceValueUpdatesSourceValueWithValueUsingToParse() { var fixture = new Fixture(); var fieldMock = MockRepository.GenerateMock <IField>(); var fieldData = new FieldData <int, string>(fieldMock, fixture.CreateAnonymous <int>()); Assert.That(fieldData, Is.Not.Null); var newValue = fixture.CreateAnonymous <int>().ToString(CultureInfo.InvariantCulture); fieldData.UpdateSourceValue(newValue); Assert.That(fieldData.GetSourceValue <int>(), Is.EqualTo(int.Parse(newValue))); }
public void TestThatUpdateSourceValueUpdatesSourceValueWithValueOfSameType() { var fixture = new Fixture(); var fieldMock = MockRepository.GenerateMock <IField>(); var fieldData = new FieldData <int, string>(fieldMock, fixture.CreateAnonymous <int>()); Assert.That(fieldData, Is.Not.Null); var newValue = fixture.CreateAnonymous <int>(); fieldData.UpdateSourceValue(newValue); Assert.That(fieldData.GetSourceValue <int>(), Is.EqualTo(newValue)); }