public void ConvertToDateTransformationInvalidDateIgnores() { BaseTransformation transformation = new ConvertToDateTransformation("dd/MM/yyyy HH:mm:ss", true); string input = "16/01/27 14:11:56"; object actual = transformation.TransformInputObject(input); object expected = null; Assert.AreEqual(expected, actual, "Date transformation didn't return null with invalid date input"); }
public void ConvertToDateTransformationWorks() { BaseTransformation transformation = new ConvertToDateTransformation("dd/MM/yyyy HH:mm:ss", true); string input = "16/01/2017 14:11:56"; DateTime expected = new DateTime(2017, 1, 16, 14, 11, 56); object actual = transformation.TransformInputObject(input); Assert.AreEqual(expected, actual, "Date transformation didn't get the correct date"); }
public void DateMappingWorks() { TemplateMapping mapper = new TemplateMapping("$[Date] $[Time]"); ConvertToDateTransformation dateTransform = new ConvertToDateTransformation("yyyy/MM/dd HH:mm:ss", false); BaseTransformation[] transformations = new BaseTransformation[] { dateTransform }; SingleMapping fullMapping = new SingleMapping(mapper, transformations); Dictionary <string, object> inputRow = new Dictionary <string, object>(); inputRow.Add("Date", "2017/12/14"); inputRow.Add("Time", "12:13:00"); object expected = new DateTime(2017, 12, 14, 12, 13, 0); object actual = fullMapping.GetValue(inputRow); Assert.AreEqual(expected, actual, "Date transformation didn't extract correct value"); }
public void ConvertToDateTransformationInvalidDateThrows() { BaseTransformation transformation = new ConvertToDateTransformation("dd/MM/yyyy HH:mm:ss", false); string input = "16/01/27 14:11:56"; object actual = transformation.TransformInputObject(input); }