public void GetField_FieldContainsValidIsoDate_ReturnsDateTime() { //Assign string fieldValue = "20121101T230000"; DateTime expected = new DateTime(2012, 11, 01, 23, 00, 00); var fieldId = Guid.NewGuid(); var item = Helpers.CreateFakeItem(fieldId, fieldValue); var field = item.Fields[new ID(fieldId)]; var mapper = new SitecoreFieldDateTimeMapper(); //Act var result = (DateTime)mapper.GetField(field, null, null); //Assert Assert.AreEqual(expected, result); }
public void GetField_FieldContainsValidDate_ReturnsDateTime() { //Assign string fieldValue = "20120101T010101"; DateTime expected = new DateTime(2012,01,01,01,01,01); var item = Database.GetItem("/sitecore/content/Tests/DataMappers/SitecoreFieldDateTimeMapper/GetField"); var field = item.Fields[FieldName]; var mapper = new SitecoreFieldDateTimeMapper(); using (new ItemEditing(item, true)) { field.Value = fieldValue; } //Act var result = (DateTime) mapper.GetField(field, null, null); //Assert Assert.AreEqual(expected, result); }