Ejemplo n.º 1
0
        public void GetField_FieldEmpty_EmptyGuidReturned()
        {
            //Assign
            var fieldValue = string.Empty;
            var fieldId    = Guid.NewGuid();

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

            var expected = Guid.Empty;

            var mapper = new SitecoreFieldGuidMapper();



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

            //Assert
            Assert.AreEqual(expected, result);
        }
        public void GetField_FieldEmpty_EmptyGuidReturned()
        {
            //Assign
            var fieldValue = string.Empty;
            var item       = Database.GetItem("/sitecore/content/Tests/DataMappers/SitecoreFieldGuidMapper/GetField");
            var field      = item.Fields[FieldName];
            var expected   = Guid.Empty;

            var mapper = new SitecoreFieldGuidMapper();

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

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

            //Assert
            Assert.AreEqual(expected, result);
        }
Ejemplo n.º 3
0
        public void GetField_ContainsGuid_GuidObjectReturned()
        {
            //Assign
            var fieldValue = "{FC1D0AFD-71CC-47e2-84B3-7F1A2973248B}";
            var fieldId    = Guid.NewGuid();

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

            var expected = new Guid(fieldValue);

            var mapper = new SitecoreFieldGuidMapper();



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

            //Assert
            Assert.AreEqual(expected, result);
        }
        public void GetField_ContainsGuid_GuidObjectReturned()
        {
            //Assign
            var fieldValue = "{FC1D0AFD-71CC-47e2-84B3-7F1A2973248B}";
            var item       = Database.GetItem("/sitecore/content/Tests/DataMappers/SitecoreFieldGuidMapper/GetField");
            var field      = item.Fields[FieldName];
            var expected   = new Guid(fieldValue);

            var mapper = new SitecoreFieldGuidMapper();

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

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

            //Assert
            Assert.AreEqual(expected, result);
        }