Ejemplo n.º 1
0
        public void CanSave_VersionOnly()
        {
            ComplexContainersItem item = new ComplexContainersItem();

            item.ID = 28;
            ComplexContainersItem version = item.Clone(false) as ComplexContainersItem;

            Expect.On(versioner).Call(versioner.AddVersion(item)).Return(version);
            versioner.Expect(v => v.TrimVersionCountTo(item, 100)).IgnoreArguments().Repeat.Any();
            versioner.Expect(v => v.IsVersionable(item)).Return(true);
            mocks.Replay(versioner);

            IItemEditor editor = SimulateEditor(item, ItemEditorVersioningMode.VersionOnly);

            DoTheSaving(CreatePrincipal("someone"), editor);

            Assert.That(persister.Repository.Get(28), Is.Null);

            Assert.AreEqual("", item.MyProperty0);
            Assert.AreEqual("", item.MyProperty1);
            Assert.AreEqual("", item.MyProperty2);
            Assert.AreEqual("", item.MyProperty3);
            Assert.IsFalse(item.MyProperty4);

            AssertItemHasValuesFromEditors(version);
        }
Ejemplo n.º 2
0
        public void CanSave_ItemAndVersion()
        {
            ComplexContainersItem item = new ComplexContainersItem();

            item.ID = 28;

            Expect.On(versioner).Call(versioner.AddVersion(item)).Return(item.Clone(false));
            versioner.Expect(v => v.TrimVersionCountTo(item, 100)).IgnoreArguments().Repeat.Any();
            versioner.Expect(v => v.IsVersionable(item)).Return(true);
            mocks.Replay(versioner);

            IItemEditor editor = SimulateEditor(item, ItemEditorVersioningMode.VersionAndSave);

            DoTheSaving(CreatePrincipal("someone"), editor);

            AssertItemHasValuesFromEditors(item);
        }
Ejemplo n.º 3
0
        public void SavingVersion_InvokesEvent()
        {
            savingVersionEventInvoked = false;
            ComplexContainersItem item = new ComplexContainersItem();

            item.ID = 29;

            Expect.On(versioner).Call(versioner.AddVersion(item)).Return(item.Clone(false));
            versioner.Expect(v => v.TrimVersionCountTo(item, 100)).IgnoreArguments().Repeat.Any();
            versioner.Expect(v => v.IsVersionable(item)).Return(true);
            mocks.Replay(versioner);

            editManager.SavingVersion += new EventHandler <CancellableItemEventArgs>(editManager_SavingVersion);
            IItemEditor editor = SimulateEditor(item, ItemEditorVersioningMode.VersionAndSave);

            DoTheSaving(CreatePrincipal("someone"), editor);

            Assert.IsTrue(savingVersionEventInvoked, "The saving version event wasn't invoked");
        }
		public void UpdateItemWithNoChangesIsNotSaved()
		{
			var item = new ComplexContainersItem
			{
				ID = 22,
				MyProperty0 = "one",
				MyProperty1 = "two",
				MyProperty2 = "three",
				MyProperty3 = "rock",
				MyProperty4 = true
			};

			Expect.On(versioner).Call(versioner.AddVersion(item)).Return(item.Clone(false));
			versioner.Expect(v => v.TrimVersionCountTo(item, 100)).IgnoreArguments().Repeat.Any();
			versioner.Expect(v => v.IsVersionable(item)).Return(true);
			mocks.Replay(versioner);

			var editor = SimulateEditor(item, ItemEditorVersioningMode.VersionAndSave);
			DoTheSaving(CreatePrincipal("someone"), editor);
			Assert.That(persister.Repository.Get(22), Is.Null);
		}