Exemplo n.º 1
0
        public void SetField_ObjectisValidDouble_SetsFieldValue()
        {
            //Assign
            string expected    = "3.141592";
            double objectValue = 3.141592D;
            var    item        = Database.GetItem("/sitecore/content/Tests/DataMappers/SitecoreFieldDoubleMapper/SetField");
            var    field       = item.Fields[FieldName];

            var mapper = new SitecoreFieldDoubleMapper();

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

            //Act
            using (new ItemEditing(item, true))
            {
                mapper.SetField(field, objectValue, null, null);
            }


            //Assert
            Assert.AreEqual(expected, field.Value);
        }
Exemplo n.º 2
0
        public void SetField_ObjectIsInt_ThrowsException()
        {
            //Assign
            int objectValue = 3;
            var fieldId     = Guid.NewGuid();

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

            var mapper = new SitecoreFieldDoubleMapper();

            item.Editing.BeginEdit();
            //Act
            mapper.SetField(field, objectValue, null, null);


            //Assert
        }
Exemplo n.º 3
0
        public void SetField_ObjectisValidDouble_SetsFieldValue()
        {
            //Assign
            string expected    = "3.141592";
            double objectValue = 3.141592D;
            var    fieldId     = Guid.NewGuid();

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

            var mapper = new SitecoreFieldDoubleMapper();

            item.Editing.BeginEdit();

            //Act

            mapper.SetField(field, objectValue, null, null);



            //Assert
            Assert.AreEqual(expected, field.Value);
        }
Exemplo n.º 4
0
        public void SetField_ObjectIsInt_ThrowsException()
        {
            //Assign
            int objectValue = 3;
            var item        = Database.GetItem("/sitecore/content/Tests/DataMappers/SitecoreFieldDoubleMapper/SetField");
            var field       = item.Fields[FieldName];

            var mapper = new SitecoreFieldDoubleMapper();

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

            //Act
            using (new ItemEditing(item, true))
            {
                mapper.SetField(field, objectValue, null, null);
            }


            //Assert
        }