Upgrade to NUnit3
- Revise hard-coded paths for compatibility with new VS adapter - Add utility functions for path generation - Extract SHA1 computation from Save function - Add ToJson helper function - Don't save SHA1 in computed document - Remove Asserts from CloseMatterControl, extend wait period - Add TestAutomationConfig type replacing serialized Dictionary
This commit is contained in:
parent
d0282730d8
commit
ee52f24835
25 changed files with 251 additions and 274 deletions
|
|
@ -33,32 +33,45 @@
|
|||
<PlatformTarget>x86</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Mono.Cecil, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\NUnit3TestAdapter.3.4.1\lib\Mono.Cecil.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Mono.Cecil.Mdb, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\NUnit3TestAdapter.3.4.1\lib\Mono.Cecil.Mdb.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Mono.Cecil.Pdb, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\NUnit3TestAdapter.3.4.1\lib\Mono.Cecil.Pdb.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Mono.Cecil.Rocks, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\NUnit3TestAdapter.3.4.1\lib\Mono.Cecil.Rocks.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="NUnit.ApplicationDomain">
|
||||
<HintPath>..\..\packages\NUnit.ApplicationDomain.5.0.1\lib\net40\NUnit.ApplicationDomain.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.core, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="nunit.core.interfaces, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.interfaces.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
|
||||
<Reference Include="NUnit.ApplicationDomain, Version=8.0.0.0, Culture=neutral, PublicKeyToken=afbd8211e0c40e2c, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\NUnit.ApplicationDomain.8.0.0\lib\net40\NUnit.ApplicationDomain.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="nunit.util, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\NUnitTestAdapter.2.0.0\lib\nunit.util.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<Reference Include="nunit.engine, Version=3.4.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\NUnit3TestAdapter.3.4.1\lib\nunit.engine.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="NUnit.VisualStudio.TestAdapter, Version=2.0.0.0, Culture=neutral, PublicKeyToken=4cb40d35494691ac, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\NUnitTestAdapter.2.0.0\lib\NUnit.VisualStudio.TestAdapter.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<Reference Include="nunit.engine.api, Version=3.0.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\NUnit3TestAdapter.3.4.1\lib\nunit.engine.api.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework, Version=3.4.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\NUnit.3.4.1\lib\net45\nunit.framework.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="NUnit3.TestAdapter, Version=3.4.1.0, Culture=neutral, PublicKeyToken=4cb40d35494691ac, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\NUnit3TestAdapter.3.4.1\lib\NUnit3.TestAdapter.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.XML" />
|
||||
|
|
|
|||
|
|
@ -44,13 +44,12 @@ namespace MatterControl.Tests.MatterControl
|
|||
[TestFixture]
|
||||
public class GCodeProcessingTests
|
||||
{
|
||||
[Test, Category("GCodeProcessing"), Category("FixNeeded" /* Disabled until MCWS production is updated */)]
|
||||
[Test, Category("GCodeProcessing")]
|
||||
public void ReplaceMacroValuesWorking()
|
||||
{
|
||||
StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(Path.Combine("..", "..", "..", "..", "StaticData"));
|
||||
|
||||
MatterControlUtilities.OverrideAppDataLocation();
|
||||
|
||||
StaticData.Instance = new FileSystemStaticData(TestContext.CurrentContext.ResolveProjectPath(4, "StaticData"));
|
||||
MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(4));
|
||||
|
||||
TestMacroReplacement("[temperature]", "200");
|
||||
TestMacroReplacement("[first_layer_speed]", "1080");
|
||||
TestMacroReplacement("[bed_remove_part_temperature]", "0");
|
||||
|
|
|
|||
|
|
@ -27,17 +27,14 @@ of the authors and should not be interpreted as representing official policies,
|
|||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.PlatformAbstract;
|
||||
using MatterHackers.MatterControl.PrinterCommunication;
|
||||
using MatterHackers.MatterControl.PrinterCommunication.Io;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using MatterHackers.MatterControl.Tests.Automation;
|
||||
using MatterHackers.VectorMath;
|
||||
using NUnit.Framework;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
||||
namespace MatterControl.Tests.MatterControl
|
||||
{
|
||||
|
|
@ -73,9 +70,8 @@ namespace MatterControl.Tests.MatterControl
|
|||
null,
|
||||
};
|
||||
|
||||
StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(Path.Combine("..", "..", "..", "..", "StaticData"));
|
||||
|
||||
MatterControlUtilities.OverrideAppDataLocation();
|
||||
StaticData.Instance = new FileSystemStaticData(TestContext.CurrentContext.ResolveProjectPath(4, "StaticData"));
|
||||
MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(4));
|
||||
|
||||
MaxLengthStream maxLengthStream = new MaxLengthStream(new TestGCodeStream(lines), 6);
|
||||
|
||||
|
|
@ -158,9 +154,8 @@ namespace MatterControl.Tests.MatterControl
|
|||
null,
|
||||
};
|
||||
|
||||
StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(Path.Combine("..", "..", "..", "..", "StaticData"));
|
||||
|
||||
MatterControlUtilities.OverrideAppDataLocation();
|
||||
StaticData.Instance = new FileSystemStaticData(TestContext.CurrentContext.ResolveProjectPath(4, "StaticData"));
|
||||
MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(4));
|
||||
|
||||
List<GCodeStream> streamList;
|
||||
GCodeStream testStream = CreateTestGCodeStream(inputLines, out streamList);
|
||||
|
|
@ -213,9 +208,8 @@ namespace MatterControl.Tests.MatterControl
|
|||
null,
|
||||
};
|
||||
|
||||
StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(Path.Combine("..", "..", "..", "..", "StaticData"));
|
||||
|
||||
MatterControlUtilities.OverrideAppDataLocation();
|
||||
StaticData.Instance = new FileSystemStaticData(TestContext.CurrentContext.ResolveProjectPath(4, "StaticData"));
|
||||
MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(4));
|
||||
|
||||
List<GCodeStream> streamList;
|
||||
GCodeStream testStream = CreateTestGCodeStream(inputLines, out streamList);
|
||||
|
|
@ -287,9 +281,8 @@ namespace MatterControl.Tests.MatterControl
|
|||
null,
|
||||
};
|
||||
|
||||
StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(Path.Combine("..", "..", "..", "..", "StaticData"));
|
||||
|
||||
MatterControlUtilities.OverrideAppDataLocation();
|
||||
StaticData.Instance = new FileSystemStaticData(TestContext.CurrentContext.ResolveProjectPath(4, "StaticData"));
|
||||
MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(4));
|
||||
|
||||
List<GCodeStream> streamList;
|
||||
GCodeStream pauseHandlingStream = CreateTestGCodeStream(inputLines, out streamList);
|
||||
|
|
@ -362,9 +355,8 @@ namespace MatterControl.Tests.MatterControl
|
|||
null,
|
||||
};
|
||||
|
||||
StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(Path.Combine("..", "..", "..", "..", "StaticData"));
|
||||
|
||||
MatterControlUtilities.OverrideAppDataLocation();
|
||||
StaticData.Instance = new FileSystemStaticData(TestContext.CurrentContext.ResolveProjectPath(4, "StaticData"));
|
||||
MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(4));
|
||||
|
||||
// this is the pause and resume from the Eris
|
||||
PrinterSettings settings = ActiveSliceSettings.Instance;
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ of the authors and should not be interpreted as representing official policies,
|
|||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.PlatformAbstract;
|
||||
using MatterHackers.GCodeVisualizer;
|
||||
|
|
@ -35,25 +36,17 @@ using MatterHackers.MatterControl.SlicerConfiguration;
|
|||
using MatterHackers.MatterControl.Tests.Automation;
|
||||
using MatterHackers.VectorMath;
|
||||
using NUnit.Framework;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace MatterControl.Tests.MatterControl
|
||||
{
|
||||
[TestFixture]
|
||||
public class LevelingTests
|
||||
{
|
||||
static LevelingTests()
|
||||
{
|
||||
MatterControlUtilities.OverrideAppDataLocation();
|
||||
}
|
||||
|
||||
[Test, Category("Leveling")]
|
||||
public void Leveling7PointsNeverGetsTooHigh()
|
||||
{
|
||||
StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(Path.Combine("..", "..", "..", "..", "StaticData"));
|
||||
|
||||
MatterControlUtilities.OverrideAppDataLocation();
|
||||
StaticData.Instance = new FileSystemStaticData(TestContext.CurrentContext.ResolveProjectPath(4, "StaticData"));
|
||||
MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(4));
|
||||
|
||||
var levelingData = new PrintLevelingData(ActiveSliceSettings.Instance);
|
||||
|
||||
|
|
@ -93,9 +86,8 @@ namespace MatterControl.Tests.MatterControl
|
|||
[Test, Category("Leveling")]
|
||||
public void Leveling7PointsCorectInterpolation()
|
||||
{
|
||||
StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(Path.Combine("..", "..", "..", "..", "StaticData"));
|
||||
|
||||
MatterControlUtilities.OverrideAppDataLocation();
|
||||
StaticData.Instance = new FileSystemStaticData(TestContext.CurrentContext.ResolveProjectPath(4, "StaticData"));
|
||||
MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(4));
|
||||
|
||||
var levelingData = new PrintLevelingData(ActiveSliceSettings.Instance);
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,9 @@ of the authors and should not be interpreted as representing official policies,
|
|||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.PlatformAbstract;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.MatterControl.DataStorage;
|
||||
|
|
@ -34,9 +37,6 @@ using MatterHackers.MatterControl.PrintLibrary.Provider;
|
|||
using MatterHackers.MatterControl.PrintQueue;
|
||||
using MatterHackers.MatterControl.Tests.Automation;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
|
||||
namespace MatterHackers.MatterControl.Tests
|
||||
{
|
||||
|
|
@ -44,25 +44,20 @@ namespace MatterHackers.MatterControl.Tests
|
|||
public class LibraryProviderSqliteTests
|
||||
{
|
||||
private bool dataReloaded = false;
|
||||
private string meshFileName = "Box20x20x10.stl";
|
||||
private string meshPathAndFileName;
|
||||
private string pathToMesh = Path.Combine("..", "..", "..", "TestData", "TestMeshes", "LibraryProviderData");
|
||||
private string meshPathAndFileName = TestContext.CurrentContext.ResolveProjectPath(4, "Tests", "TestData", "TestMeshes", "LibraryProviderData", "Box20x20x10.stl");
|
||||
|
||||
public LibraryProviderSqliteTests()
|
||||
[SetUp]
|
||||
public void SetupBeforeTest()
|
||||
{
|
||||
#if !__ANDROID__
|
||||
// Set the static data to point to the directory of MatterControl
|
||||
StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(Path.Combine("..", "..", "..", "..", "StaticData"));
|
||||
#endif
|
||||
dataReloaded = false;
|
||||
}
|
||||
|
||||
private event EventHandler unregisterEvents;
|
||||
|
||||
#if !__ANDROID__
|
||||
[Test, RunInApplicationDomain, Category("FixNeeded" /* Disabled until MCWS production is updated */)]
|
||||
public void LibraryProviderSqlite_NavigationWorking()
|
||||
{
|
||||
MatterControlUtilities.OverrideAppDataLocation();
|
||||
StaticData.Instance = new FileSystemStaticData(TestContext.CurrentContext.ResolveProjectPath(4, "StaticData"));
|
||||
MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(4));
|
||||
|
||||
LibraryProviderSQLite testProvider = new LibraryProviderSQLite(null, null, null, "Local Library");
|
||||
testProvider.DataReloaded += (sender, e) => { dataReloaded = true; };
|
||||
|
|
@ -118,23 +113,6 @@ namespace MatterHackers.MatterControl.Tests
|
|||
}
|
||||
#endif
|
||||
|
||||
[SetUp]
|
||||
public void SetupBeforeTest()
|
||||
{
|
||||
meshPathAndFileName = Path.Combine(pathToMesh, meshFileName);
|
||||
|
||||
dataReloaded = false;
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TeardownAfterTest()
|
||||
{
|
||||
if (unregisterEvents != null)
|
||||
{
|
||||
unregisterEvents(this, null);
|
||||
}
|
||||
}
|
||||
|
||||
private bool NamedCollectionExists(string nameToLookFor)
|
||||
{
|
||||
string query = string.Format("SELECT * FROM PrintItemCollection WHERE Name = '{0}' ORDER BY Name ASC;", nameToLookFor);
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ using System.Collections.Generic;
|
|||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using MatterHackers.MatterControl.Tests.Automation;
|
||||
using MatterHackers.Agg;
|
||||
|
||||
namespace MatterControl.Tests
|
||||
{
|
||||
|
|
@ -44,17 +46,14 @@ namespace MatterControl.Tests
|
|||
public class LibraryProviderTests
|
||||
{
|
||||
private bool dataReloaded = false;
|
||||
private string meshFileName = "Box20x20x10.stl";
|
||||
private string meshPathAndFileName;
|
||||
private string pathToMesh = Path.Combine("..", "..", "..", "TestData", "TestMeshes", "LibraryProviderData");
|
||||
|
||||
private event EventHandler unregisterEvents;
|
||||
private const string meshFileName = "Box20x20x10.stl";
|
||||
private string meshPathAndFileName = TestContext.CurrentContext.ResolveProjectPath(5, "MatterControl", "Tests", "TestData", "TestMeshes", "LibraryProviderData", meshFileName);
|
||||
|
||||
public LibraryProviderTests()
|
||||
{
|
||||
#if !__ANDROID__
|
||||
// Set the static data to point to the directory of MatterControl
|
||||
StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(Path.Combine("..", "..", "..", "..", "StaticData"));
|
||||
StaticData.Instance = new FileSystemStaticData(TestContext.CurrentContext.ResolveProjectPath(4, "StaticData"));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -145,20 +144,9 @@ namespace MatterControl.Tests
|
|||
[SetUp]
|
||||
public void SetupBeforeTest()
|
||||
{
|
||||
meshPathAndFileName = Path.Combine(pathToMesh, meshFileName);
|
||||
|
||||
dataReloaded = false;
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TeardownAfterTest()
|
||||
{
|
||||
if (unregisterEvents != null)
|
||||
{
|
||||
unregisterEvents(this, null);
|
||||
}
|
||||
}
|
||||
|
||||
private bool NamedCollectionExists(string nameToLookFor)
|
||||
{
|
||||
string query = string.Format("SELECT * FROM PrintItemCollection WHERE Name = '{0}' ORDER BY Name ASC;", nameToLookFor);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,13 @@ of the authors and should not be interpreted as representing official policies,
|
|||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Image;
|
||||
using MatterHackers.Agg.PlatformAbstract;
|
||||
using MatterHackers.Agg.UI;
|
||||
|
|
@ -36,11 +43,6 @@ using MatterHackers.MatterControl.DataStorage;
|
|||
using MatterHackers.MatterControl.PrintLibrary.Provider;
|
||||
using Newtonsoft.Json;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace MatterHackers.MatterControl.Tests.Automation
|
||||
{
|
||||
|
|
@ -110,8 +112,9 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
public static void CloseMatterControl(AutomationRunner testRunner)
|
||||
{
|
||||
SystemWindow mcWindowLocal = MatterControlApplication.Instance;
|
||||
Assert.IsTrue(testRunner.ClickByName("File Menu", 2));
|
||||
Assert.IsTrue(testRunner.ClickByName("Exit Menu Item", 2));
|
||||
testRunner.ClickByName("File Menu", 5);
|
||||
testRunner.ClickByName("Exit Menu Item", 5);
|
||||
|
||||
testRunner.Wait(.2);
|
||||
if (mcWindowLocal.Parent != null)
|
||||
{
|
||||
|
|
@ -137,49 +140,17 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
|
||||
public static Process LaunchAndConnectToPrinterEmulator(AutomationRunner testRunner)
|
||||
{
|
||||
// check for the settings file
|
||||
string testConfigDataPath = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "MCTestConfig");
|
||||
var emulatorPath = Path.Combine(testConfigDataPath, "PrinterEmulatorConfig.json");
|
||||
// Load the TestEnv config
|
||||
var config = TestAutomationConfig.Load();
|
||||
|
||||
// if no file create it
|
||||
if(!File.Exists(emulatorPath))
|
||||
{
|
||||
Directory.CreateDirectory(testConfigDataPath);
|
||||
|
||||
Dictionary<string, string> userSettings = new Dictionary<string, string>()
|
||||
{
|
||||
["MCPort"] = "",
|
||||
["Printer"] = "",
|
||||
};
|
||||
|
||||
File.WriteAllText(emulatorPath, JsonConvert.SerializeObject(userSettings, Formatting.Indented));
|
||||
}
|
||||
|
||||
|
||||
// open the settings file
|
||||
var jsonDict = JsonConvert.DeserializeObject<Dictionary<string, string>>(File.ReadAllText(emulatorPath));
|
||||
|
||||
// if no com port set, issue instructions on how to set it
|
||||
if(!jsonDict.ContainsKey("MCPort")
|
||||
|| !jsonDict.ContainsKey("Printer")
|
||||
|| string.IsNullOrEmpty(jsonDict["MCPort"])
|
||||
|| string.IsNullOrEmpty(jsonDict["Printer"]))
|
||||
{
|
||||
throw new Exception("You must set the port and printer in: " + emulatorPath);
|
||||
}
|
||||
|
||||
// create the printer
|
||||
//Create printer for sync to see
|
||||
// Create the printer
|
||||
MatterControlUtilities.AddAndSelectPrinter(testRunner, "Airwolf 3D", "HD");
|
||||
|
||||
string comPort = jsonDict["MCPort"];
|
||||
string printerPort = jsonDict["Printer"];
|
||||
|
||||
var process = new Process();
|
||||
process.StartInfo = new ProcessStartInfo()
|
||||
{
|
||||
FileName = "python",
|
||||
Arguments = string.Format("{0} {1}", StaticData.Instance.MapPath("../PrinterEmulator.py"), printerPort),
|
||||
Arguments = string.Format("{0} {1}", StaticData.Instance.MapPath("../PrinterEmulator.py"), config.Printer),
|
||||
WindowStyle = ProcessWindowStyle.Minimized
|
||||
};
|
||||
|
||||
|
|
@ -191,7 +162,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
|
||||
testRunner.ClickByName("Com Port Dropdown");
|
||||
|
||||
testRunner.ClickByName(comPort + " Menu Item", 1);
|
||||
testRunner.ClickByName(config.MCPort + " Menu Item", 1);
|
||||
|
||||
testRunner.ClickByName("Cancel Wizard Button");
|
||||
|
||||
|
|
@ -276,7 +247,6 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
testRunner.ClickByName(printer, 2);
|
||||
|
||||
testRunner.ClickByName("Save & Continue Button", 2);
|
||||
|
||||
testRunner.Wait(2);
|
||||
|
||||
testRunner.ClickByName("Cancel Wizard Button", 2);
|
||||
|
|
@ -309,12 +279,10 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
/// <summary>
|
||||
/// Overrides the AppData location, ensuring each test starts with a fresh MatterControl database.
|
||||
/// </summary>
|
||||
public static void OverrideAppDataLocation()
|
||||
public static void OverrideAppDataLocation(string matterControlDirectory)
|
||||
{
|
||||
string tempFolderPath = Path.GetFullPath(Path.Combine("..", "..", "..", "..", "Tests","temp"));
|
||||
|
||||
ApplicationDataStorage.Instance.OverrideAppDataLocation(
|
||||
Path.Combine(tempFolderPath, runName, $"Test{testID++}"));
|
||||
string tempFolderPath = Path.Combine(matterControlDirectory, "Tests","temp", runName, $"Test{testID++}");
|
||||
ApplicationDataStorage.Instance.OverrideAppDataLocation(tempFolderPath);
|
||||
}
|
||||
|
||||
public static void AddItemsToQueue(string queueItemFolderToLoad)
|
||||
|
|
@ -391,14 +359,16 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
|
||||
if (staticDataPathOverride == null)
|
||||
{
|
||||
staticDataPathOverride = Path.Combine("..", "..", "..", "..", "StaticData");
|
||||
// Popping one directory above MatterControl, then back down into MatterControl ensures this works in MCCentral as well and MatterControl
|
||||
staticDataPathOverride = TestContext.CurrentContext.ResolveProjectPath(5, "MatterControl", "StaticData");
|
||||
}
|
||||
|
||||
#if !__ANDROID__
|
||||
// Set the static data to point to the directory of MatterControl
|
||||
StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(staticDataPathOverride);
|
||||
StaticData.Instance = new FileSystemStaticData(staticDataPathOverride);
|
||||
#endif
|
||||
MatterControlUtilities.OverrideAppDataLocation();
|
||||
// Popping one directory above MatterControl, then back down into MatterControl ensures this works in MCCentral as well and MatterControl
|
||||
MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(5, "MatterControl"));
|
||||
|
||||
if (queueItemFolderToAdd != QueueTemplate.None)
|
||||
{
|
||||
|
|
@ -433,6 +403,21 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
testRunner.ClickByName("LibraryActionMenu");
|
||||
testRunner.ClickByName("Remove Menu Item", 1);
|
||||
}
|
||||
|
||||
public static string ResolveProjectPath(this TestContext context, int stepsToProjectRoot, params string[] relativePathSteps)
|
||||
{
|
||||
string assemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
|
||||
var allPathSteps = new List<string> { assemblyPath };
|
||||
allPathSteps.AddRange(Enumerable.Repeat("..", stepsToProjectRoot));
|
||||
|
||||
if (relativePathSteps.Any())
|
||||
{
|
||||
allPathSteps.AddRange(relativePathSteps);
|
||||
}
|
||||
|
||||
return Path.GetFullPath(Path.Combine(allPathSteps.ToArray()));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -444,4 +429,55 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
None,
|
||||
Three_Queue_Items
|
||||
}
|
||||
|
||||
public class TestAutomationConfig
|
||||
{
|
||||
private static readonly string configPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "MHTest.config");
|
||||
|
||||
/// <summary>
|
||||
/// The ClientToken used by tests to emulate an external client
|
||||
/// </summary>
|
||||
public string TestEnvClientToken { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The serial port that MatterControl will communicate with for the Com0Com connection
|
||||
/// </summary>
|
||||
public string MCPort { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The serial port that Python will communicate with to emulate printer firmware
|
||||
/// </summary>
|
||||
public string Printer { get; set; }
|
||||
|
||||
public static TestAutomationConfig Load()
|
||||
{
|
||||
TestAutomationConfig config = null;
|
||||
|
||||
if (!File.Exists(configPath))
|
||||
{
|
||||
config = new TestAutomationConfig();
|
||||
config.Save();
|
||||
}
|
||||
else
|
||||
{
|
||||
config = JsonConvert.DeserializeObject<TestAutomationConfig>(File.ReadAllText(configPath));
|
||||
}
|
||||
|
||||
// if no com port set, issue instructions on how to set it
|
||||
if (string.IsNullOrEmpty(config.MCPort) || string.IsNullOrEmpty(config.Printer))
|
||||
{
|
||||
throw new Exception("You must set the port and printer in: " + configPath);
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Persist the current settings to the 'MHTest.config' in the user profile - %userprofile%\MHTest.config
|
||||
/// </summary>
|
||||
public void Save()
|
||||
{
|
||||
File.WriteAllText(configPath, JsonConvert.SerializeObject(this, Formatting.Indented));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,17 +1,12 @@
|
|||
using MatterHackers.MatterControl;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Globalization;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using System.Collections.ObjectModel;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.PlatformAbstract;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using MatterHackers.MatterControl.Tests.Automation;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MatterControl.Tests.MatterControl
|
||||
{
|
||||
|
|
@ -19,14 +14,12 @@ namespace MatterControl.Tests.MatterControl
|
|||
public class OemProfileTests
|
||||
{
|
||||
private static List<PrinterConfig> allPrinters;
|
||||
private static string matterControlDirectory = Path.GetFullPath(Path.Combine("..", "..", "..", ".."));
|
||||
private static string printerSettingsDirectory = Path.GetFullPath(Path.Combine(matterControlDirectory, "StaticData", "Profiles"));
|
||||
private static string printerSettingsDirectory = TestContext.CurrentContext.ResolveProjectPath(4, "StaticData", "Profiles");
|
||||
|
||||
static OemProfileTests()
|
||||
{
|
||||
MatterControlUtilities.OverrideAppDataLocation();
|
||||
|
||||
StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(Path.Combine(matterControlDirectory, "StaticData"));
|
||||
StaticData.Instance = new FileSystemStaticData(TestContext.CurrentContext.ResolveProjectPath(4, "StaticData"));
|
||||
MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(4));
|
||||
|
||||
allPrinters = (from printerFile in new DirectoryInfo(printerSettingsDirectory).GetFiles("*.printer", SearchOption.AllDirectories)
|
||||
select new PrinterConfig
|
||||
|
|
@ -92,7 +85,7 @@ namespace MatterControl.Tests.MatterControl
|
|||
string bedSize = settings.GetValue(SettingsKey.bed_size);
|
||||
|
||||
// Must exist in all configs
|
||||
Assert.IsNotNullOrEmpty(bedSize, "[bed_size] must exist: " + printer.RelativeFilePath);
|
||||
Assert.IsTrue(!string.IsNullOrEmpty(bedSize), "[bed_size] must exist: " + printer.RelativeFilePath);
|
||||
|
||||
string[] segments = bedSize.Trim().Split(',');
|
||||
|
||||
|
|
@ -115,7 +108,7 @@ namespace MatterControl.Tests.MatterControl
|
|||
string printCenter = settings.GetValue(SettingsKey.print_center);
|
||||
|
||||
// Must exist in all configs
|
||||
Assert.IsNotNullOrEmpty(printCenter, "[print_center] must exist: " + printer.RelativeFilePath);
|
||||
Assert.IsTrue(!string.IsNullOrEmpty(printCenter), "[print_center] must exist: " + printer.RelativeFilePath);
|
||||
|
||||
string[] segments = printCenter.Trim().Split(',');
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,11 @@
|
|||
using MatterHackers.MatterControl;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Globalization;
|
||||
using MatterHackers.MatterControl.SettingsManagement;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.PlatformAbstract;
|
||||
using MatterHackers.MatterControl;
|
||||
using MatterHackers.MatterControl.SettingsManagement;
|
||||
using MatterHackers.MatterControl.Tests.Automation;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MatterControl.Tests.MatterControl
|
||||
{
|
||||
|
|
@ -19,9 +14,8 @@ namespace MatterControl.Tests.MatterControl
|
|||
[Test, Category("FixNeeded" /* Disabled until MCWS production is updated */)]
|
||||
public void PrinterChooserHonorsWhitelist()
|
||||
{
|
||||
StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(Path.Combine("..", "..", "..", "..", "StaticData"));
|
||||
|
||||
MatterControlUtilities.OverrideAppDataLocation();
|
||||
StaticData.Instance = new FileSystemStaticData(TestContext.CurrentContext.ResolveProjectPath(4, "StaticData"));
|
||||
MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(4));
|
||||
|
||||
var manufacturers = new string[] { "3D Factory", "3D Stuffmaker", "Airwolf 3D", "BCN", "BeeVeryCreative", "Blue Eagle Labs", "Deezmaker", "FlashForge", "gCreate", "IRA3D", "JumpStart", "Leapfrog", "Lulzbot", "MAKEiT", "Maker's Tool Works", "MakerBot", "MakerGear", "Me3D", "OpenBeam", "Organic Thinking System", "Other", "Portabee", "Printrbot", "PrintSpace", "Revolution 3D Printers", "ROBO 3D", "SeeMeCNC", "Solidoodle", "Tosingraf", "Type A Machines", "Ultimaker", "Velleman", "Wanhao" };
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,7 @@
|
|||
using MatterHackers.MatterControl;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Globalization;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using MatterHackers.MatterControl.Tests.Automation;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MatterControl.Tests.MatterControl
|
||||
{
|
||||
|
|
@ -18,8 +11,7 @@ namespace MatterControl.Tests.MatterControl
|
|||
[Test, Category("PrinterWhiteListTests")]
|
||||
public void DesktopCalibrationPartsInSettings()
|
||||
{
|
||||
|
||||
string settingsJsonPath = Path.GetFullPath(Path.Combine("..", "..", "..", "..", "StaticData", "OEMSettings", "Settings.json"));
|
||||
string settingsJsonPath = TestContext.CurrentContext.ResolveProjectPath(4, "StaticData", "OEMSettings", "Settings.json");
|
||||
|
||||
if (File.Exists(settingsJsonPath))
|
||||
{
|
||||
|
|
@ -32,20 +24,15 @@ namespace MatterControl.Tests.MatterControl
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
[Test, Category("SamplePartsTests")]
|
||||
public void DesktopCalibrationPartsExist()
|
||||
{
|
||||
|
||||
string samplePartsPath = Path.GetFullPath(Path.Combine("..", "..", "..", "..", "StaticData", "OEMSettings", "SampleParts"));
|
||||
string samplePartsPath = TestContext.CurrentContext.ResolveProjectPath(4, "StaticData", "OEMSettings", "SampleParts");
|
||||
string[] files = Directory.GetFiles(samplePartsPath);
|
||||
bool hasTabletStand = files.Where(l => l.Contains("MatterControl - Stand.stl")).Any();
|
||||
bool hasCoin = files.Where(l => l.Contains("MatterControl - Coin.stl")).Any();
|
||||
Assert.IsTrue(hasCoin, "Expected coin file not found");
|
||||
Assert.IsTrue(hasTabletStand, "Expected stand file not found");
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,11 +28,11 @@ either expressed or implied, of the FreeBSD Project.
|
|||
*/
|
||||
|
||||
using MatterHackers.Agg.PlatformAbstract;
|
||||
using MatterHackers.MatterControl.Tests.Automation;
|
||||
using MatterHackers.PolygonMesh;
|
||||
using MatterHackers.PolygonMesh.Processors;
|
||||
using MatterHackers.VectorMath;
|
||||
using NUnit.Framework;
|
||||
using System.IO;
|
||||
|
||||
namespace MatterHackers.MatterControl.Slicing.Tests
|
||||
{
|
||||
|
|
@ -48,8 +48,7 @@ namespace MatterHackers.MatterControl.Slicing.Tests
|
|||
return;
|
||||
}
|
||||
|
||||
string pathToMesh = Path.Combine("..", "..", "..", "TestData", "TestMeshes", "SliceLayers");
|
||||
string meshFileName = Path.Combine(pathToMesh, "Box20x20x10.stl");
|
||||
string meshFileName = TestContext.CurrentContext.ResolveProjectPath(4, "Tests", "TestData", "TestMeshes", "SliceLayers", "Box20x20x10.stl");
|
||||
Mesh cubeMesh = StlProcessing.Load(meshFileName);
|
||||
|
||||
AxisAlignedBoundingBox bounds = cubeMesh.GetAxisAlignedBoundingBox();
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ using System.Reflection;
|
|||
using System.Text;
|
||||
using System.Linq;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.MatterControl.Tests.Automation;
|
||||
|
||||
namespace MatterControl.Tests.MatterControl
|
||||
{
|
||||
|
|
@ -111,18 +112,11 @@ namespace MatterControl.Tests.MatterControl
|
|||
[Test, Category("Translations")]
|
||||
public void EnglishLinesOnlyContainEnglishCharachters()
|
||||
{
|
||||
string fullPath = TestContext.CurrentContext.ResolveProjectPath(4, "StaticData", "Translations");
|
||||
|
||||
var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory());
|
||||
string pathToMatterControlFolder = currentDirectory.Parent.Parent.Parent.Parent.FullName;
|
||||
string translationsPath = @"StaticData\Translations";
|
||||
string fullPath = Path.Combine(pathToMatterControlFolder,translationsPath);
|
||||
|
||||
string[] translationFiles = Directory.GetDirectories(fullPath);
|
||||
string translationsText = @"Translation.txt";
|
||||
|
||||
foreach (string file in translationFiles)
|
||||
foreach (string directory in Directory.GetDirectories(fullPath))
|
||||
{
|
||||
string fullPathToEachTranslation = Path.Combine(file, translationsText);
|
||||
string fullPathToEachTranslation = Path.Combine(directory, "Translation.txt");
|
||||
Console.Write(fullPathToEachTranslation);
|
||||
readTranslationFile(fullPathToEachTranslation);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,10 @@
|
|||
<assemblyIdentity name="nunit.framework" publicKeyToken="96d09a1eb7f44a77" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.6.4.14350" newVersion="2.6.4.14350" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="nunit.framework" publicKeyToken="2638cd05610744eb" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.4.1.0" newVersion="3.4.1.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net45" />
|
||||
<package id="NUnit" version="2.6.4" targetFramework="net45" />
|
||||
<package id="NUnit.ApplicationDomain" version="5.0.1" targetFramework="net45" />
|
||||
<package id="NUnitTestAdapter" version="2.0.0" targetFramework="net45" />
|
||||
<package id="NUnit" version="3.4.1" targetFramework="net45" />
|
||||
<package id="NUnit.ApplicationDomain" version="8.0.0" targetFramework="net45" />
|
||||
<package id="NUnit3TestAdapter" version="3.4.1" targetFramework="net45" />
|
||||
</packages>
|
||||
Loading…
Add table
Add a link
Reference in a new issue