74 lines
1.9 KiB
C#
74 lines
1.9 KiB
C#
using System;
|
|
using MileageTraker.Web.Utility;
|
|
using NUnit.Framework;
|
|
|
|
namespace Web.Tests.Utility
|
|
{
|
|
[TestFixture]
|
|
public class AlgorithmsTests
|
|
{
|
|
private const int _existingNumber = 2;
|
|
private readonly DateTime _existingDate = DateTime.Today.AddDays(-1);
|
|
|
|
[Test]
|
|
public void IsChronological_True_If_Greater_And_After()
|
|
{
|
|
var date = _existingDate.AddDays(1);
|
|
const int number = _existingNumber + 1;
|
|
var result = Algorithms.IsChronological(_existingDate, _existingNumber, date, number);
|
|
|
|
Assert.That(result);
|
|
}
|
|
|
|
[Test]
|
|
public void IsChronological_False_If_LessThan_And_After()
|
|
{
|
|
var date = _existingDate.AddDays(1);
|
|
const int number = _existingNumber - 1;
|
|
var result = Algorithms.IsChronological(_existingDate, _existingNumber, date, number);
|
|
|
|
Assert.That(result, Is.False);
|
|
}
|
|
|
|
[Test]
|
|
public void IsChronological_True_If_LessThan_And_Before()
|
|
{
|
|
var date = _existingDate.AddDays(-1);
|
|
const int number = _existingNumber - 1;
|
|
var result = Algorithms.IsChronological(_existingDate, _existingNumber, date, number);
|
|
|
|
Assert.That(result, Is.True);
|
|
}
|
|
|
|
[Test]
|
|
public void IsChronological_False_If_GreaterThan_And_Before()
|
|
{
|
|
var date = _existingDate.AddDays(-1);
|
|
const int number = _existingNumber + 1;
|
|
var result = Algorithms.IsChronological(_existingDate, _existingNumber, date, number);
|
|
|
|
Assert.That(result, Is.False);
|
|
}
|
|
|
|
[Test]
|
|
public void IsChronological_True_If_Same_And_Before()
|
|
{
|
|
var date = _existingDate.AddDays(-1);
|
|
const int number = _existingNumber;
|
|
var result = Algorithms.IsChronological(_existingDate, _existingNumber, date, number);
|
|
|
|
Assert.That(result, Is.True);
|
|
}
|
|
|
|
|
|
[Test]
|
|
public void IsChronological_True_If_Greater_And_SameTime()
|
|
{
|
|
var date = _existingDate;
|
|
const int number = _existingNumber + 1;
|
|
var result = Algorithms.IsChronological(_existingDate, _existingNumber, date, number);
|
|
|
|
Assert.That(result, Is.True);
|
|
}
|
|
}
|
|
} |