protected virtual bool AssertEqualsAsDate(Table table, Row row, string columnName,
                                                  string expected, object actual)
        {
            if (expected.IndexOf(TODAY) > -1 && actual is string)
            {
                actual = ToDate((string)actual);
            }

            if (expected.IndexOf(TODAY) > -1 && (actual is DateTime || actual is DateTimeOffset))
            {
                String today = Formi.Format(DateTime.Today, "yyyy-MM-dd");
                expected = expected.Replace(TODAY, today);
                if (AssertEqualsStrictly(table, row, columnName, expected, DateTimeToString((IFormattable)actual, today)))
                {
                    return(true);
                }
                Assertie.AreEqual(expected, actual,
                                  "M_Fixture_Temp_ObjectValidator_AssertEquals", table, row, columnName, expected, actual, GetType(actual));
            }
            if (actual is DateTime || actual is DateTimeOffset)
            {
                string actualAsText = DateTimeToString((IFormattable)actual, expected);
                if (AssertEqualsStrictly(table, row, columnName, expected, actualAsText))
                {
                    return(true);
                }
                Assertie.AreEqual(expected, actualAsText,
                                  "M_Fixture_Temp_ObjectValidator_AssertEquals", table, row, columnName, expected, actualAsText, GetType(actual));
            }
            return(false);
        }
Exemple #2
0
        public void Formatは指定された書式で日時を文字列に変換する()
        {
            // setup
            DateTime dateTime = new DateTime(2012, 1, 1, 1, 1, 2);

            // expect
            Assert.AreEqual("20120101010102", Formi.Format(dateTime, "yyyyMMddHHmmss"));
        }
Exemple #3
0
        public void Formatは指定された書式とタイムゾーンで日時を文字列に変換する()
        {
            // setup
            TimeZoneInfo current  = TimeZoneInfo.Local;
            TimeZoneInfo custom   = TimeZoneInfo.CreateCustomTimeZone("test1", TimeSpan.FromHours(current.BaseUtcOffset.Hours + 1), "test1", "test1");
            DateTime     dateTime = new DateTime(2012, 1, 1, 1, 1, 2);

            // expect
            Assert.AreEqual("20120101 020102", Formi.Format(dateTime, "yyyyMMdd HHmmss", custom));
        }