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); }
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 }
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); }
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 }