public void SetField_ObjectIsInt_ThrowsException() { //Assign string objectValue = "hello world"; var fieldId = Guid.NewGuid(); var item = Helpers.CreateFakeItem(fieldId, string.Empty); var field = item.Fields[new ID(fieldId)]; var config = new SitecoreFieldConfiguration(); config.PropertyInfo = typeof(Stub).GetProperty("Property"); var mapper = new SitecoreFieldEnumMapper(); //Act mapper.SetField(field, objectValue, config, null); //Assert }
public void SetField_ObjectIsInt_ThrowsException() { //Assign string objectValue = "hello world"; var item = Database.GetItem("/sitecore/content/Tests/DataMappers/SitecoreFieldEnumMapper/SetField"); var field = item.Fields[FieldName]; var config = new SitecoreFieldConfiguration(); config.PropertyInfo = typeof(Stub).GetProperty("Property"); var mapper = new SitecoreFieldEnumMapper(); using (new ItemEditing(item, true)) { field.Value = string.Empty; } //Act using (new ItemEditing(item, true)) { mapper.SetField(field, objectValue, config, null); } //Assert }
public void SetField_ObjectisValidEnum_SetsFieldValue() { //Assign string expected = "Value2"; StubEnum objectValue = StubEnum.Value2; var fieldId = Guid.NewGuid(); var item = Helpers.CreateFakeItem(fieldId, string.Empty); var field = item.Fields[new ID(fieldId)]; var config = new SitecoreFieldConfiguration(); config.PropertyInfo = typeof(Stub).GetProperty("Property"); var mapper = new SitecoreFieldEnumMapper(); item.Editing.BeginEdit(); //Act mapper.SetField(field, objectValue, config, null); //Assert Assert.AreEqual(expected, field.Value); }
public void SetField_ObjectisValidEnum_SetsFieldValue() { //Assign string expected = "Value2"; StubEnum objectValue = StubEnum.Value2; var item = Database.GetItem("/sitecore/content/Tests/DataMappers/SitecoreFieldEnumMapper/SetField"); var field = item.Fields[FieldName]; var config = new SitecoreFieldConfiguration(); config.PropertyInfo = typeof(Stub).GetProperty("Property"); var mapper = new SitecoreFieldEnumMapper(); using (new ItemEditing(item, true)) { field.Value = string.Empty; } //Act using (new ItemEditing(item, true)) { mapper.SetField(field, objectValue, config, null); } //Assert Assert.AreEqual(expected, field.Value); }