Example #1
0
        public void MapToOriginalEntityGuidAsId()
        {
            //Arrange
            //See ctor

            //Act
            var entity = UModelMapper.MapToEntity <TestClassGuid>(this._uModel, Bootstrap.Config <TestClassGuid>());

            //Assert
            Assert.AreEqual(this._testClass.Id, entity.Id);
            Assert.AreEqual(this._testClass.Name, entity.Name);

            Assert.AreEqual(this._testClass.Summary, entity.Summary);
            Assert.AreEqual(this._testClass.Boolean, entity.Boolean);
            Assert.AreEqual(this._testClass.Dropdown, entity.Dropdown);
        }
Example #2
0
        public void MapToUModelContent()
        {
            //Arrange
            //See ctor

            //Act
            var uModel = UModelMapper.MapToUModel(Bootstrap.Config <TestClassGuid>(), this._testClass);

            //Assert
            Assert.AreEqual(1, uModel.Tabs.Count);
            Assert.AreEqual("Profile", uModel.Tabs[0].Label);
            Assert.AreEqual(5, uModel.Tabs[0].Properties.Count);

            //AddTextBox
            Assert.AreEqual("My label", uModel.Tabs[0].Properties[0].Label);
            Assert.AreEqual("My description", uModel.Tabs[0].Properties[0].Description);
            Assert.AreEqual(this._testClass.Name, uModel.Tabs[0].Properties[0].Value);
            Assert.AreEqual(false, uModel.Tabs[0].Properties[0].IsReadOnly);
            Assert.AreEqual(50, uModel.Tabs[0].Properties[0].Config["maxChars"]);
            Assert.AreEqual(true, uModel.Tabs[0].Properties[0].Validation["mandatory"]);
            Assert.AreEqual("^[A-z]{9}$", uModel.Tabs[0].Properties[0].Validation["pattern"]);
            Assert.AreEqual("Umbraco.Textbox", uModel.Tabs[0].Properties[0].Editor);
            Assert.AreEqual("textbox", uModel.Tabs[0].Properties[0].View);

            //AddTextBox
            Assert.AreEqual("My label", uModel.Tabs[0].Properties[1].Label);
            Assert.AreEqual("Should be readonly", uModel.Tabs[0].Properties[1].Description);
            Assert.AreEqual(this._testClass.Name, uModel.Tabs[0].Properties[1].Value);
            Assert.AreEqual(true, uModel.Tabs[0].Properties[1].IsReadOnly);
            Assert.AreEqual(500, uModel.Tabs[0].Properties[1].Config["maxChars"]);//default max chars value for textbox
            Assert.AreEqual(false, uModel.Tabs[0].Properties[1].Validation["mandatory"]);
            Assert.AreEqual(null, uModel.Tabs[0].Properties[2].Validation["pattern"]);
            Assert.AreEqual("Umbraco.Textbox", uModel.Tabs[0].Properties[1].Editor);
            Assert.AreEqual("textbox", uModel.Tabs[0].Properties[1].View);

            //AddTextArea
            Assert.AreEqual("Summary", uModel.Tabs[0].Properties[2].Label);
            Assert.AreEqual("My short summary", uModel.Tabs[0].Properties[2].Description);
            Assert.AreEqual(this._testClass.Summary, uModel.Tabs[0].Properties[2].Value);
            Assert.AreEqual(false, uModel.Tabs[0].Properties[2].IsReadOnly);
            Assert.AreEqual(false, uModel.Tabs[0].Properties[2].Config["maxChars"]);
            Assert.AreEqual(true, uModel.Tabs[0].Properties[2].Validation["mandatory"]);
            Assert.AreEqual(null, uModel.Tabs[0].Properties[2].Validation["pattern"]);
            Assert.AreEqual("Umbraco.Textarea", uModel.Tabs[0].Properties[2].Editor);
            Assert.AreEqual("textarea", uModel.Tabs[0].Properties[2].View);

            //AddCheckbox
            Assert.AreEqual("Active", uModel.Tabs[0].Properties[3].Label);
            Assert.AreEqual(null, uModel.Tabs[0].Properties[3].Description);
            Assert.AreEqual("1", uModel.Tabs[0].Properties[3].Value);
            Assert.AreEqual(false, uModel.Tabs[0].Properties[3].IsReadOnly);
            Assert.AreEqual("Umbraco.TrueFalse", uModel.Tabs[0].Properties[3].Editor);
            Assert.AreEqual("boolean", uModel.Tabs[0].Properties[3].View);

            //AddDropdown
            Assert.AreEqual("Select", uModel.Tabs[0].Properties[4].Label);
            Assert.AreEqual(null, uModel.Tabs[0].Properties[4].Description);
            Assert.AreEqual("A", uModel.Tabs[0].Properties[4].Value);
            Assert.AreEqual(false, uModel.Tabs[0].Properties[4].IsReadOnly);
            Assert.AreEqual(true, uModel.Tabs[0].Properties[4].Validation["mandatory"]);
            Assert.AreEqual("Umbraco.Flexible", uModel.Tabs[0].Properties[4].Editor);
            Assert.AreEqual("dropdownFlexible", uModel.Tabs[0].Properties[4].View);

            Assert.AreEqual(this._testClass.Id, uModel.Id);
            Assert.AreEqual(this._testClass.Name, uModel.Name);
        }