Esempio n. 1
0
        public void GetField_FieldIsEmpty_ReturnsEmptyNameValueCollection()
        {
            //Assign
            var fieldValue = "";
            var fieldId    = Guid.NewGuid();

            var item  = Helpers.CreateFakeItem(fieldId, fieldValue);
            var field = item.Fields[new ID(fieldId)];

            var mapper = new SitecoreFieldNameValueCollectionMapper();

            //Act
            var result = mapper.GetField(field, null, null) as NameValueCollection;

            //Assert
            Assert.AreEqual(0, result.Count);
        }
        public void GetField_FieldIsEmpty_ReturnsEmptyNameValueCollection()
        {
            //Assign
            var fieldValue = "";
            var item       = Database.GetItem("/sitecore/content/Tests/DataMappers/SitecoreFieldNameValueCollectionMapper/GetField");
            var field      = item.Fields[FieldName];

            var mapper = new SitecoreFieldNameValueCollectionMapper();

            using (new ItemEditing(item, true))
            {
                field.Value = fieldValue;
            }

            //Act
            var result = mapper.GetField(field, null, null) as NameValueCollection;

            //Assert
            Assert.AreEqual(0, result.Count);
        }
Esempio n. 3
0
        public void GetField_FieldContainsThreeItems_ReturnsNameValueCollection()
        {
            //Assign
            var fieldValue = "Name1=Value1&Name2=Value2";
            var fieldId    = Guid.NewGuid();

            var item  = Helpers.CreateFakeItem(fieldId, fieldValue);
            var field = item.Fields[new ID(fieldId)];

            var mapper = new SitecoreFieldNameValueCollectionMapper();


            //Act
            var result = mapper.GetField(field, null, null) as NameValueCollection;

            //Assert
            Assert.AreEqual("Value1", result["Name1"]);
            Assert.AreEqual("Value2", result["Name2"]);
            Assert.AreEqual(2, result.Count);
        }
        public void GetField_FieldContainsThreeItems_ReturnsNameValueCollection()
        {
            //Assign
            var fieldValue = "Name1=Value1&Name2=Value2";
            var item       = Database.GetItem("/sitecore/content/Tests/DataMappers/SitecoreFieldNameValueCollectionMapper/GetField");
            var field      = item.Fields[FieldName];

            var mapper = new SitecoreFieldNameValueCollectionMapper();

            using (new ItemEditing(item, true))
            {
                field.Value = fieldValue;
            }

            //Act
            var result = mapper.GetField(field, null, null) as NameValueCollection;

            //Assert
            Assert.AreEqual("Value1", result["Name1"]);
            Assert.AreEqual("Value2", result["Name2"]);
            Assert.AreEqual(2, result.Count);
        }