예제 #1
0
        public void  GetFieldValue_EmtpyField_ReturnsNameValueCollectionNoItems()
        {
            //Assign
            SitecoreFieldNameValueCollectionHandler handler = new SitecoreFieldNameValueCollectionHandler();
            string input = string.Empty;

            //Act
            var result = handler.GetFieldValue(input, null, null) as NameValueCollection;

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(0, result.Count);
        }
예제 #2
0
        public void GetFieldValue_FieldWithValues_ReturnsNameValueCollectionNoItems()
        {
            //Assign
            SitecoreFieldNameValueCollectionHandler handler = new SitecoreFieldNameValueCollectionHandler();
            string input = "Test=value%26&Mike=ted";

            //Act
            var result = handler.GetFieldValue(input, null, null) as NameValueCollection;

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(2, result.Count);
            Assert.AreEqual("Test", result.Keys[0]);
            Assert.AreEqual("ted", result["Mike"]);
            Assert.AreEqual("value&", result["Test"]);
        }
예제 #3
0
        public void SetFieldValue()
        {
            //Assign
            SitecoreFieldNameValueCollectionHandler handler = new SitecoreFieldNameValueCollectionHandler();

            NameValueCollection values = new NameValueCollection();

            values["Test"] = "value&";
            values["Mike"] = "ted";

            string expected = "Test=value%26&Mike=ted";

            //Act
            var result = handler.SetFieldValue(values, null);

            //Assert

            Assert.AreEqual(expected, result);
        }