public void LibraryProviderSqlite_NavigationWorking()
        {
            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; };
            Thread.Sleep(3000);             // wait for the library to finish initializing
            UiThread.InvokePendingActions();
            Assert.IsTrue(testProvider.CollectionCount == 0, "Start with a new database for these tests.");
            Assert.IsTrue(testProvider.ItemCount == 3, "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";

            Assert.IsTrue(!NamedCollectionExists(collectionName));             // assert that the record does not exist in the DB
            Assert.IsTrue(dataReloaded == false);
            testProvider.AddCollectionToLibrary(collectionName);
            Assert.IsTrue(testProvider.CollectionCount == 1);
            Assert.IsTrue(dataReloaded == true);
            Assert.IsTrue(NamedCollectionExists(collectionName));             // assert that the record does exist in the DB

            PrintItemWrapper itemAtRoot = testProvider.GetPrintItemWrapperAsync(0).Result;

            // add an item works correctly
            dataReloaded = false;
            Assert.IsTrue(!NamedItemExists(collectionName));
            Assert.IsTrue(dataReloaded == false);

            testProvider.AddFilesToLibrary(new string[] { meshPathAndFileName });
            Thread.Sleep(3000);             // wait for the add to finish
            UiThread.InvokePendingActions();

            Assert.IsTrue(testProvider.ItemCount == 4);
            Assert.IsTrue(dataReloaded == true);
            string fileNameWithExtension = Path.GetFileNameWithoutExtension(meshPathAndFileName);

            Assert.IsTrue(NamedItemExists(fileNameWithExtension));

            // make sure the provider locater is correct

            // remove item works
            dataReloaded = false;
            Assert.IsTrue(dataReloaded == false);
            testProvider.RemoveItem(0);
            Assert.IsTrue(dataReloaded == true);
            Assert.IsTrue(!NamedItemExists(fileNameWithExtension));

            // remove collection gets rid of it
            dataReloaded = false;
            Assert.IsTrue(dataReloaded == false);
            testProvider.RemoveCollection(0);
            Assert.IsTrue(dataReloaded == true);
            Assert.IsTrue(testProvider.CollectionCount == 0);
            Assert.IsTrue(!NamedCollectionExists(collectionName));             // assert that the record does not exist in the DB

            //MatterControlUtilities.RestoreStaticDataAfterTesting(staticDataState, true);
        }
        public void LibraryProviderSqlite_NavigationWorking()
        {
            Datastore.Instance.Initialize();
            LibraryProviderSQLite testProvider = new LibraryProviderSQLite(null, null);

            Thread.Sleep(3000);             // wait for the library to finish initializing
            Assert.IsTrue(testProvider.CollectionCount == 0, "Start with a new database for these tests.");
            Assert.IsTrue(testProvider.ItemCount == 1, "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";

            Assert.IsTrue(!NamedCollectionExists(collectionName));             // assert that the record does not exist in the DB
            Assert.IsTrue(dataReloaded == false);
            testProvider.AddCollectionToLibrary(collectionName);
            Assert.IsTrue(testProvider.CollectionCount == 1);
            Assert.IsTrue(dataReloaded == true);
            Assert.IsTrue(NamedCollectionExists(collectionName));             // assert that the record does exist in the DB

            PrintItemWrapper           itemAtRoot      = testProvider.GetPrintItemWrapper(0);
            List <ProviderLocatorNode> providerLocator = itemAtRoot.PrintItem.GetLibraryProviderLocator();

            Assert.IsTrue(providerLocator.Count == 1);

            // add an item works correctly
            dataReloaded = false;
            Assert.IsTrue(!NamedItemExists(collectionName));
            Assert.IsTrue(dataReloaded == false);

            testProvider.AddFilesToLibrary(new string[] { meshPathAndFileName });
            Thread.Sleep(3000);             // wait for the add to finihs

            Assert.IsTrue(testProvider.ItemCount == 2);
            Assert.IsTrue(dataReloaded == true);
            string fileNameWithExtension = Path.GetFileNameWithoutExtension(meshPathAndFileName);

            Assert.IsTrue(NamedItemExists(fileNameWithExtension));

            // make sure the provider locator is correct

            // remove item works
            dataReloaded = false;
            Assert.IsTrue(dataReloaded == false);
            testProvider.RemoveItem(testProvider.GetPrintItemWrapper(1));
            Assert.IsTrue(dataReloaded == true);
            Assert.IsTrue(!NamedItemExists(fileNameWithExtension));

            // remove collection gets rid of it
            dataReloaded = false;
            Assert.IsTrue(dataReloaded == false);
            testProvider.RemoveCollection(testProvider.GetCollectionItem(0));
            Assert.IsTrue(dataReloaded == true);
            Assert.IsTrue(testProvider.CollectionCount == 0);
            Assert.IsTrue(!NamedCollectionExists(collectionName));             // assert that the record does not exist in the DB
        }