Example #1
0
        private CMISViewModel getInitializedViewModel()
        {
            CMISViewModel vm = getViewModel();

            Assert.IsFalse(vm.DataLoaded);
            Assert.IsFalse(vm.TT.PropertiesLoaded);
            Assert.IsTrue(vm.FT.WarningVisible);
            Assert.AreEqual(0, vm.SelectedTab);

            vm.LoadRepositoriesButtonHandler();
            Assert.IsFalse(vm.DataLoaded);

            vm.ConnectdButtonHandler();
            Assert.IsTrue(vm.DataLoaded);
            Assert.IsFalse(vm.TT.PropertiesLoaded);
            Assert.IsTrue(vm.FT.WarningVisible);
            Assert.AreEqual(1, vm.SelectedTab);

            vm.ActivateTab("typesTab");
            vm.TT.SetSelectTypeHandler(vm.TT.Types[0]);
            Assert.IsFalse(vm.TT.PropertiesLoaded);
            Assert.AreEqual(vm.TT.SelectedCulture, CultureInfo.CurrentCulture);

            vm.FT.SetSelectedFolderHandler(vm.FT.Folders[0]);
            Assert.IsFalse(vm.FT.WarningVisible);

            Assert.IsNull(SIEEMessageBox.LastMessage);
            return(vm);
        }
Example #2
0
        public void T07_SelectReposiory()
        {
            CMISViewModel vm = getViewModel();

            vm.LoadRepositoriesButtonHandler();
            Assert.AreEqual("Repository 1", vm.CT.SelectedRepository.Id);
            Assert.AreEqual(vm.CT.Repositories[0], vm.CT.SelectedRepository);
            vm.CT.SelectedRepository = vm.CT.Repositories[1];
            SIEESettings save = vm.Settings;

            vm = new CMISViewModel(vm.Settings, vm.CMISClient);
            Assert.AreEqual("Repository 2", vm.CT.SelectedRepository.Id);
            Assert.AreEqual(vm.CT.Repositories[1].Description, vm.CT.SelectedRepository.Description);
        }
