Admin import functional
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using AutoMapper;
|
||||
using MileageTraker.Web.ViewModels;
|
||||
using MileageTraker.Web.ViewModels.CreateLog;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Web.Tests.ViewModels.CreateLog
|
||||
{
|
||||
[TestFixture]
|
||||
public class LogImportViewModelTests
|
||||
{
|
||||
private LogImportViewModel GetTestModel()
|
||||
{
|
||||
return new LogImportViewModel
|
||||
{
|
||||
CityName = "City",
|
||||
Date = "10-20-2010",
|
||||
EndOdometer = "10010",
|
||||
GasPurchased = "1.123",
|
||||
LogType = "Commuting",
|
||||
Notes = "My Note",
|
||||
Purpose = "Training",
|
||||
VehicleId = "1021"
|
||||
};
|
||||
}
|
||||
|
||||
// TODO: probably no longer need getlog
|
||||
[Test]
|
||||
public void GetLog_Correct()
|
||||
{
|
||||
var vm = GetTestModel();
|
||||
var log = vm.GetLog();
|
||||
Assert.That(log.CityName, Is.EqualTo(vm.CityName));
|
||||
Assert.That(log.Date, Is.EqualTo(new DateTime(2010,10,20)));
|
||||
Assert.That(log.Purpose.Purpose, Is.EqualTo("Training"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException(typeof(AutoMapperMappingException))]
|
||||
public void GetLog_GasPurchased_NotNumber()
|
||||
{
|
||||
var vm = GetTestModel();
|
||||
vm.Date = "wrong";
|
||||
vm.GetLog();
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException(typeof(AutoMapperMappingException))]
|
||||
public void GetLog_Purpose_NotValid()
|
||||
{
|
||||
var vm = GetTestModel();
|
||||
vm.Purpose = "uh huh nope";
|
||||
var log = vm.GetLog();
|
||||
Assert.That(log.CityName, Is.EqualTo(vm.CityName));
|
||||
Assert.That(log.Date, Is.EqualTo(new DateTime(2010, 10, 20)));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user