Improved filtering implemented.

This commit is contained in:
2014-05-16 18:23:18 -04:00
parent b2d57a9e5f
commit fe0bc4e9ff
14 changed files with 425 additions and 133 deletions
+11 -3
View File
@@ -2,9 +2,7 @@
using System.Linq;
using MileageTraker.Web.Models;
using MileageTraker.Web.Utility;
using MileageTraker.Web.ViewModels;
using MileageTraker.Web.ViewModels.CreateLog;
using MileageTraker.Web.ViewModels.Log;
using MiscUtil.Collections;
using NUnit.Framework;
using ImportLogViewModel = MileageTraker.Web.ViewModels.Log.ImportLogViewModel;
@@ -108,5 +106,15 @@ namespace Web.Tests.Utility
{
typeof (MileageLogType).ParseWithDisplayNames("None");
}
[Test]
public void YearMonthGroupTest()
{
var range = new Range<DateTime>(new DateTime(2011, 2, 4), new DateTime(2013, 6, 23));
var monthsBetween = range.FromStart(d => d.AddMonths(1));
var yearMonthList = CustomExtensions.YearMonthList(monthsBetween);
Assert.That(yearMonthList, Has.Count.EqualTo(3));
Assert.That(yearMonthList["2013"], Has.Count.EqualTo(6));
}
}
}
@@ -0,0 +1,55 @@
using MileageTraker.Web.Models;
using MileageTraker.Web.ViewModels.Log;
using NUnit.Framework;
namespace Web.Tests.ViewModels.Log
{
[TestFixture]
public class LogQueryViewModelTests
{
[Test]
public void YearMonthStartTest()
{
var model = new LogQueryViewModel {Year = 2011, Month=1};
var ym = model.YearMonthStart;
Assert.That(ym, Is.EqualTo("2011-01"));
}
[Test]
public void YearMonthEndTest()
{
var model = new LogQueryViewModel {Year = 2011, Month=1, MonthRange = 3};
var ym = model.YearMonthEnd;
Assert.That(ym, Is.EqualTo("2011-03"));
}
[Test]
public void YearMonthEnd_YearRoll_Test()
{
var model = new LogQueryViewModel { Year = 2011, Month = 6, MonthRange = 12 };
var ym = model.YearMonthEnd;
Assert.That(ym, Is.EqualTo("2012-05"));
}
[Test]
public void YearMonthEnd_YearRoll_NotQuite_Test()
{
var model = new LogQueryViewModel { Year = 2011, Month = 1, MonthRange = 12 };
var ym = model.YearMonthEnd;
Assert.That(ym, Is.EqualTo("2011-12"));
}
[Test]
public void AllTest()
{
var model = new LogQueryViewModel
{
Year = 2011, Month = 2, MonthRange = 12,
EmployeeName = "My Name",
LogType = MileageLogType.Commuting,
VehicleId = "1023"
};
Assert.That(model.ToString(), Is.EqualTo("2011-02to2012-01_Comm_1023_My-Name"));
}
}
}
+5
View File
@@ -44,6 +44,10 @@
<Private>True</Private>
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
</Reference>
<Reference Include="MiscUtil, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d3c42c4bfacf7596, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\JonSkeet.MiscUtil.0.1\lib\net35-Client\MiscUtil.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=2.6.3.13283, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
@@ -98,6 +102,7 @@
<Compile Include="Utility\CustomExtensionsTests.cs" />
<Compile Include="ViewModels\CreateLog\CreateLogViewModelTests.cs" />
<Compile Include="ViewModels\CreateLog\LogImportViewModelTests.cs" />
<Compile Include="ViewModels\Log\LogQueryViewModelTests.cs" />
<Compile Include="ViewModels\Log\LogViewModelTests.cs" />
<Compile Include="ViewModels\User\CreateUserViewModelTests.cs" />
<Compile Include="ViewModels\User\EditUserViewModelTests.cs" />