Example #3
0
        public void T01_ConnectionTab()
        {
            // Verify default values
            CMISViewModel vm = new CMISViewModel(new CMISSettings(), new CMISClientMock());

            Assert.IsFalse(vm.IsRunning);
            Assert.IsFalse(vm.DataLoaded);
            Assert.IsFalse(vm.CanConnect());
            Assert.AreEqual(0, vm.SelectedTab);
            Assert.AreEqual("http://<Server URL>", vm.CT.ServerURL);
            Assert.AreEqual(TypeOfBinding.Atom, vm.CT.TypeOfBinding);
            Assert.AreEqual(null, vm.CT.Username);
            Assert.AreEqual(string.Empty, vm.CT.Password);
            Assert.IsNull(vm.CT.SelectedRepository.Id);
            Assert.IsNull(vm.CT.SelectedRepository.Description);
            Assert.IsFalse(vm.CT.SecondaryTypesSupported);

            // Verify tab order
            CMIS_WPFControl wpfControl = new CMIS_WPFControl();

            wpfControl.DataContext = vm;
            Dictionary <int, string> tabs = new Dictionary <int, string>()
            {
                { 0, "connectionTab" },
                { 1, "folderTab" },
                { 2, "typesTab" },
                { 3, "documentTab" },
                { 4, "secondaryTypesTab" },
            };
            TabControl tc = (TabControl)LogicalTreeHelper.FindLogicalNode(wpfControl, "mainTabControl");

            for (int i = 0; i < tabs.Count; i++)
            {
                tc.SelectedIndex = i;
                TabItem ti = tc.SelectedItem as TabItem;
                Assert.AreEqual(tabs[i], ti.Name);
            }

            // Load repositories
            vm = getViewModel();
            Assert.IsFalse(vm.CanConnect());
            Assert.IsFalse(vm.DataLoaded);
            Assert.IsFalse(vm.CMISSettings.LoadRepositoriesPossible);
            Assert.IsFalse(vm.CMISSettings.ConnectPossible);

            vm = new CMISViewModel(vm.Settings, new CMISClientMock());
            Assert.IsFalse(vm.CanConnect());                          // no change
            Assert.IsFalse(vm.DataLoaded);                            // no change
            Assert.IsFalse(vm.CMISSettings.LoadRepositoriesPossible); // no change
            Assert.IsFalse(vm.CMISSettings.ConnectPossible);          // no change

            vm.LoadRepositoriesButtonHandler();
            Assert.AreEqual(3, vm.CT.Repositories.Count);
            Assert.IsTrue(vm.CanConnect());                          // change
            Assert.IsFalse(vm.DataLoaded);                           // no change
            Assert.IsTrue(vm.CMISSettings.LoadRepositoriesPossible); // change
            Assert.IsFalse(vm.CMISSettings.ConnectPossible);         // no change

            vm = new CMISViewModel(vm.Settings, new CMISClientMock());
            Assert.AreEqual(3, vm.CT.Repositories.Count);
            Assert.IsTrue(vm.CanConnect());                           // change
            Assert.IsFalse(vm.DataLoaded);                            // no change
            Assert.IsTrue(vm.CMISSettings.LoadRepositoriesPossible);  // change
            Assert.IsFalse(vm.CMISSettings.ConnectPossible);          // no change

            vm.CT.Username += "-1";                                   // invalidate connection settings
            Assert.IsFalse(vm.CanConnect());                          // change
            Assert.IsFalse(vm.DataLoaded);                            // no change
            Assert.IsFalse(vm.CMISSettings.LoadRepositoriesPossible); // change
            Assert.IsFalse(vm.CMISSettings.ConnectPossible);          // no change
            vm.LoadRepositoriesButtonHandler();

            // Connect
            Assert.AreEqual(vm.CT.SelectedRepository, vm.CT.Repositories.First());
            vm.ConnectdButtonHandler();
            Assert.IsNull(SIEEMessageBox.LastMessage);
            Assert.IsTrue(vm.CanConnect());                          // no change
            Assert.IsTrue(vm.DataLoaded);                            // change
            Assert.IsTrue(vm.CMISSettings.LoadRepositoriesPossible); // no change
            Assert.IsTrue(vm.CMISSettings.ConnectPossible);          // change
            Assert.AreEqual(vm.CT.SelectedRepository.Id, ((CMISClientMock)vm.CMISClient).CurrentRepository);

            // Connecting twice -> no change
            ((CMISClientMock)vm.CMISClient).CurrentRepository = null;
            vm.ConnectdButtonHandler();
            Assert.AreEqual(null, ((CMISClientMock)vm.CMISClient).CurrentRepository);

            // Change repository
            vm.CT.SelectedRepository = vm.CT.Repositories.Last();    // reselect
            Assert.IsTrue(vm.CanConnect());                          // no change
            Assert.IsFalse(vm.DataLoaded);                           // change
            Assert.IsTrue(vm.CMISSettings.LoadRepositoriesPossible); // no change
            Assert.IsFalse(vm.CMISSettings.ConnectPossible);         // change

            vm.ConnectdButtonHandler();
            Assert.IsNull(SIEEMessageBox.LastMessage);
            vm = new CMISViewModel(vm.Settings, new CMISClientMock());
            Assert.IsTrue(vm.CanConnect());                          // no change
            Assert.IsTrue(vm.DataLoaded);                            // no change
            Assert.IsTrue(vm.CMISSettings.LoadRepositoriesPossible); // no change
            Assert.IsTrue(vm.CMISSettings.ConnectPossible);          // no change
            Assert.AreEqual(vm.CT.SelectedRepository.Id, ((CMISClientMock)vm.CMISClient).CurrentRepository);

            // Binding type
            vm.CT.BrowserBinding = true;
            Assert.AreEqual(TypeOfBinding.Browser, vm.CMISSettings.Binding);
            Assert.IsFalse(vm.CT.AtomBinding);
            Assert.IsTrue(vm.CT.BrowserBinding);
            Assert.IsFalse(vm.CT.WebServiceBinding);
            vm.LoadRepositoriesButtonHandler();
            Assert.AreEqual(TypeOfBinding.Browser, vm.CMISClient.TypeOfBinding);
            vm.CT.WebServiceBinding = true;
            Assert.AreEqual(TypeOfBinding.WebService, vm.CMISSettings.Binding);
            Assert.IsFalse(vm.CT.AtomBinding);
            Assert.IsFalse(vm.CT.BrowserBinding);
            Assert.IsTrue(vm.CT.WebServiceBinding);
            vm.LoadRepositoriesButtonHandler();
            Assert.AreEqual(TypeOfBinding.WebService, vm.CMISClient.TypeOfBinding);
            vm.CT.AtomBinding = true;
            Assert.AreEqual(TypeOfBinding.Atom, vm.CMISSettings.Binding);
            Assert.IsTrue(vm.CT.AtomBinding);
            Assert.IsFalse(vm.CT.BrowserBinding);
            Assert.IsFalse(vm.CT.WebServiceBinding);
            vm.LoadRepositoriesButtonHandler();
            Assert.AreEqual(TypeOfBinding.Atom, vm.CMISClient.TypeOfBinding);
            Assert.AreEqual(vm.CT.Username, vm.CMISClient.Username);
            Assert.AreEqual(vm.CT.Password, vm.CMISClient.Password);
        }