Improve failure logging, move unstable test to FixNeeded
This commit is contained in:
parent
d68a5d6d07
commit
e580c886a9
2 changed files with 27 additions and 21 deletions
|
|
@ -48,21 +48,23 @@ namespace MatterControl.Tests
|
|||
private string meshPathAndFileName;
|
||||
private string pathToMesh = Path.Combine("..", "..", "..", "TestData", "TestMeshes", "LibraryProviderData");
|
||||
|
||||
public LibraryProviderTests()
|
||||
{
|
||||
#if !__ANDROID__
|
||||
// Set the static data to point to the directory of MatterControl
|
||||
StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(Path.Combine("..", "..", "..", "..", "StaticData"));
|
||||
#endif
|
||||
}
|
||||
|
||||
private event EventHandler unregisterEvents;
|
||||
|
||||
[Test]
|
||||
public LibraryProviderTests()
|
||||
{
|
||||
#if !__ANDROID__
|
||||
// Set the static data to point to the directory of MatterControl
|
||||
StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(Path.Combine("..", "..", "..", "..", "StaticData"));
|
||||
#endif
|
||||
}
|
||||
|
||||
// Timing issues make this test is too unstable to run. The DataReloaded event frequently resets the
|
||||
// dataReloaded variable right after being set to false, resulting in a test failure where dataReloaded is
|
||||
// asserted to be false but is not. It repros best via command line but does fail in Visual Studio on release
|
||||
// builds if you run it enough times
|
||||
[Test, Category("FixNeeded")]
|
||||
public void LibraryProviderFileSystem_NavigationWorking()
|
||||
{
|
||||
StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(Path.Combine("..", "..", "..", "..", "StaticData"));
|
||||
|
||||
string downloadsDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Downloads");
|
||||
string testLibraryDirectory = Path.Combine(downloadsDirectory, "LibraryProviderFileSystemTest");
|
||||
if (Directory.Exists(testLibraryDirectory))
|
||||
|
|
@ -73,22 +75,26 @@ namespace MatterControl.Tests
|
|||
Directory.CreateDirectory(testLibraryDirectory);
|
||||
|
||||
LibraryProviderFileSystem testProvider = new LibraryProviderFileSystem(testLibraryDirectory, "TestPath", null, null);
|
||||
testProvider.DataReloaded += (sender, e) => { dataReloaded = true; };
|
||||
testProvider.DataReloaded += (s, e) => { dataReloaded = true; };
|
||||
|
||||
Assert.IsTrue(testProvider.CollectionCount == 0, "Start with a new database for these tests.");
|
||||
Assert.IsTrue(testProvider.ItemCount == 0, "Start with a new database for these tests.");
|
||||
|
||||
// create a collection and make sure it is on disk
|
||||
dataReloaded = false; // it has been loaded for the default set of parts
|
||||
|
||||
string collectionName = "Collection1";
|
||||
string createdDirectory = Path.Combine(testLibraryDirectory, collectionName);
|
||||
Assert.IsTrue(!Directory.Exists(createdDirectory));
|
||||
Assert.IsTrue(dataReloaded == false);
|
||||
|
||||
Assert.IsFalse(Directory.Exists(createdDirectory), "CreatedDirectory should *not* exist");
|
||||
Assert.IsFalse(dataReloaded, "Reload should *not* have occurred");
|
||||
|
||||
testProvider.AddCollectionToLibrary(collectionName);
|
||||
Thread.Sleep(500); // wait for the add to finish
|
||||
Assert.IsTrue(testProvider.CollectionCount == 1);
|
||||
Assert.IsTrue(dataReloaded == true);
|
||||
Assert.IsTrue(Directory.Exists(createdDirectory));
|
||||
|
||||
Assert.AreEqual(1, testProvider.CollectionCount, "Incorrect collection count");
|
||||
Assert.IsTrue(dataReloaded, "Reload should *have* occurred");
|
||||
Assert.IsTrue(Directory.Exists(createdDirectory), "CreatedDirectory *should* exist");
|
||||
|
||||
// add an item works correctly
|
||||
LibraryProvider subProvider = testProvider.GetProviderForCollection(testProvider.GetCollectionItem(0));
|
||||
|
|
@ -96,11 +102,11 @@ namespace MatterControl.Tests
|
|||
dataReloaded = false;
|
||||
//itemAdded = false;
|
||||
string subPathAndFile = Path.Combine(createdDirectory, meshFileName);
|
||||
Assert.IsTrue(!File.Exists(subPathAndFile));
|
||||
Assert.IsTrue(dataReloaded == false);
|
||||
Assert.IsFalse(File.Exists(subPathAndFile), "File should *not* exist: " + subPathAndFile);
|
||||
Assert.IsFalse(dataReloaded, "Reload should *not* have occurred");
|
||||
//Assert.IsTrue(itemAdded == false);
|
||||
|
||||
// WIP: saving the name incorectly for this location (does not need to be changed).
|
||||
// WIP: saving the name incorrectly for this location (does not need to be changed).
|
||||
subProvider.AddFilesToLibrary(new string[] { meshPathAndFileName });
|
||||
Thread.Sleep(3000); // wait for the add to finish
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue