public void GetField_FieldContainsInvalidValidDecimal_ReturnsDecimal()
        {
            //Assign
            string  fieldValue = "hello world";
            decimal expected   = 3.141592M;
            var     fieldId    = Guid.NewGuid();

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

            var mapper = new SitecoreFieldDecimalMapper();

            //Act
            Assert.Throws <MapperException>(() =>
            {
                var result = (decimal)mapper.GetField(field, null, null);
            });
        }
        public void GetField_FieldContainsEmptyString_ReturnsDecimalZero()
        {
            //Assign
            string  fieldValue = string.Empty;
            decimal expected   = 0;
            var     fieldId    = Guid.NewGuid();

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

            var mapper = new SitecoreFieldDecimalMapper();

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

            //Assert
            Assert.AreEqual(expected, result);
        }
        public void GetField_FieldContainsInvalidValidDecimal_ReturnsDecimal()
        {
            //Assign
            string  fieldValue = "hello world";
            decimal expected   = 3.141592M;
            var     item       = Database.GetItem("/sitecore/content/Tests/DataMappers/SitecoreFieldDecimalMapper/GetField");
            var     field      = item.Fields[FieldName];

            var mapper = new SitecoreFieldDecimalMapper();

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

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

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