Submit all LeafInputFiles together

This commit is contained in:
2016-03-28 10:20:50 -04:00
parent 4b2757b19a
commit 9e86b92f08
29 changed files with 353 additions and 268 deletions
@@ -1,79 +0,0 @@
using System;
using System.Linq;
using LeafWeb.Core.Entities;
using LeafWeb.Web.ViewModels.LeafOutput;
using NUnit.Framework;
namespace LeafWeb.Web.Tests.ViewModels.LeafOutput
{
[TestFixture]
public class LeafOutputViewModelTests
{
private LeafInputFile GetLeafInputFile()
{
return new LeafInputFile
{
Filename = "MyFilename.ext",
Id = 3,
CurrentStatus = LeafInputStatusType.Complete,
LeafInput = new LeafInput
{
Added = DateTime.Today,
Email = "test@email.com",
Identifier = "Ident I Fier",
Name = "My Name",
PhotosynthesisType = new PhotosynthesisType {Id = "1", Name = "1", SortOrder = 1}
},
LeafOutputFiles = new[] {new LeafOutputFile {Filename = "OutputFilename.txt"}}
};
}
[Test]
public void CanConstructFromLeafInputFile()
{
var file = GetLeafInputFile();
var viewModel = new LeafOutputViewModel(file);
Assert.That(viewModel.CurrentStatus, Is.EqualTo(file.CurrentStatus.ToString()));
Assert.That(viewModel.LeafInputFileId, Is.EqualTo(file.Id));
Assert.That(viewModel.LeafInputFilename, Is.EqualTo(file.Filename));
Assert.That(viewModel.LeafOutputFilenames, Has.Length.EqualTo(1));
Assert.That(viewModel.LeafInputIdentifier, Is.EqualTo(file.LeafInput.Identifier));
Assert.That(viewModel.LeafInputSiteId, Is.EqualTo(file.LeafInput.SiteId));
Assert.That(viewModel.LeafInputPhotosynthesisType, Is.EqualTo(file.LeafInput.PhotosynthesisType.Name));
}
[Test]
public void CanConstructFromLeafInputFile_Running()
{
var file = GetLeafInputFile();
file.CurrentStatus = LeafInputStatusType.Running;
file.LeafOutputFiles = new LeafOutputFile[0];
var viewModel = new LeafOutputViewModel(file);
Assert.That(viewModel.CurrentStatus, Is.EqualTo(LeafInputStatusType.Running.ToString()));
Assert.That(viewModel.LeafOutputFilenames, Has.Length.EqualTo(0));
}
[Test]
public void CanConstructFromLeafInputFile_Error()
{
var file = GetLeafInputFile();
file.CurrentStatus = LeafInputStatusType.Error;
file.StatusHistory = new []
{
new LeafInputFileStatus
{
DateTime = DateTime.Today,
LeafInputFile = file,
Description = "My Error",
Status = LeafInputStatusType.Error
}
};
var viewModel = new LeafOutputViewModel(file);
Assert.That(viewModel.CurrentStatus, Is.EqualTo(LeafInputStatusType.Error.ToString()));
Assert.That(viewModel.ErrorMessages[0], Is.EqualTo(file.StatusHistory.First().Description));
}
}
}
@@ -0,0 +1,81 @@
using System;
using System.Linq;
using LeafWeb.Core.Entities;
using LeafWeb.Web.ViewModels.ResultStatus;
using NUnit.Framework;
namespace LeafWeb.Web.Tests.ViewModels.ResultStatus
{
[TestFixture]
public class ResultStatusViewModelTests
{
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
}
}
};
}
[Test]
public void CanConstructFromLeafInputFile()
{
var leafInput = GetLeafInput();
var viewModel = new ResultStatusViewModel(leafInput);
Assert.That(viewModel.CurrentStatus, Is.EqualTo(leafInput.CurrentStatus.ToString()));
Assert.That(viewModel.LeafInputId, Is.EqualTo(leafInput.Id));
Assert.That(viewModel.LeafOutputFilenames, Has.Length.EqualTo(1));
Assert.That(viewModel.LeafInputIdentifier, Is.EqualTo(leafInput.Identifier));
Assert.That(viewModel.LeafInputSiteId, Is.EqualTo(leafInput.SiteId));
Assert.That(viewModel.LeafInputPhotosynthesisType, Is.EqualTo(leafInput.PhotosynthesisType.Name));
}
[Test]
public void CanConstructFromLeafInputFile_Running()
{
var leafInput = GetLeafInput();
leafInput.CurrentStatus = LeafInputStatusType.Running;
leafInput.OutputFiles = new LeafOutputFile[0];
var viewModel = new ResultStatusViewModel(leafInput);
Assert.That(viewModel.CurrentStatus, Is.EqualTo(LeafInputStatusType.Running.ToString()));
Assert.That(viewModel.LeafOutputFilenames, Has.Length.EqualTo(0));
}
[Test]
public void CanConstructFromLeafInputFile_Error()
{
var leafInput = GetLeafInput();
leafInput.CurrentStatus = LeafInputStatusType.Error;
leafInput.StatusHistory = new []
{
new LeafInputStatus
{
DateTime = DateTime.Today,
LeafInput = leafInput,
Description = "My Error",
Status = LeafInputStatusType.Error
}
};
var viewModel = new ResultStatusViewModel(leafInput);
Assert.That(viewModel.CurrentStatus, Is.EqualTo(LeafInputStatusType.Error.ToString()));
Assert.That(viewModel.ErrorMessages[0], Is.EqualTo(leafInput.StatusHistory.First().Description));
}
}
}
+1 -1
View File
@@ -44,7 +44,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ViewModels\LeafOutput\LeafOutputViewModelTests.cs" />
<Compile Include="ViewModels\ResultStatus\ResultStatusViewModelTests.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />