예제 #1
0
        public void When_EditableRoot_is_Saved_Then_we_receive_an_object_back_that_is_Marked_as_NotNew_NotDirty()
        {
            var context = GetContext();
            var root    = new MockEditableRoot(MockEditableRoot.MockEditableRootId, false);

            root.Name   = "justin";
            root.Saved += (o, e) =>
            {
                var actual = (MockEditableRoot)e.NewObject;
                context.Assert.IsNotNull(actual);
                context.Assert.AreEqual(MockEditableRoot.MockEditableRootId, actual.Id);
                context.Assert.IsFalse(actual.IsNew);
                context.Assert.IsFalse(actual.IsDirty);
                context.Assert.AreEqual("update", actual.DataPortalMethod);
                context.Assert.Success();
            };

            //State prior to saved
            context.Assert.IsFalse(root.IsNew);
            context.Assert.IsTrue(root.IsDirty);

            root.BeginSave();

            context.Complete();
        }
예제 #2
0
        public void If_EditableRoot_IsDeleted_Then_Saved_Returns_New_Dirty_Instance_of_Root_That_is_no_longer_marked_Deleted()
        {
            var context = GetContext();
            var root    = new MockEditableRoot(MockEditableRoot.MockEditableRootId, false);

            root.Saved += (o, e) =>
            {
                var actual = (MockEditableRoot)e.NewObject;
                context.Assert.IsNotNull(actual);
                context.Assert.IsTrue(actual.IsNew);
                context.Assert.IsTrue(actual.IsDirty);
                context.Assert.IsFalse(actual.IsDeleted);
                context.Assert.AreEqual("delete", actual.DataPortalMethod);
                context.Assert.Success();
            };
            root.Delete();
            //state prior to save()
            context.Assert.IsFalse(root.IsNew);
            context.Assert.IsTrue(root.IsDirty);
            context.Assert.IsTrue(root.IsDeleted);


            root.BeginSave();

            context.Complete();
        }
예제 #3
0
        public void TestUpdate()
        {
            UnitTestContext  context = GetContext();
            MockEditableRoot root    = new MockEditableRoot(MockEditableRoot.MockEditableRootId, false);

            root.Name   = "justin";
            root.Saved += (o, e) =>
            {
                var actual = (MockEditableRoot)e.NewObject;
                context.Assert.AreEqual(MockEditableRoot.MockEditableRootId, actual.Id);
                context.Assert.IsFalse(actual.IsNew);
                context.Assert.IsFalse(actual.IsDirty);
                context.Assert.AreEqual("update", actual.DataPortalMethod);
                context.Assert.Success();
            };
#if SILVERLIGHT
            root.BeginSave((o1, e1) => { context.Assert.IsNull(e1.Error); });
#else
            root.Save();
#endif
            context.Complete();
        }
예제 #4
0
        public void When_New_EditableRoot_is_Saved_Then_returned_object_isMarked_NotNew_NotDirty()
        {
            var context = GetContext();
            var root    = new MockEditableRoot(MockEditableRoot.MockEditableRootId, true);

            root.Name   = "justin";
            root.Saved += (o, e) =>
            {
                if (e.Error != null)
                {
                    context.Assert.Fail();
                }
                var actual = (MockEditableRoot)e.NewObject;
                context.Assert.IsNotNull(actual);
                context.Assert.AreEqual(MockEditableRoot.MockEditableRootId, actual.Id);
                context.Assert.IsFalse(actual.IsNew);
                context.Assert.IsFalse(actual.IsDirty);
                context.Assert.AreEqual("insert", actual.DataPortalMethod);
                context.Assert.Success();
            };
            root.BeginSave();

            context.Complete();
        }