Leaf Input Details
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
using System;
|
||||
using LeafWeb.Core.Entities;
|
||||
using LeafWeb.WebCms.Models;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace LeafWeb.WebCms.Tests.Models
|
||||
{
|
||||
[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.Exception;
|
||||
leafInput.StatusHistory = new []
|
||||
{
|
||||
new LeafInputStatus
|
||||
{
|
||||
DateTime = DateTime.Today,
|
||||
LeafInput = leafInput,
|
||||
Description = "My Error",
|
||||
Status = LeafInputStatusType.Exception
|
||||
}
|
||||
};
|
||||
var viewModel = new ResultStatusViewModel(leafInput);
|
||||
|
||||
Assert.That(viewModel.CurrentStatus, Is.EqualTo(LeafInputStatusType.Exception.ToString()));
|
||||
//Assert.That(viewModel.ErrorMessages[0], Is.EqualTo(leafInput.StatusHistory.First().Description));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("WebCms.Tests")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("WebCms.Tests")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2016")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("d46179a2-58d6-46a3-9c5e-53d143a15277")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,72 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{D46179A2-58D6-46A3-9C5E-53D143A15277}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>LeafWeb.WebCms.Tests</RootNamespace>
|
||||
<AssemblyName>WebCms.Tests</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="nunit.framework, Version=3.5.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NUnit.3.5.0\lib\net45\nunit.framework.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Models\LeafInputDetailsTests.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Models\ResultStatusViewModelTests.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Core\Core.csproj">
|
||||
<Project>{25baed75-7e75-4d11-90d9-358472054df6}</Project>
|
||||
<Name>Core</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\WebCms\WebCms.csproj">
|
||||
<Project>{63d7ebed-ecf5-4227-b2d3-b77fbe4c3b3a}</Project>
|
||||
<Name>WebCms</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="NUnit" version="3.5.0" targetFramework="net452" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user