コード例 #1
0
        [FullTrustTest] // ISerializable types cannot be deserialized in medium trust.
        public void DomainMethod_NullablePredefinedTypes()
        {
            TestProvider_Scenarios provider = new TestProvider_Scenarios(TestURIs.TestProvider_Scenarios);
            MixedType changedObj = null;
            MixedType valuesObj = null;

            SubmitOperation so = null;
            LoadOperation lo = provider.Load(provider.GetMixedTypesQuery(), false);

            // wait for Load to complete, then invoke some domain methods
            EnqueueConditional(() => lo.IsComplete);
            EnqueueCallback(delegate
            {
                Assert.AreEqual(3, lo.Entities.Count(), "Entities count should be 3");
                changedObj = provider.MixedTypes.Single(t => t.ID == "MixedType_Max");
                valuesObj = provider.MixedTypes.Single(t => t.ID == "MixedType_Other");

                // invoke domain method on changedObj with values from valuesObj
                changedObj.TestNullablePredefined(valuesObj.NullableDecimalProp, valuesObj.NullableDateTimeProp,
                    valuesObj.NullableTimeSpanProp, valuesObj.NullableGuidProp, valuesObj.NullableEnumProp, valuesObj.NullableDateTimeOffsetProp);

                // submit
                so = provider.SubmitChanges(TestHelperMethods.DefaultOperationAction, null);
            });

            // wait for submitted event being fired and verify invoked entities in changeset
            EnqueueConditional(() => so.IsComplete);
            EnqueueCallback(delegate
            {
                Assert.IsNull(so.Error);

                // verify values of changedObj are now the same as valuesObj
                Assert.AreNotEqual(valuesObj.ID, changedObj.ID);
                Assert.AreEqual(valuesObj.NullableDateTimeProp, changedObj.NullableDateTimeProp);
                Assert.AreEqual(valuesObj.NullableTimeSpanProp, changedObj.NullableTimeSpanProp);
                Assert.AreEqual(valuesObj.NullableDecimalProp, changedObj.NullableDecimalProp);
                Assert.AreEqual(valuesObj.NullableGuidProp, changedObj.NullableGuidProp);
                Assert.AreEqual(valuesObj.NullableEnumProp, changedObj.NullableEnumProp);
                Assert.AreEqual(valuesObj.NullableDateTimeOffsetProp, changedObj.NullableDateTimeOffsetProp);
            });

            EnqueueTestComplete();
        }
コード例 #2
0
        [FullTrustTest] // ISerializable types cannot be deserialized in medium trust.
        public void DomainMethod_NullableTypes_NullParams()
        {
            TestProvider_Scenarios provider = new TestProvider_Scenarios(TestURIs.TestProvider_Scenarios);
            MixedType obj1 = null;
            MixedType obj2 = null;

            SubmitOperation so = null;
            LoadOperation lo = provider.Load(provider.GetMixedTypesQuery(), false);

            // wait for Load to complete, then invoke some domain methods
            EnqueueConditional(() => lo.IsComplete);
            EnqueueCallback(delegate
            {
                Assert.AreEqual(3, lo.Entities.Count(), "Entities count should be 3");
                obj1 = provider.MixedTypes.Single(t => t.ID == "MixedType_Min");
                obj2 = provider.MixedTypes.Single(t => t.ID == "MixedType_Other");

                // invoke domain methods with null values
                obj1.TestNullablePrimitive(null, null, null, null, null, null, null, null, null, null, null, null);
                obj2.TestNullablePredefined(null, null, null, null, null, null);

                // submit
                so = provider.SubmitChanges(TestHelperMethods.DefaultOperationAction, null);
            });

            // wait for submitted event being fired and verify invoked entities in changeset
            EnqueueConditional(() => so.IsComplete);
            EnqueueCallback(delegate
            {
                Assert.IsNull(so.Error);

                // verify values of obj1 and obj2
                Assert.IsNull(obj1.NullableBooleanProp);
                Assert.IsNull(obj1.NullableByteProp);
                Assert.IsNull(obj1.NullableSByteProp);
                Assert.IsNull(obj1.NullableInt16Prop);
                Assert.IsNull(obj1.NullableUInt16Prop);
                Assert.IsNull(obj1.NullableInt32Prop);
                Assert.IsNull(obj1.NullableUInt32Prop);
                Assert.IsNull(obj1.NullableInt64Prop);
                Assert.IsNull(obj1.NullableUInt64Prop);
                Assert.IsNull(obj1.NullableCharProp);
                Assert.IsNull(obj1.NullableDoubleProp);
                Assert.IsNull(obj1.NullableSingleProp);
                Assert.IsNotNull(obj1.NullableDateTimeProp);

                Assert.IsNull(obj2.NullableDateTimeProp);
                Assert.IsNull(obj2.NullableTimeSpanProp);
                Assert.IsNull(obj2.NullableDecimalProp);
                Assert.IsNull(obj2.NullableGuidProp);
                Assert.IsNull(obj2.NullableEnumProp);
                Assert.IsNotNull(obj2.NullableBooleanProp);
                Assert.IsNull(obj2.NullableDateTimeOffsetProp);
            });

            EnqueueTestComplete();
        }
コード例 #3
0
        [FullTrustTest] // ISerializable types cannot be deserialized in medium trust.
        public void DomainMethod_PredefinedTypes()
        {
            TestProvider_Scenarios provider = new TestProvider_Scenarios(TestURIs.TestProvider_Scenarios);
            MixedType changedObj = null;
            MixedType valuesObj = null;

            SubmitOperation so = null;
            LoadOperation lo = provider.Load(provider.GetMixedTypesQuery(), false);

            // wait for Load to complete, then invoke some domain methods
            EnqueueConditional(() => lo.IsComplete);
            EnqueueCallback(delegate
            {
                Assert.AreEqual(3, lo.Entities.Count(), "Entities count should be 3");
                changedObj = provider.MixedTypes.Single(t => t.ID == "MixedType_Max");
                valuesObj = provider.MixedTypes.Single(t => t.ID == "MixedType_Other");

                // invoke domain method on changedObj with values from valuesObj
                changedObj.TestPredefined(valuesObj.StringProp, valuesObj.DecimalProp, valuesObj.DateTimeProp,
                    valuesObj.TimeSpanProp, valuesObj.StringsProp, valuesObj.UriProp, valuesObj.GuidProp, valuesObj.BinaryProp,
                    /*valuesObj.XElementProp,*/ valuesObj.ByteArrayProp, valuesObj.EnumProp, valuesObj.DictionaryStringProp, valuesObj.DateTimeOffsetProp);

                // submit
                so = provider.SubmitChanges(TestHelperMethods.DefaultOperationAction, null);
            });

            // wait for submitted event being fired and verify invoked entities in changeset
            EnqueueConditional(() => so.IsComplete);
            EnqueueCallback(delegate
            {
                Assert.IsNull(so.Error);

                // verify values of changedObj are now the same as valuesObj
                Assert.AreNotEqual(valuesObj.ID, changedObj.ID);
                Assert.AreEqual(valuesObj.StringProp, changedObj.StringProp);
                Assert.AreEqual(valuesObj.DateTimeProp, changedObj.DateTimeProp);
                Assert.AreEqual(valuesObj.TimeSpanProp, changedObj.TimeSpanProp);
                Assert.AreEqual(valuesObj.DecimalProp, changedObj.DecimalProp);
                Assert.AreEqual(valuesObj.UriProp, changedObj.UriProp);
                Assert.AreEqual(valuesObj.GuidProp, changedObj.GuidProp);
                Assert.AreEqual(valuesObj.ByteArrayProp.Length, changedObj.ByteArrayProp.Length);
                Assert.AreEqual(123, changedObj.BinaryProp[2]);
                Assert.AreEqual(valuesObj.BinaryProp.Length, changedObj.BinaryProp.Length);
                //Assert.AreEqual(valuesObj.XElementProp.Value, changedObj.XElementProp.Value);
                //Assert.AreEqual("<someElement>element text</someElement>", changedObj.XElementProp.ToString());
                Assert.AreEqual(valuesObj.EnumProp, changedObj.EnumProp);
                Assert.AreEqual(valuesObj.DictionaryStringProp.Count, changedObj.DictionaryStringProp.Count);
                Assert.IsTrue(valuesObj.DictionaryStringProp.Keys.SequenceEqual(changedObj.DictionaryStringProp.Keys));
                Assert.AreEqual(valuesObj.DateTimeOffsetProp, changedObj.DateTimeOffsetProp);
            });

            EnqueueTestComplete();
        }