Fixing an issue with output parameters that are of type IntPtr
[castle.git] / MonoRail / Castle.MonoRail.Framework.Tests / Helpers / DateFormatHelperTestCase.cs
blob31d3acb918bf850bc3039f09c7333f9bfed674b5
1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle.MonoRail.Framework.Tests.Helpers
17 using System;
19 using Castle.MonoRail.Framework.Helpers;
21 using NUnit.Framework;
24 [TestFixture]
25 public class DateFormatHelperTestCase
27 private DateFormatHelper helper = new DateFormatHelper();
29 [Test]
30 public void FriendlyFormatWithDiffOfOneSecond()
32 Assert.AreEqual("1 second ago",
33 helper.FriendlyFormatFromNow( DateTime.Now.AddSeconds(-1) ));
36 [Test]
37 public void FriendlyFormatWithDiffOfTenSeconds()
39 Assert.AreEqual("10 seconds ago",
40 helper.FriendlyFormatFromNow( DateTime.Now.AddSeconds(-10) ));
43 [Test]
44 public void FriendlyFormatWithDiffOfTenMinutes()
46 Assert.AreEqual("10 minutes ago",
47 helper.FriendlyFormatFromNow( DateTime.Now.AddMinutes(-10) ));
50 [Test]
51 public void FriendlyFormatWithDiffOf120Minutes()
53 Assert.AreEqual("2 hours ago",
54 helper.FriendlyFormatFromNow( DateTime.Now.AddMinutes(-120) ));
57 [Test]
58 public void FriendlyFormatWithDiffOf17Hours()
60 Assert.AreEqual("17 hours ago",
61 helper.FriendlyFormatFromNow( DateTime.Now.AddMinutes(- (17 * 60 + 30) ) ));
64 [Test]
65 public void FriendlyFormatWithDiffOf2Days()
67 Assert.AreEqual("2 days ago",
68 helper.FriendlyFormatFromNow( DateTime.Now.AddDays(-2) ));
71 [Test]
72 public void AlternativeFriendlyFormatFromNow()
74 Assert.AreEqual("Today", helper.AlternativeFriendlyFormatFromNow( DateTime.Now ));
77 [Test]
78 public void AlternativeFriendlyFormatFromNowWith4Hours()
80 Assert.AreEqual("Today", helper.AlternativeFriendlyFormatFromNow( DateTime.Now.AddHours(-4) ));
83 [Test]
84 public void AlternativeFriendlyFormatFromNowWith44Hours()
86 Assert.AreEqual("Yesterday", helper.AlternativeFriendlyFormatFromNow( DateTime.Now.AddHours(-44) ));
89 [Test]
90 public void AlternativeFriendlyFormatFromNowWith3Days()
92 Assert.AreEqual("3 days ago", helper.AlternativeFriendlyFormatFromNow( DateTime.Now.AddDays(-3) ));
95 [Test]
96 public void AlternativeFriendlyFormatFromNowWith120Days()
98 Assert.AreEqual("4 months ago", helper.AlternativeFriendlyFormatFromNow( DateTime.Now.AddDays(-120) ));
101 [Test]
102 public void ToShortDate()
104 DateTime now = DateTime.Now;
106 string expected = now.ToShortDateString();
107 Assert.AreEqual(expected, helper.ToShortDate(now));
108 Assert.AreEqual(String.Empty, helper.ToShortDate(null));
111 [Test]
112 public void ToShortDateTime()
114 DateTime now = DateTime.Now;
116 string expected = now.ToShortDateString() + " " + now.ToShortTimeString();
117 Assert.AreEqual(expected, helper.ToShortDateTime(now));
118 Assert.AreEqual(String.Empty, helper.ToShortDateTime(null));