93 lines
2.7 KiB
C#
93 lines
2.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using LeafWeb.Core.Entities;
|
|
using LeafWeb.WebCms.Models;
|
|
using NUnit.Framework;
|
|
|
|
namespace LeafWeb.WebCms.Tests.Models
|
|
{
|
|
[TestFixture]
|
|
public class LeafInputDetailsTests
|
|
{
|
|
private LeafInput GetLeafInput()
|
|
{
|
|
return new LeafInput
|
|
{
|
|
CurrentStatus = LeafInputStatusType.Complete,
|
|
OutputFiles = new[] { new LeafOutputFile { Filename = "OutputFilename.txt" } },
|
|
Added = DateTime.Today,
|
|
Email = "test@email.com",
|
|
Identifier = "Ident I Fier",
|
|
Name = "My Name",
|
|
PhotosynthesisType = new PhotosynthesisType { Id = "1", Name = "1", SortOrder = 1 },
|
|
InputFiles = new[]
|
|
{
|
|
new LeafInputFile
|
|
{
|
|
Filename = "MyFilename.ext",
|
|
Id = 3
|
|
}
|
|
},
|
|
StatusHistory = new List<LeafInputStatus> {
|
|
new LeafInputStatus
|
|
{
|
|
DateTime = DateTime.Today.Subtract(new TimeSpan(4,0,0)),
|
|
Description = "Added",
|
|
Details = "Uploaded from Web",
|
|
Id = 1,
|
|
Status = LeafInputStatusType.Pending
|
|
},
|
|
new LeafInputStatus
|
|
{
|
|
DateTime = DateTime.Today.Subtract(new TimeSpan(3,0,0)),
|
|
Description = "Uploading input data",
|
|
Id = 2,
|
|
Status = LeafInputStatusType.Starting
|
|
},
|
|
new LeafInputStatus
|
|
{
|
|
DateTime = DateTime.Today.Subtract(new TimeSpan(2,12,0)),
|
|
Description = "Running on server",
|
|
Id = 3,
|
|
Status = LeafInputStatusType.Running
|
|
},
|
|
new LeafInputStatus
|
|
{
|
|
DateTime = DateTime.Today.Subtract(new TimeSpan(1,0,0)),
|
|
Description = "Downloading results",
|
|
Id = 4,
|
|
Status = LeafInputStatusType.Finishing
|
|
},
|
|
new LeafInputStatus
|
|
{
|
|
DateTime = DateTime.Today.Subtract(new TimeSpan(0,12,0)),
|
|
Description = "All done",
|
|
Id = 5,
|
|
Status = LeafInputStatusType.Complete
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
|
|
[Test]
|
|
public void CanConstructFromLeafInputFile()
|
|
{
|
|
var leafInput = GetLeafInput();
|
|
var viewModel = new LeafInputDetails(leafInput);
|
|
|
|
Assert.That(viewModel.CurrentStatus, Is.EqualTo(leafInput.CurrentStatus.ToString()));
|
|
Assert.That(viewModel.StatusHistory, Has.Count.EqualTo(5));
|
|
Assert.That(viewModel.StatusHistory[0].Status, Is.EqualTo("Pending"));
|
|
Assert.That(viewModel.StatusHistory[1].Status, Is.EqualTo("Starting"));
|
|
Assert.That(viewModel.StatusHistory[4].Status, Is.EqualTo("Complete"));
|
|
//Assert.That(viewModel., Is.EqualTo(leafInput.Id));
|
|
//Assert.That(viewModel.LeafOutputFilenames, Has.Length.EqualTo(1));
|
|
//Assert.That(viewModel., Is.EqualTo(leafInput.Identifier));
|
|
Assert.That(viewModel.SiteId, Is.EqualTo(leafInput.SiteId));
|
|
//Assert.That(viewModel.LeafInputPhotosynthesisType, Is.EqualTo(leafInput.PhotosynthesisType.Name));
|
|
}
|
|
|
|
}
|
|
}
|