public void GetField_FieldContainsInvalidValidEnum_ThrowsException()
        {
            //Assign
            string fieldValue = "hello world";
            var    fieldId    = Guid.NewGuid();

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

            var config = new SitecoreFieldConfiguration();

            config.PropertyInfo = typeof(Stub).GetProperty("Property");

            var mapper = new SitecoreFieldNullableEnumMapper();

            //Act
            var result = (StubEnum?)mapper.GetField(field, config, null);

            //Assert
        }
        public void GetField_FieldContainsEmptyString_ReturnsNull()
        {
            //Assign
            string fieldValue = string.Empty;
            var    fieldId    = Guid.NewGuid();

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

            var config = new SitecoreFieldConfiguration();

            config.PropertyInfo = typeof(Stub).GetProperty("Property");

            var mapper = new SitecoreFieldNullableEnumMapper();

            //Act
            var result = (StubEnum?)mapper.GetField(field, config, null);

            //Assert
            Assert.IsNull(result);
        }
        public void GetField_FieldContainsValidEnumInteger_ReturnsEnum()
        {
            //Assign
            string   fieldValue = "2";
            StubEnum expected   = StubEnum.Value2;
            var      fieldId    = Guid.NewGuid();

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

            var config = new SitecoreFieldConfiguration();

            config.PropertyInfo = typeof(Stub).GetProperty("Property");

            var mapper = new SitecoreFieldNullableEnumMapper();

            //Act
            var result = (StubEnum?)mapper.GetField(field, config, null);

            //Assert
            Assert.IsTrue(result.HasValue);
            Assert.AreEqual(expected, result.Value);
        }