Ejemplo n.º 1
0
        public void RequiredValueWithInvalidValue()
        {
            RequiredFieldMapping <string> fieldMapping = new RequiredFieldMapping <string>("Field", () => "Default");

            Model model = new Model();

            ModelProperties <Model> modelProperties = new ModelProperties <Model>();

            string value;

            Assert.That(fieldMapping.TryResolveValue(modelProperties, model, out value), Is.True);
            Assert.That(value, Is.EqualTo("Default"));
        }
Ejemplo n.º 2
0
        public void ResolveValueWithDefaultValue()
        {
            string defaultValue = new Iso8601DateTimeConverter().ConvertToInvariantString(DateTime.UtcNow);
            RequiredFieldMapping <DateTime> fieldMapping = new RequiredFieldMapping <DateTime>("Sample", () => defaultValue);

            Model model = new Model {
                Id = 0
            };

            ModelProperties <Model> modelProperties = new ModelProperties <Model>();

            string value;

            Assert.That(fieldMapping.TryResolveValue(modelProperties, model, out value), Is.True);
            Assert.That(value, Is.EqualTo(defaultValue));
        }