Ejemplo n.º 1
0
        public void Test_Binding_NullToValueType_Throws()
        {
            RootModel model = new RootModel();
            Relation  rel   = DatabaseHelper.Default.Relation(model, "Complex.Value");

            IField value = rel.Scalar();

            Should.Throw <BindingException>(() => value.Bind(null));
        }
Ejemplo n.º 2
0
        public void Test_Binding_OfNonConvertibleValue_Throws()
        {
            RootModel model = new RootModel();
            Relation  rel   = DatabaseHelper.Default.Relation(model, "Complex.Value");

            IField value = rel.Scalar();

            Should.Throw <BindingException>(() => value.Bind("String"));
        }
Ejemplo n.º 3
0
        public void Test_Binding_WithContravariance()
        {
            RootModel model = new RootModel();
            Relation  rel   = DatabaseHelper.Default.Relation(model, "Object");

            IField value = rel.Scalar();

            Should.NotThrow(() => value.Bind(new RootModel()));
        }
Ejemplo n.º 4
0
        public void Test_Binding_ToMissing_Throws()
        {
            Model    model = new Model();
            Relation rel   = DatabaseHelper.Default.Relation(model, "Complex.Value");

            IField value = rel.Scalar();

            Should.Throw <BindingException>(() => value.Bind(10));
        }
Ejemplo n.º 5
0
        public void Test_Binding_ToNullValue()
        {
            RootModel model = new RootModel();
            Relation  rel   = DatabaseHelper.Default.Relation(model, "Complex");

            IField complex = rel.Scalar();

            complex.ShouldNotBeNull();

            Should.NotThrow(() => complex.Bind(new RootModel.SubModel()
            {
                Value = 10
            }));

            model.Complex.Value.ShouldBe(10);
        }
Ejemplo n.º 6
0
        public void Test_Binding_ToProperty()
        {
            RootModel model = new RootModel()
            {
                Complex = new RootModel.SubModel()
            };
            Relation rel = DatabaseHelper.Default.Relation(model, "Complex.Value");

            IField value = rel.Scalar();

            value.Bind(12);

            value.ShouldNotBeNull();
            value.Value.ShouldBe(12);
            model.Complex.Value.ShouldBe(12);
        }