public void UpdateThrows_ChangeSetStillReturned()
        {
            TestProvider_Scenarios provider = new TestProvider_Scenarios(TestURIs.TestProvider_Scenarios);

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

            this.EnqueueCompletion(() => lo);
            EnqueueCallback(delegate
            {
                Assert.IsNull(lo.Error);
                Assert.IsTrue(lo.Entities.Count() > 0);
                A entity = provider.As.First();
                entity.BID1++;
                so = provider.SubmitChanges(TestHelperMethods.DefaultOperationAction, null);
            });
            this.EnqueueCompletion(() => so);
            EnqueueCallback(delegate
            {
                Assert.IsNotNull(so.Error);
                Assert.AreEqual(Resource.DomainContext_SubmitOperationFailed_Validation, so.Error.Message);
                Assert.IsNotNull(so.ChangeSet);
                Assert.AreEqual(1, so.ChangeSet.ModifiedEntities.Count);
            });
            EnqueueTestComplete();
        }
        public void DomainContext_Load_SelectMethodThrows()
        {
            TestProvider_Scenarios provider = new TestProvider_Scenarios(TestURIs.TestProvider_Scenarios);

            LoadOperation lo = provider.Load(provider.GetMixedTypesThrowQuery(), false);

            this.EnqueueCompletion(() => lo);
            EnqueueCallback(delegate
            {
                Assert.IsNotNull(lo.Error);

                // verify we propagate the top level exception message as well
                // as the inner exception message (to one level deep)
                Assert.IsTrue(lo.Error.Message.Contains("Not implemented yet."));
                Assert.IsTrue(lo.Error.Message.Contains("InnerException1"));
                Assert.IsFalse(lo.Error.Message.Contains("InnerException2"));
            });

            EnqueueTestComplete();
        }
        private void ExecuteQuery(Func <TestProvider_Scenarios, EntityQuery <CityWithCacheData> > getQuery, string expectedCacheData)
        {
            LoadOperation <CityWithCacheData> loadOp = null;

            EnqueueCallback(delegate
            {
                TestProvider_Scenarios dc = new TestProvider_Scenarios(TestURIs.TestProvider_Scenarios);
                loadOp = dc.Load(getQuery(dc));
            });

            EnqueueConditional(() => loadOp.IsComplete);
            EnqueueCallback(delegate
            {
                if (loadOp.Error != null)
                {
                    Assert.Fail(loadOp.Error.ToString());
                }

                CityWithCacheData city = loadOp.Entities.First();
                Assert.AreEqual(expectedCacheData, city.CacheData, "Incorrect cache data");
            });
        }
Example #4
0
        [FullTrustTest] // ISerializable types cannot be deserialized in medium trust.
        public void InvokeOperationParams_TestNullable()
        {
            InvokeOperation <bool> invoke   = null;
            TestProvider_Scenarios provider = new TestProvider_Scenarios(TestURIs.TestProvider_Scenarios);
            MixedType changedObj            = null;
            MixedType valuesObj             = null;

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

            // wait for Load to complete, then invoke some domain methods
            EnqueueConditional(() => lo.IsComplete);

            EnqueueCallback(delegate
            {
                changedObj = provider.MixedTypes.Single(t => (t.ID == "MixedType_Max"));
                valuesObj  = provider.MixedTypes.Single(t => (t.ID == "MixedType_Other"));

                // invoke invoke operation
                invoke = provider.TestNullable_Online(changedObj, valuesObj.NullableBooleanProp, valuesObj.NullableByteProp, valuesObj.NullableSByteProp,
                                                      valuesObj.NullableInt16Prop, valuesObj.NullableUInt16Prop, valuesObj.NullableInt32Prop, valuesObj.NullableUInt32Prop,
                                                      valuesObj.NullableInt64Prop, valuesObj.NullableUInt64Prop, valuesObj.NullableCharProp, valuesObj.NullableDoubleProp,
                                                      valuesObj.NullableSingleProp, valuesObj.NullableDecimalProp, valuesObj.NullableDateTimeProp,
                                                      valuesObj.NullableTimeSpanProp, valuesObj.NullableGuidProp, valuesObj.NullableEnumProp,
                                                      valuesObj.NullableTimeSpanListProp, valuesObj.NullableDateTimeOffsetProp, TestHelperMethods.DefaultOperationAction, null);
            });

            EnqueueConditional(() => invoke.IsComplete);
            EnqueueCallback(delegate
            {
                // verify invocation completed succesfully
                Assert.IsNull(invoke.Error, "InvokeEventArgs.Error should be null");
                Assert.IsFalse(invoke.ValidationErrors.Any());

                Assert.IsTrue(invoke.Value);
            });

            EnqueueTestComplete();
        }
Example #5
0
        [FullTrustTest] // ISerializable types cannot be deserialized in medium trust.
        public void InvokeOperationParams_TestPrimitive()
        {
            TestProvider_Scenarios provider = new TestProvider_Scenarios(TestURIs.TestProvider_Scenarios);
            MixedType changedObj            = null;
            MixedType valuesObj             = null;
            InvokeOperation <bool> invoke   = null;
            LoadOperation          lo       = provider.Load(provider.GetMixedTypesQuery(), false);

            // wait for Load to complete, then invoke some domain methods
            EnqueueConditional(() => lo.IsComplete);

            EnqueueCallback(delegate
            {
                changedObj = provider.MixedTypes.Single(t => (t.ID == "MixedType_Max"));
                valuesObj  = provider.MixedTypes.Single(t => (t.ID == "MixedType_Other"));

                // invoke invoke operation
                invoke = provider.TestPrimitive_Online(changedObj, valuesObj.BooleanProp, valuesObj.ByteProp, valuesObj.SByteProp,
                                                       valuesObj.Int16Prop, valuesObj.UInt16Prop, valuesObj.Int32Prop, valuesObj.UInt32Prop, valuesObj.Int64Prop,
                                                       valuesObj.UInt64Prop, valuesObj.CharProp, valuesObj.DoubleProp, valuesObj.SingleProp, TestHelperMethods.DefaultOperationAction, null);
            });

            EnqueueConditional(() => invoke.IsComplete);
            EnqueueCallback(delegate
            {
                // verify invocation completed succesfully
                Assert.IsNull(invoke.Error);
                Assert.IsFalse(invoke.ValidationErrors.Any());

                Assert.IsTrue(invoke.Value);

                // verify the entity we passed as the invoke operation param is not changed on the client
                Assert.AreEqual(255, changedObj.ByteProp);
            });

            EnqueueTestComplete();
        }
Example #6
0
        [FullTrustTest] // ISerializable types cannot be deserialized in medium trust.
        public void InvokeOperationParams_TestPredefined()
        {
            InvokeOperation <bool> invoke   = null;
            TestProvider_Scenarios provider = new TestProvider_Scenarios(TestURIs.TestProvider_Scenarios);
            MixedType changedObj            = null;
            MixedType valuesObj             = null;

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

            // wait for Load to complete, then invoke some domain methods
            EnqueueConditional(() => lo.IsComplete);

            EnqueueCallback(delegate
            {
                changedObj = provider.MixedTypes.Single(t => (t.ID == "MixedType_Max"));
                valuesObj  = provider.MixedTypes.Single(t => (t.ID == "MixedType_Other"));

                // invoke invoke operation
                invoke = provider.TestPredefined_Online(changedObj, valuesObj.StringProp, valuesObj.DecimalProp,
                                                        valuesObj.DateTimeProp, valuesObj.TimeSpanProp, valuesObj.StringsProp, valuesObj.UriProp,
                                                        valuesObj.GuidProp, valuesObj.BinaryProp, valuesObj.XElementProp, valuesObj.ByteArrayProp,
                                                        valuesObj.EnumProp, valuesObj.GuidsProp, valuesObj.UInt64sProp, valuesObj.DateTimeOffsetProp, TestHelperMethods.DefaultOperationAction, null);
            });

            EnqueueConditional(() => invoke.IsComplete);
            EnqueueCallback(delegate
            {
                // verify invocation completed succesfully
                Assert.IsNull(invoke.Error);
                Assert.IsFalse(invoke.ValidationErrors.Any());

                Assert.IsTrue(invoke.Value);
            });

            EnqueueTestComplete();
        }