public void CancelSubmit_EmptyChangeset()
        {
            Northwind nw = new Northwind(TestURIs.LTS_Northwind);
            SubmitOperation so = null;

            this.EnqueueCallback(() =>
            {
                so = nw.SubmitChanges();
                if (so.CanCancel)
                {
                    so.Cancel();
                }
            });
            this.EnqueueConditional(() => so.IsComplete);
            this.EnqueueCallback(() =>
            {
                Assert.IsNull(so.Error);
            });
            this.EnqueueTestComplete();
        }
        public void EmptyChangeSet_SubmitChanges()
        {
            Northwind ctxt = new Northwind(TestURIs.LTS_Northwind_CUD);
            
            SubmitOperation so = ctxt.SubmitChanges(TestHelperMethods.DefaultOperationAction, null);
            EnqueueConditional(delegate
            {
                return so.IsComplete;
            });
            EnqueueCallback(delegate
            {
                Assert.IsFalse(so.HasError);
                Assert.IsNull(so.Error);
                Assert.IsTrue(so.ChangeSet.IsEmpty);
            });

            EnqueueTestComplete();
        }
        public void UncommitedEntityEdits()
        {
            Northwind ctxt = new Northwind(TestURIs.LTS_Northwind);
            Product prod = new Product
            {
                ProductID = 1,
                ProductName = "Cheezy Tots"
            };
            ctxt.EntityContainer.LoadEntities(new Entity[] { prod });

            // start an edit session and calculate
            // changes w/o ending the session
            IEditableObject eo = (IEditableObject)prod;
            eo.BeginEdit();
            prod.ProductName = "Chikn Crisps";
            Assert.IsTrue(prod.HasChanges);
            Assert.IsTrue(prod.IsEditing);
            EntityChangeSet cs = ctxt.EntityContainer.GetChanges();
            Assert.AreEqual(1, cs.ModifiedEntities.Count);

            // however, attempting to call submit will result in
            // an exception
            ExceptionHelper.ExpectInvalidOperationException(delegate
            {
                ctxt.SubmitChanges(TestHelperMethods.DefaultOperationAction, null);
            }, string.Format(Resource.Entity_UncommittedChanges, prod));

            // end the session
            eo.EndEdit();
            Assert.IsFalse(prod.IsEditing);
            cs = ctxt.EntityContainer.GetChanges();
            Assert.AreEqual(1, cs.ModifiedEntities.Count);
        }
        public void Bug635474_IsSubmittingStateManagement()
        {
            Northwind nw = new Northwind(TestURIs.LTS_Northwind);
            Product prod = new Product
            {
                ProductID = 1,
                ProductName = "Tasty O's"
            };
            nw.Products.Attach(prod);

            // verify that IsSubmitting is reset when the submit
            // is cancelled
            prod.ProductName += "x";
            SubmitOperation so = nw.SubmitChanges(TestHelperMethods.DefaultOperationAction, null);
            so.Cancel();
            Assert.IsFalse(nw.IsSubmitting);
        }