Search for both LeafInput and LeafInputData

This commit is contained in:
2023-02-02 09:35:22 -05:00
parent 8e16510ad9
commit 680f139aa5
24 changed files with 808 additions and 281 deletions
+8 -107
View File
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using LeafWeb.Core.Entities;
using LeafWeb.WebCms.App_Start;
using LeafWeb.WebCms.App_Start;
using LeafWeb.WebCms.Models;
using NUnit.Framework;
@@ -16,106 +13,10 @@ namespace LeafWeb.WebCms.Tests.Models
AutoMapperConfig.RegisterMappings();
}
private LeafInput GetLeafInput =>
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
}
},
LeafInputData = new List<LeafInputData>
{
new LeafInputData
{
Site = new LeafInputDataSite {Latitude = 10, Longitude = 20, SiteId = "MySiteId"},
SiteName = "MySite",
Id = 123,
Data = new List<LeafInputDataCurve>
{
new LeafInputDataCurve
{
CO2S = 3.1
}
}
}
}
};
private LeafInputData GetLeafInputData =>
new LeafInputData
{
Site = new LeafInputDataSite {Latitude = 10, Longitude = 20, SiteId = "MySiteId"},
SiteName = "MySite",
Id = 123,
Data = new List<LeafInputDataCurve>
{
new LeafInputDataCurve
{
CO2S = 3.1
}
}
};
private LeafInputDataCurve GetLeafInputDataCurve =>
new LeafInputDataCurve
{
CO2S = 3.1
};
[Test]
public void CanConstructLeafInputDataCurve()
{
var leafInputDataCurve = GetLeafInputDataCurve;
var leafInputDataCurve = LeafInputTestData.GetLeafInputDataCurve;
var viewModel = new LeafInputDataCurveViewModel(leafInputDataCurve);
Assert.That(viewModel.CO2S, Is.EqualTo(3.1));
@@ -124,19 +25,19 @@ namespace LeafWeb.WebCms.Tests.Models
[Test]
public void CanConstructLeafInputData()
{
var leafInputData = GetLeafInputData;
var leafInputData = LeafInputTestData.GetLeafInputData;
var viewModel = new LeafInputDataViewModel(leafInputData);
Assert.That(viewModel.SiteName, Is.EqualTo("MySite"));
Assert.That(viewModel.Data, Is.Not.Null);
Assert.That(viewModel.Data, Has.Count.GreaterThan(0));
Assert.That(viewModel.Data[0].CO2S, Is.EqualTo(3.1));
Assert.That(viewModel.Data[0].CO2S, Is.EqualTo(292.5618317));
}
[Test]
public void CanConstructAdminFromLeafInputFile()
{
var leafInput = GetLeafInput;
var leafInput = LeafInputTestData.GetLeafInput;
var viewModel = new LeafInputDetails_Admin(leafInput);
//Assert.That(viewModel.CurrentStatus, Is.EqualTo(leafInput.CurrentStatus.ToString()));
@@ -162,7 +63,7 @@ namespace LeafWeb.WebCms.Tests.Models
Assert.That(viewModel.LeafInputData[0].Data, Is.Not.Null);
Assert.That(viewModel.LeafInputData[0].Data, Has.Count.GreaterThan(0));
Assert.That(viewModel.LeafInputData[0].Data[0].CO2S, Is.EqualTo(3.1));
Assert.That(viewModel.LeafInputData[0].Data[1].CO2S, Is.EqualTo(195.4142136));
//Assert.That(viewModel.LeafInputData[0].Id, Is.EqualTo(123));
}
@@ -170,7 +71,7 @@ namespace LeafWeb.WebCms.Tests.Models
[Test]
public void CanConstructFromLeafInputFile()
{
var leafInput = GetLeafInput;
var leafInput = LeafInputTestData.GetLeafInput;
var viewModel = new LeafInputDetails(leafInput);
//Assert.That(viewModel.CurrentStatus, Is.EqualTo(leafInput.CurrentStatus.ToString()));
@@ -192,7 +93,7 @@ namespace LeafWeb.WebCms.Tests.Models
Assert.That(viewModel.LeafInputData[0].Data, Is.Not.Null);
Assert.That(viewModel.LeafInputData[0].Data, Has.Count.GreaterThan(0));
Assert.That(viewModel.LeafInputData[0].Data[0].CO2S, Is.EqualTo(3.1));
Assert.That(viewModel.LeafInputData[0].Data[0].CO2S, Is.EqualTo(292.5618317));
//Assert.That(viewModel.LeafInputData[0].Id, Is.EqualTo(123));
}