Esempio n. 1
0
        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>());
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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));
        }
Esempio n. 4
0
        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));
        }
Esempio n. 5
0
        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)));
        }
Esempio n. 6
0
        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));
        }