Пример #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>());
        }
Пример #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);
        }
Пример #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));
        }
Пример #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));
        }
Пример #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)));
        }
Пример #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));
        }