コード例 #1
0
        public void CanUpdateEditors()
        {
            ComplexContainersItem item = new ComplexContainersItem();
            IDictionary<string, Control> added = AddEditors(item);

            TextBox tbp0 = added["MyProperty0"] as TextBox;
            TextBox tbp1 = added["MyProperty1"] as TextBox;
            TextBox tbp2 = added["MyProperty2"] as TextBox;
            FreeTextArea ftap3 = added["MyProperty3"] as FreeTextArea;
            CheckBox cbp4 = added["MyProperty4"] as CheckBox;

            Assert.IsEmpty(tbp0.Text);
            Assert.IsEmpty(tbp1.Text);
            Assert.IsEmpty(tbp2.Text);
            Assert.IsEmpty(ftap3.Text);
            Assert.IsFalse(cbp4.Checked);

            item.MyProperty0 = "one";
            item.MyProperty1 = "two";
            item.MyProperty2 = "three";
            item.MyProperty3 = "rock";
            item.MyProperty4 = true;

			editManager.UpdateEditors(definitions.GetDefinition(item.GetContentType()), item, added, CreatePrincipal("someone"));

            Assert.AreEqual("one", tbp0.Text);
            Assert.AreEqual("two", tbp1.Text);
            Assert.AreEqual("three", tbp2.Text);
            Assert.AreEqual("rock", ftap3.Text);
            Assert.IsTrue(cbp4.Checked);
        }
コード例 #2
0
ファイル: EditManagerTests.cs プロジェクト: JohnsonYuan/n2cms
 protected IDictionary<string, Control> AddEditors(ComplexContainersItem item)
 {
     Type itemType = item.GetContentType();
     Control editorContainer = new Control();
     IDictionary<string, Control> added = editManager.AddEditors(definitions.GetDefinition(itemType), item, editorContainer, CreatePrincipal("someone"));
     return added;
 }
コード例 #3
0
        public void UpdateItem_WithNoChanges_ReturnsFalse()
        {
            ComplexContainersItem item = new ComplexContainersItem();
            Type itemType = item.GetContentType();
            Control editorContainer = new Control();
            IDictionary<string, Control> added = editManager.AddEditors(definitions.GetDefinition(itemType), item, editorContainer, CreatePrincipal("someone"));

            item.MyProperty0 = "one";
            item.MyProperty1 = "two";
            item.MyProperty2 = "three";
            item.MyProperty3 = "rock";
            item.MyProperty4 = true;
            editManager.UpdateEditors(definitions.GetDefinition(item.GetContentType()), item, added, CreatePrincipal("someone"));

            var result = editManager.UpdateItem(definitions.GetDefinition(item.GetContentType()), item, added, null);

            Assert.IsFalse(result.Length > 0, "UpdateItem didn't return false even though the editors were unchanged.");
        }
コード例 #4
0
        public void UpdateItem_WithChanges_ReturnsTrue()
        {
            ComplexContainersItem item = new ComplexContainersItem();
            IDictionary<string, Control> added = AddEditors(item);

            TextBox tbp0 = added["MyProperty0"] as TextBox;
            TextBox tbp1 = added["MyProperty1"] as TextBox;
            TextBox tbp2 = added["MyProperty2"] as TextBox;
            FreeTextArea ftap3 = added["MyProperty3"] as FreeTextArea;
            CheckBox cbp4 = added["MyProperty4"] as CheckBox;

            tbp0.Text = "one";
            tbp1.Text = "two";
            tbp2.Text = "three";
            ftap3.Text = "rock";
            cbp4.Checked = true;

            var result = editManager.UpdateItem(definitions.GetDefinition(item.GetContentType()), item, added, CreatePrincipal("someone"));

            Assert.That(result.Length, Is.GreaterThan(0), "UpdateItem didn't return true even though the editors were changed.");
        }
コード例 #5
0
		public void CanUpdateItem()
		{
			ComplexContainersItem item = new ComplexContainersItem();
			IDictionary<string, Control> added = AddEditors(item);

			var tbp0 = added["MyProperty0"] as TextBox;
			var tbp1 = added["MyProperty1"] as TextBox;
			var tbp2 = added["MyProperty2"] as TextBox;
			var ftap3 = added["MyProperty3"] as FreeTextArea;
			var cbp4 = added["MyProperty4"] as CheckBox;

			Assert.That(tbp0 != null);
			Assert.That(tbp1 != null);
			Assert.That(tbp2 != null);
			Assert.That(ftap3 != null);
			Assert.That(cbp4 != null);

			Assert.IsEmpty(item.MyProperty0);
			Assert.IsEmpty(item.MyProperty1);
			Assert.IsEmpty(item.MyProperty2);
			Assert.IsEmpty(item.MyProperty3);
			Assert.IsFalse(item.MyProperty4);

			tbp0.Text = "one";
			tbp1.Text = "two";
			tbp2.Text = "three";
			ftap3.Text = "rock";
			cbp4.Checked = true;

			editManager.UpdateItem(definitions.GetDefinition(item.GetContentType()), item, added, CreatePrincipal("someone"));

			Assert.AreEqual("one", item.MyProperty0);
			Assert.AreEqual("two", item.MyProperty1);
			Assert.AreEqual("three", item.MyProperty2);
			Assert.AreEqual("rock", item.MyProperty3);
			Assert.IsTrue(item.MyProperty4);
		}
コード例 #6
0
		public void UpdateItemWithChangesReturnsTrue()
		{
			var item = new ComplexContainersItem();
			var added = AddEditors(item);

			var tbp0 = added["MyProperty0"] as TextBox;
			var tbp1 = added["MyProperty1"] as TextBox;
			var tbp2 = added["MyProperty2"] as TextBox;
			var ftap3 = added["MyProperty3"] as FreeTextArea;
			var cbp4 = added["MyProperty4"] as CheckBox;

			Assert.That(tbp0 != null, "tbp0 != null");
			Assert.That(tbp1 != null, "tbp1 != null");
			Assert.That(tbp2 != null, "tbp2 != null");
			Assert.That(ftap3 != null, "ftap3 != null");
			Assert.That(cbp4 != null, "cbp4 != null");
			tbp0.Text = "one";
			tbp1.Text = "two";
			tbp2.Text = "three";
			ftap3.Text = "rock";
			cbp4.Checked = true;

			var result = editManager.UpdateItem(definitions.GetDefinition(item.GetContentType()), item, added, CreatePrincipal("someone"));

			Assert.That(result.Length, Is.GreaterThan(0), "UpdateItem didn't return true even though the editors were changed.");
		}
コード例 #7
0
ファイル: EditManagerTests.cs プロジェクト: spmason/n2cms
 protected IDictionary<string, Control> AddEditors(ComplexContainersItem item)
 {
     Type itemType = item.GetContentType();
     Control editorContainer = new Control();
     IDictionary<string, Control> added = editManager.AddEditors(itemType, editorContainer, null);
     return added;
 }