Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit ae121f26 authored by Harald MARTINI's avatar Harald MARTINI
Browse files

Added BugReport (Wrong decimal count) Test

parent e1d58a17
No related branches found
No related tags found
No related merge requests found
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Ninject;
using NUnit.Framework;
using NUnit.Framework.Internal;
using VECTO3GUI2020.ViewModel.Implementation;
using VECTO3GUI2020.ViewModel.Interfaces;
namespace Vecto3GUI2020Test.BugReports
{
[TestFixture]
public class VifTests : ViewModelTestBase
{
public const string primaryDecimalTestFile = "PrimaryDecimal/primary_heavyBus group41_nonSmart_rounded_decimals.xml";
[TestCase(VifTests.primaryDecimalTestFile, TestName="PneumaticsCompressorDrive")]
public async Task CreateAndLoadVifWithWrongDecimalCount(string fileName)
{
//Load JobFile
var jobListViewModel = _kernel.Get<IJobListViewModel>() as JobListViewModel;
await jobListViewModel.AddJobAsync(GetFullPath(fileName: fileName));
Assert.AreEqual(1, jobListViewModel.Jobs.Count);
jobListViewModel.Jobs[0].Selected = true;
//Start Simulation
TestContext.Write("Starting simulation ... ");
Stopwatch stop = Stopwatch.StartNew();
await jobListViewModel.RunSimulationExecute();
stop.Stop();
TestContext.WriteLine($"Done! ({stop.Elapsed.TotalSeconds}s)");
var vifName = fileName.Replace(".xml", "RSLT_VIF.xml");
await jobListViewModel.AddJobAsync(GetFullPath(fileName: vifName));
Assert.AreEqual(2, jobListViewModel.Jobs.Count);
return;
}
#region Overrides of ViewModelTestBase
protected override string GetFullPath(string fileName)
{
fileName = "/bugreports/" + primaryDecimalTestFile;
return base.GetFullPath(fileName);
}
#endregion
}
}
......@@ -109,6 +109,9 @@
<None Update="inputdata\vecto_vehicle-completed_heavyBus_31b.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestData\bugreports\PrimaryDecimal\primary_heavyBus group41_nonSmart_rounded_decimals.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="TestData\exempted_primary_heavyBus.VIF.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
......@@ -126,4 +129,8 @@
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="Testdata\bugreports\" />
</ItemGroup>
</Project>
......@@ -2,7 +2,8 @@
using System.Collections.ObjectModel;
using NUnit.Framework;
using TUGraz.VectoCommon.Models;
using VECTO3GUI2020.Helper;
using TUGraz.VectoCommon.Utils;
using EnumHelper = VECTO3GUI2020.Helper.EnumHelper;
namespace Vecto3GUI2020Test.ViewModelTests
{
......@@ -38,6 +39,25 @@ namespace Vecto3GUI2020Test.ViewModelTests
Assert.False(collection2.Contains(VehicleCode.NOT_APPLICABLE));
}
[TestCase(1.000, 3U, "1.000")]
[TestCase(1.210, 3U, "1.210")]
[TestCase(1.201, 3U, "1.201")]
[TestCase(1.3, 3U, "1.300")]
public void ToMinSignificantDigitsExtensionTest(double input, uint significantDigits, string expected)
{
var result = input.ToMinSignificantDigits(significantDigits); //Called like this in XMLPrimaryBusVehicleReport;
Assert.AreEqual(expected, result);
}
[TestCase(1.000, 3U, 3U, "1.000")]
[TestCase(1.210, 3U, 3U, "1.210")]
[TestCase(1.201, 3U, 3U, "1.201")]
[TestCase(1.3, 3U, 3U, "1.300")]
public void ToMinSignificantDigitsExtensionTest2(double input, uint significantDigits, uint decimals, string expected)
{
var result = input.ToMinSignificantDigits(significantDigits, decimals); //Called like this in XMLPrimaryBusVehicleReport;
Assert.AreEqual(expected, result);
}
}
}
\ No newline at end of file
......@@ -71,6 +71,7 @@ namespace Vecto3GUI2020Test.ViewModelTests
}
[Test]
public void CreateVifWrongDecimal()
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment