Admin import functional
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,18 @@
|
||||
using System.IO;
|
||||
using MileageTraker.Web.DAL;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Web.Tests.DAL
|
||||
{
|
||||
[TestFixture]
|
||||
public class LogImportTemplateWriterTests
|
||||
{
|
||||
[Test]
|
||||
public void LogImportTemplteWriterTests()
|
||||
{
|
||||
var bytes = LogImportTemplateWriter.Write();
|
||||
using (var fs = new FileStream("LogImport.xls", FileMode.Create))
|
||||
fs.Write(bytes, 0, bytes.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using System.Linq;
|
||||
using MileageTraker.Web.DAL;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Web.Tests.DAL
|
||||
{
|
||||
[TestFixture]
|
||||
public class LogImporterTests
|
||||
{
|
||||
private const string LogFolder = @"DAL\LogDocs\";
|
||||
|
||||
[Test]
|
||||
public void Import_Gets_More_Than_One_Result()
|
||||
{
|
||||
var logs = LogImporter.Import(LogFolder + "Logs.xls").ToList();
|
||||
|
||||
Assert.That(logs.Count(), Is.GreaterThan(0));
|
||||
var first = logs.First();
|
||||
Assert.That(first.VehicleId, Is.EqualTo("3572"));
|
||||
Assert.That(first.Date, Is.EqualTo("3/4/2013"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException(typeof(LogImportException))]
|
||||
public void Import_Incorrect_ColumnHeaders()
|
||||
{
|
||||
LogImporter.Import(LogFolder + "Logs_IncorrectHeaders.xls");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Import_TemplateTest()
|
||||
{
|
||||
var logs = LogImporter.Import(LogFolder + "MileageTraker_ImportTemplate.xls");
|
||||
Assert.That(logs.Count(), Is.EqualTo(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user