Added tests for new relative time calculator.
This commit is contained in:
parent
63343d16df
commit
87bfa40f23
2 changed files with 68 additions and 4 deletions
|
|
@ -1,4 +1,33 @@
|
|||
using MatterHackers.MatterControl;
|
||||
/*
|
||||
Copyright (c) 2014, Lars Brubaker
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The views and conclusions contained in the software and documentation are those
|
||||
of the authors and should not be interpreted as representing official policies,
|
||||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using MatterHackers.MatterControl;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
|
@ -7,14 +36,49 @@ using System.Diagnostics;
|
|||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using MatterHackers.Agg.UI;
|
||||
|
||||
namespace MatterControl.Tests.MatterControl
|
||||
{
|
||||
|
||||
[TestFixture]
|
||||
public class TranslationsTests
|
||||
{
|
||||
[Test, Category("Translations")]
|
||||
[Test, Category("Translations")]
|
||||
public void RelativeFriendlyDatesTest()
|
||||
{
|
||||
// May 28, 2016 at 3:13 pm
|
||||
DateTime nowTime = new DateTime(2016, 05, 28, 15, 13, 37);
|
||||
|
||||
DateTime testTime = nowTime.AddMinutes(-63);
|
||||
Assert.IsTrue(RelativeTime.GetTimeBlock(nowTime, testTime) == TimeBlock.Today);
|
||||
Assert.IsTrue(RelativeTime.GetDetail(nowTime, testTime) == "2:10 PM");
|
||||
|
||||
testTime = nowTime.AddHours(-25);
|
||||
Assert.IsTrue(RelativeTime.GetTimeBlock(nowTime, testTime) == TimeBlock.Yesterday);
|
||||
Assert.IsTrue(RelativeTime.GetDetail(nowTime, testTime) == "2:13 PM");
|
||||
|
||||
testTime = nowTime.AddDays(-4);
|
||||
Assert.IsTrue(RelativeTime.GetTimeBlock(nowTime, testTime) == TimeBlock.SameWeek);
|
||||
Assert.IsTrue(RelativeTime.GetDetail(nowTime, testTime) == "Tuesday 3:13 PM");
|
||||
|
||||
testTime = nowTime.AddDays(-6);
|
||||
Assert.IsTrue(RelativeTime.GetTimeBlock(nowTime, testTime) == TimeBlock.SameWeek);
|
||||
Assert.IsTrue(RelativeTime.GetDetail(nowTime, testTime) == "Sunday 3:13 PM");
|
||||
|
||||
testTime = nowTime.AddDays(-7);
|
||||
Assert.IsTrue(RelativeTime.GetTimeBlock(nowTime, testTime) == TimeBlock.SameMonth);
|
||||
Assert.IsTrue(RelativeTime.GetDetail(nowTime, testTime) == "21, 3:13 PM");
|
||||
|
||||
testTime = nowTime.AddDays(-37);
|
||||
Assert.IsTrue(RelativeTime.GetTimeBlock(nowTime, testTime) == TimeBlock.SameYear);
|
||||
Assert.IsTrue(RelativeTime.GetDetail(nowTime, testTime) == "April 21, 3:13 PM");
|
||||
|
||||
testTime = nowTime.AddDays(-364);
|
||||
Assert.IsTrue(RelativeTime.GetTimeBlock(nowTime, testTime) == TimeBlock.PastYear);
|
||||
Assert.IsTrue(RelativeTime.GetDetail(nowTime, testTime) == "2015 May 30, 3:13 PM");
|
||||
}
|
||||
|
||||
[Test, Category("Translations")]
|
||||
public void EnglishLinesOnlyContainEnglishCharachters()
|
||||
{
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue