private static void CreateTestSolution()
        {
            // First we create a basic solution with some sample items
            SolutionRepository SR = new SolutionRepository();

            if (Directory.Exists(TempRepositoryFolder))
            {
                Directory.Delete(TempRepositoryFolder, true);
            }

            // Define the items types we want in our Repository
            SR.AddItemInfo <MyRepositoryItem>(pattern: "*.Ginger.MyRepositoryItem.xml",   // Need to use for file name
                                              rootFolder: SolutionRepository.cSolutionRootFolderSign + "MyRepositoryItems",
                                              containRepositoryItems: true,
                                              displayName: "My Repository Item",
                                              PropertyNameForFileName: nameof(MyRepositoryItem.Name)
                                              );


            SR.CreateRepository(TempRepositoryFolder);
            SR.Open(TempRepositoryFolder);

            MyRepositoryItem A1 = new MyRepositoryItem("A1");

            SR.AddRepositoryItem(A1);

            MyRepositoryItem A2 = new MyRepositoryItem("A2");

            SR.AddRepositoryItem(A2);

            MyRepositoryItem A3 = new MyRepositoryItem("A3");

            SR.AddRepositoryItem(A3);


            RepositoryFolder <MyRepositoryItem> MyRepoRF   = SR.GetRepositoryItemRootFolder <MyRepositoryItem>();
            RepositoryFolder <MyRepositoryItem> SubFolder1 = (RepositoryFolder <MyRepositoryItem>)MyRepoRF.AddSubFolder("SubFolder1");

            MyRepoRF.AddSubFolder("EmptySubFolder");

            MyRepositoryItem A4 = new MyRepositoryItem("A4");

            SubFolder1.AddRepositoryItem(A4);

            // Folder to delete later
            MyRepoRF.AddSubFolder("SubFolderForDelete");

            // Create folders tree
            RepositoryFolder <MyRepositoryItem> SF1 = (RepositoryFolder <MyRepositoryItem>)MyRepoRF.AddSubFolder("SF1");
            RepositoryFolder <MyRepositoryItem> SF2 = (RepositoryFolder <MyRepositoryItem>)SF1.AddSubFolder("SF1_SF2");
            RepositoryFolder <MyRepositoryItem> SF3 = (RepositoryFolder <MyRepositoryItem>)SF2.AddSubFolder("SF1_SF2_SF3");
            MyRepositoryItem BF5 = new MyRepositoryItem("A5");

            SubFolder1.AddRepositoryItem(BF5);

            MyRepositoryItem BF6 = new MyRepositoryItem("A6");

            SF3.AddRepositoryItem(BF6);

            RepositoryFolder <MyRepositoryItem> bigFolder = (RepositoryFolder <MyRepositoryItem>)MyRepoRF.AddSubFolder("BigfolderWith100Items");


            // Add another 100 big item so it will take time loading and we can check multi thread access while load in progress
            for (int i = 0; i < 100; i++)
            {
                MyRepositoryItem bigItem = new MyRepositoryItem("Big Item #" + i);
                bigItem.BigStringHolderSlowSet = new string('a', 150000);
                bigFolder.AddRepositoryItem(bigItem);
            }


            //TODO: add more sample items for testing
            SR.Close();
        }
Exemple #2
0
        private static void CreateTestSolution()
        {
            // First we create a basic solution with some sample items
            SolutionRepository SR = new SolutionRepository();

            if (Directory.Exists(TempRepositoryFolder))
            {
                Directory.Delete(TempRepositoryFolder, true);
            }

            // Define the items types we want in our Repository
            //SR.AddItemInfo<MyRepositoryItem>("*.Ginger.MyRepositoryItem.xml", @"~\MyRepositoryItems", true, "My Repository Item", addToRootFolders: true, PropertyNameForFileName: nameof(MyRepositoryItem.Name));
            SR.AddItemInfo <MyRepositoryItem>(pattern: "*.Ginger.MyRepositoryItem.xml",   // Need to use for file name
                                              rootFolder: SolutionRepository.cSolutionRootFolderSign + "MyRepositoryItems",
                                              containRepositoryItems: true,
                                              displayName: "My Repository Item",
                                              PropertyNameForFileName: nameof(MyRepositoryItem.Name)
                                              );


            SR.CreateRepository(TempRepositoryFolder);
            SR.Open(TempRepositoryFolder);

            MyRepositoryItem A1 = new MyRepositoryItem("A1");

            SR.AddRepositoryItem(A1);

            MyRepositoryItem A2 = new MyRepositoryItem("A2");

            SR.AddRepositoryItem(A2);

            MyRepositoryItem A3 = new MyRepositoryItem("A3");

            SR.AddRepositoryItem(A3);


            RepositoryFolder <MyRepositoryItem> MyRepoRF   = SR.GetRepositoryItemRootFolder <MyRepositoryItem>();
            RepositoryFolder <MyRepositoryItem> SubFolder1 = (RepositoryFolder <MyRepositoryItem>)MyRepoRF.AddSubFolder("SubFolder1");

            MyRepoRF.AddSubFolder("EmptySubFolder");

            MyRepositoryItem A4 = new MyRepositoryItem("A4");

            SubFolder1.AddRepositoryItem(A4);

            // Folder to delete later
            MyRepoRF.AddSubFolder("SubFolderForDelete");

            // Create folders tree
            RepositoryFolder <MyRepositoryItem> SF1 = (RepositoryFolder <MyRepositoryItem>)MyRepoRF.AddSubFolder("SF1");
            RepositoryFolder <MyRepositoryItem> SF2 = (RepositoryFolder <MyRepositoryItem>)SF1.AddSubFolder("SF1_SF2");
            RepositoryFolder <MyRepositoryItem> SF3 = (RepositoryFolder <MyRepositoryItem>)SF2.AddSubFolder("SF1_SF2_SF3");
            MyRepositoryItem BF5 = new MyRepositoryItem("A5");

            SubFolder1.AddRepositoryItem(BF5);

            MyRepositoryItem BF6 = new MyRepositoryItem("A6");

            SF3.AddRepositoryItem(BF6);

            //TODO: add more sample items for testing
            SR.Close();
        }
Exemple #3
0
        private static void CreateTestSolution()
        {
            // First we create a basic solution with some sample items
            SolutionRepository SR = new SolutionRepository();

            //string TempRepositoryFolder = TestResources.getGingerUnitTesterTempFolder(@"Solutions\SRTestTemp");
            if (Directory.Exists(TempRepositoryFolder))
            {
                Directory.Delete(TempRepositoryFolder, true);
            }

            // Define the items types we want in our Repository
            SR.AddItemInfo <MyRepositoryItem>("*.Ginger.MyRepositoryItem.xml", @"~\MyRepositoryItems", true, "My Repository Item", PropertyNameForFileName: nameof(MyRepositoryItem.Name));


            SR.CreateRepository(TempRepositoryFolder);
            SR.Open(TempRepositoryFolder);

            MyRepositoryItem A1 = new MyRepositoryItem("A1");

            SR.AddRepositoryItem(A1);

            MyRepositoryItem A2 = new MyRepositoryItem("A2");

            SR.AddRepositoryItem(A2);

            MyRepositoryItem A3 = new MyRepositoryItem("A3");

            SR.AddRepositoryItem(A3);


            RepositoryFolder <MyRepositoryItem> MyRepoRF   = SR.GetRepositoryItemRootFolder <MyRepositoryItem>();
            RepositoryFolder <MyRepositoryItem> SubFolder1 = (RepositoryFolder <MyRepositoryItem>)MyRepoRF.AddSubFolder("SubFolder1");

            MyRepoRF.AddSubFolder("EmptySubFolder");

            MyRepositoryItem A4 = new MyRepositoryItem("A4");

            SubFolder1.AddRepositoryItem(A4);

            // Folder to delete later
            MyRepoRF.AddSubFolder("SubFolderForDelete");

            // Create folders tree
            RepositoryFolder <MyRepositoryItem> SF1 = (RepositoryFolder <MyRepositoryItem>)MyRepoRF.AddSubFolder("SF1");
            RepositoryFolder <MyRepositoryItem> SF2 = (RepositoryFolder <MyRepositoryItem>)SF1.AddSubFolder("SF1_SF2");
            RepositoryFolder <MyRepositoryItem> SF3 = (RepositoryFolder <MyRepositoryItem>)SF2.AddSubFolder("SF1_SF2_SF3");
            MyRepositoryItem BF5 = new MyRepositoryItem("A5");

            SubFolder1.AddRepositoryItem(BF5);

            MyRepositoryItem BF6 = new MyRepositoryItem("A6");

            SF3.AddRepositoryItem(BF6);

            //TODO: add more sample items for testing
            SR.Close();
        }
Exemple #4
0
        public void RenameBfsSubFolder()
        {
            //Arrange
            //add new sub folder with new bf's to be deleted
            RepositoryFolder <MyRepositoryItem> BFRF           = mSolutionRepository.GetRepositoryItemRootFolder <MyRepositoryItem>();
            RepositoryFolder <MyRepositoryItem> folderToRename = (RepositoryFolder <MyRepositoryItem>)BFRF.AddSubFolder("RenameBfsSubFolder_FolderToRename");
            MyRepositoryItem bf1 = new MyRepositoryItem("FolderToRename_bf1");

            folderToRename.AddRepositoryItem(bf1);
            MyRepositoryItem bf2 = new MyRepositoryItem("FolderToRename_bf2");

            folderToRename.AddRepositoryItem(bf2);
            //add new sub-sub folder with new bf's under the folder which will be renamed
            RepositoryFolder <MyRepositoryItem> subfolderUnderRenamedFolder = (RepositoryFolder <MyRepositoryItem>)folderToRename.AddSubFolder("RenameBfsSubFolder_subfolderUnderRenamedFolder");
            MyRepositoryItem bf3 = new MyRepositoryItem("FolderToRename_bf3");

            subfolderUnderRenamedFolder.AddRepositoryItem(bf3);

            //Act
            string newName = "RenameBfsSubFolder_NewName";

            folderToRename.RenameFolder(newName);
            ObservableList <MyRepositoryItem> bfs = mSolutionRepository.GetAllRepositoryItems <MyRepositoryItem>();

            //Assert
            Assert.IsTrue(folderToRename.FolderRelativePath.Contains(newName), "Validate folder relative path was updated");
            Assert.IsTrue(folderToRename.FolderFullPath.Contains(newName), "Validate folder full path was updated");
            Assert.IsTrue(Directory.Exists(folderToRename.FolderFullPath), "Validate folder full path is valid");
            Assert.AreEqual(folderToRename.DisplayName, newName, "Validate folder Display Name is correct");
            Assert.AreEqual(folderToRename.FolderName, newName, "Validate Folder Name is correct");
            Assert.IsTrue(subfolderUnderRenamedFolder.FolderRelativePath.Contains(newName), "Validate sub folder relative path was updated");
            Assert.IsTrue(subfolderUnderRenamedFolder.FolderFullPath.Contains(newName), "Validate sub folder full path was updated");
            Assert.IsTrue(Directory.Exists(subfolderUnderRenamedFolder.FolderFullPath), "Validate sub folder full path is valid");
            Assert.IsTrue(bf1.ContainingFolder.Contains(newName), "Validate level 1 BF ContainingFolder was updated");
            Assert.IsTrue(bf1.ContainingFolderFullPath.Contains(newName), "Validate level 1 BF ContainingFolderFullPath was updated");
            Assert.IsTrue(bf1.FilePath.Contains(newName), "Validate level 1 BF FilePath was updated");
            Assert.IsTrue(File.Exists(bf1.FilePath), "Validate level 1 BF FilePath is valid");
            Assert.IsTrue(bf3.ContainingFolder.Contains(newName), "Validate level 2 BF ContainingFolder was updated");
            Assert.IsTrue(bf3.ContainingFolderFullPath.Contains(newName), "Validate level 2 BF ContainingFolderFullPath was updated");
            Assert.IsTrue(bf3.FilePath.Contains(newName), "Validate level 2 BF FilePath was updated");
            Assert.IsTrue(File.Exists(bf3.FilePath), "Validate level 2 BF FilePath is valid");
            Assert.AreEqual(bfs.Where(x => x.Guid == bf1.Guid).ToList().Count, 1, "Make sure level 1 item is not loaded to cache more than once");
            Assert.AreEqual(bfs.Where(x => x.Guid == bf3.Guid).ToList().Count, 1, "Make sure level 2 item is not loaded to cache more than once");
        }
Exemple #5
0
        public void DeleteBfsSubFolderWithAllItemsLoaded()
        {
            //Arrange
            ObservableList <MyRepositoryItem> MRIs = mSolutionRepository.GetAllRepositoryItems <MyRepositoryItem>();
            //add new sub folder with new bf's to be deleted
            RepositoryFolder <MyRepositoryItem> MRIRF          = mSolutionRepository.GetRepositoryItemRootFolder <MyRepositoryItem>();
            RepositoryFolder <MyRepositoryItem> folderToDelete = (RepositoryFolder <MyRepositoryItem>)MRIRF.AddSubFolder("DeleteSubFolder_FolderForDelete");
            MyRepositoryItem MRI1 = new MyRepositoryItem("DeleteSubFolder_MRI1");

            folderToDelete.AddRepositoryItem(MRI1);
            MyRepositoryItem MRI2 = new MyRepositoryItem("DeleteSubFolder_MRI2");

            folderToDelete.AddRepositoryItem(MRI2);
            //add new sub-sub folder with new MRI's to be deleted
            RepositoryFolder <MyRepositoryItem> subfolderToDelete = (RepositoryFolder <MyRepositoryItem>)folderToDelete.AddSubFolder("DeleteSubFolder_subfolderToDelete");
            MyRepositoryItem MRI3 = new MyRepositoryItem("DeleteSubFolder_MRI3");

            subfolderToDelete.AddRepositoryItem(MRI3);

            //Act
            mSolutionRepository.DeleteRepositoryItemFolder(folderToDelete);

            //Assert
            Assert.IsTrue(Directory.Exists(folderToDelete.FolderFullPath) == false);
            Assert.AreEqual((mSolutionRepository.GetRepositoryItemByGuid <MyRepositoryItem>(MRI1.Guid)), null, "make sure all deleted folder items were removed from cache");
            Assert.AreEqual((mSolutionRepository.GetRepositoryItemByGuid <MyRepositoryItem>(MRI3.Guid)), null, "make sure all deleted folder sub folder items were removed from cache");
        }
Exemple #6
0
        public void ApplicationAPIModelMultipleSoapAndRestSaveAndLoad()
        {
            // Arrange
            RepositoryFolder <ApplicationAPIModel> RFRoot    = SR.GetRepositoryItemRootFolder <ApplicationAPIModel>();
            RepositoryFolder <ApplicationAPIModel> subFolder = (RepositoryFolder <ApplicationAPIModel>)RFRoot.AddSubFolder("SecondFolder");

            //Act
            //add items to root folder
            ApplicationAPIModel AAMS1 = new ApplicationAPIModel()
            {
                Name = "Group1_Operation1"
            };

            SR.AddRepositoryItem(AAMS1);
            ApplicationAPIModel AAMS2 = new ApplicationAPIModel()
            {
                Name = "Group1_Operation2"
            };

            SR.AddRepositoryItem(AAMS2);
            ApplicationAPIModel AAMS3 = new ApplicationAPIModel()
            {
                Name = "Group1_Operation3"
            };

            SR.AddRepositoryItem(AAMS3);
            //add items to sub folder items
            ApplicationAPIModel AAMR1 = new ApplicationAPIModel()
            {
                Name = "Group2_Operation1"
            };

            subFolder.AddRepositoryItem(AAMR1);
            ApplicationAPIModel AAMR2 = new ApplicationAPIModel()
            {
                Name = "Group2_Operation2"
            };

            subFolder.AddRepositoryItem(AAMR2);
            ApplicationAPIModel AAMR3 = new ApplicationAPIModel()
            {
                Name = "Group2_Operation3"
            };

            subFolder.AddRepositoryItem(AAMR3);

            ObservableList <ApplicationAPIModel>   AAMBList          = SR.GetAllRepositoryItems <ApplicationAPIModel>();
            RepositoryFolder <ApplicationAPIModel> SecondFolder      = RFRoot.GetSubFolder("SecondFolder");
            ObservableList <ApplicationAPIModel>   AAMBListSubFolder = SecondFolder.GetFolderItems();


            //Assert
            // Assert.AreEqual(AAMBList.Count, 6, "All appllication models including sub folders"); - cannot compare since we run several tests in parallel
            Assert.AreEqual(AAMBListSubFolder.Count, 3, "Second Folder should have 3 files");
        }