예제 #1
0
        public void ValueShouldBeFormattedUsingDefaultFormat()
        {
            TimeTagHelper tagHelper = new TimeTagHelper();
            tagHelper.Value = new DateTimeOffset(2014, 12, 25, 13, 21, 0, TimeSpan.FromHours(0));

            var output = GetOutput();
            tagHelper.Process(GetContext(), output);

            Assert.Null(output.TagName);
            Assert.Equal("12/25/2014 1:21 PM", output.Content.GetContent());
        }
예제 #2
0
        public void ValueShouldBeFormattedUsingSpecifiedFormat()
        {
            TimeTagHelper tagHelper = new TimeTagHelper();
            tagHelper.Value = new DateTimeOffset(2014, 12, 25, 13, 21, 0, TimeSpan.FromHours(0));
            tagHelper.Format = "yyyy-MM-dd";

            var output = GetOutput();
            tagHelper.Process(GetContext(), output);

            Assert.Null(output.TagName);
            Assert.Equal("2014-12-25", output.Content.GetContent());
        }
예제 #3
0
        public void ValueShouldBeConvertedToSpecifiedTimeZone()
        {
            TimeTagHelper tagHelper = new TimeTagHelper();
            tagHelper.Value = new DateTimeOffset(2014, 12, 25, 13, 21, 0, TimeSpan.FromHours(0));
            tagHelper.Format = "yyyy-MM-dd h:mm tt";
            tagHelper.TargetTimeZoneId = "Central Standard Time";

            var output = GetOutput();
            tagHelper.Process(GetContext(), output);

            Assert.Null(output.TagName);
            Assert.Equal("2014-12-25 7:21 AM", output.Content.GetContent());
        }
예제 #4
0
        public void ValueShouldBeFormattedUsingDefaultFormat()
        {
            System.Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US");
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US");

            TimeTagHelper tagHelper = new TimeTagHelper();
            tagHelper.Value = new DateTimeOffset(2014, 12, 25, 13, 21, 0, TimeSpan.FromHours(0));

            var output = GetOutput();
            tagHelper.Process(GetContext(), output);

            Assert.Null(output.TagName);
            Assert.Equal("12/25/2014 1:21 PM", output.Content.GetContent());
        }