Esempio n. 1
0
        public void CompareDateTimeValidationAndConvertion()
        {
            IOUtility iOUtility = new IOUtility();

            foreach (var dt in DateTimeCases)
            {
                DateTime result;
                iOUtility.ConvertToDate(dt.InputDateTimeString, dt.Pattern, out result, dt.CultureInfo);
                DataTypeCheck check       = new DataTypeCheck("dtCheck", "DateTime", DecimalCharacter.point, dt.Pattern, dt.CultureInfo);
                var           checkresult = check.Execute(dt.InputDateTimeString, 1);

                if (dt.ItMatch)
                {
                    result.ToString(new CultureInfo("en-US", false)).Should().NotBeNull("can´t convert : " + dt.InputDateTimeString + " with pattern:" + dt.Pattern);
                    result.ToString(new CultureInfo("en-US", false)).Should().Match(dt.OutputDateTimeString, "not match :" + result + " - " + dt.OutputDateTimeString);
                    //checkresult.Should(typeof(DateTime))
                    //Assert.IsInstanceOf<DateTime>(checkresult, "xyz");
                    checkresult.Should().BeOfType <DateTime>();
                }
                else
                {
                    if (result != null)
                    {
                        result.ToString(new CultureInfo("en-US", false)).Should().NotMatch(dt.OutputDateTimeString, "should not match :" + result + " - " + dt.OutputDateTimeString);
                    }
                    else
                    {
                        result.ToString(new CultureInfo("en-US", false)).Should().BeNullOrEmpty();
                        checkresult.Should().BeOfType <Error>();
                    }
                }
            }
        }
Esempio n. 2
0
        public void ConvertStringToDateTimeWithPatternTest()
        {
            IOUtility iOUtility = new IOUtility();

            foreach (var dt in DateTimeCases)
            {
                DateTime result;
                iOUtility.ConvertToDate(dt.InputDateTimeString, dt.Pattern, out result, dt.CultureInfo);

                if (dt.ItMatch)
                {
                    result.ToString(new CultureInfo("en-US", false)).Should().NotBeNull("can´t convert : " + dt.InputDateTimeString + " with pattern:" + dt.Pattern);
                    result.ToString(new CultureInfo("en-US", false)).Should().Match(dt.OutputDateTimeString, "not match :" + result + " - " + dt.OutputDateTimeString);
                }
                else
                {
                    if (result != null)
                    {
                        result.ToString(new CultureInfo("en-US", false)).Should().NotMatch(dt.OutputDateTimeString, "should not match :" + result + " - " + dt.OutputDateTimeString);
                    }
                    else
                    {
                        result.ToString(new CultureInfo("en-US", false)).Should().BeNullOrEmpty();
                    }
                }
            }
        }