Exemple #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));
        }
Exemple #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"));
        }
Exemple #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()));
        }
Exemple #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));
        }
Exemple #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);
        }
Exemple #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);
        }