Пример #1
0
        public void t02_ListHandling()
        {
            SPOViewModel vm = createViewModel();

            // Initial values
            Assert.IsNull(vm.LT.Lists);
            Assert.IsNull(vm.LT.SelectedList);

            List <SPOList> testLists = vm.SPOClient.GetLists();

            // First login: Default selected item
            vm.LoginButtonHandler();
            vm.SPOSettings.ListFilter.TypeTemplateRanges.Add(new SPOListFilter.TypeTemplateRange()
            {
                From = 5000, To = 5005,
            });
            vm.LT.ActivateTab();
            Assert.AreEqual(testLists.Count(), vm.LT.Lists.Count());
            Assert.AreEqual(testLists[0].Id, vm.LT.SelectedList.Id);

            // Activate tab with preset SelectedList
            vm.LT.SelectedList = testLists[1];
            vm.LT.Lists        = null;
            vm.DataLoaded      = false;
            vm.LT.ActivateTab();
            Assert.AreEqual(testLists.Count(), vm.LT.Lists.Count());
            Assert.AreEqual(testLists[1].Id, vm.LT.SelectedList.Id);

            // Activate tab with preset but not-existing SelectedList
            vm.LT.SelectedList = new SPOList()
            {
                Id = Guid.NewGuid()
            };
            vm.LT.Lists   = null;
            vm.DataLoaded = false;
            vm.LT.ActivateTab();
            Assert.AreEqual(testLists.Count(), vm.LT.Lists.Count());
            Assert.AreEqual(testLists[0].Id, vm.LT.SelectedList.Id);

            // Activate tab with empty list of Lists
            vm.LT.SelectedList = testLists[1];
            vm.LT.Lists        = null;
            vm.DataLoaded      = false;
            ((SPOClientMock)vm.SPOClient).ReturnEmptyList = true;
            vm.LT.ActivateTab();
            Assert.AreEqual(0, vm.LT.Lists.Count());
            Assert.AreEqual(testLists[1].Id, vm.LT.SelectedList.Id); // unchanged
            ((SPOClientMock)vm.SPOClient).ReturnEmptyList = false;
        }
Пример #2
0
        public void t01_Connection()
        {
            SPOViewModel vm = createViewModel();

            // Test initial values
            Assert.AreEqual("<http://servername/sitename>", vm.CT.SiteUrl);
            Assert.AreEqual(string.Empty, vm.CT.Username);
            Assert.AreEqual(string.Empty, vm.CT.Password);
            Assert.IsTrue(vm.CT.Office365);
            Assert.IsFalse(vm.SPOSettings.LoginPossible);
            Assert.IsFalse(vm.DataLoaded);
            Assert.AreEqual(connectionTab, vm.SelectedTab);

            // Test faild login
            vm.CT.Username             = "******";
            SIEEMessageBox.LastMessage = null;
            vm.LoginButtonHandler();
            Assert.IsNotNull(SIEEMessageBox.LastMessage);
            Assert.IsFalse(vm.SPOSettings.LoginPossible);
            Assert.IsFalse(vm.DataLoaded);
            Assert.AreEqual(connectionTab, vm.SelectedTab);

            // Test successful login
            vm.CT.Username             = "******";
            SIEEMessageBox.LastMessage = null;
            vm.LoginButtonHandler();
            Assert.IsNull(SIEEMessageBox.LastMessage);
            Assert.IsTrue(vm.SPOSettings.LoginPossible);
            Assert.AreEqual(listTab, vm.SelectedTab);
            vm.LT.ActivateTab();
            Assert.IsTrue(vm.DataLoaded);

            // Reload settings and verify
            vm = createViewModel(vm.SPOSettings);
            Assert.IsTrue(vm.SPOSettings.LoginPossible);
            Assert.AreEqual(listTab, vm.SelectedTab);
            vm.LT.ActivateTab();
            Assert.IsTrue(vm.DataLoaded);

            // Switching tabs should not change status of Dataloded
            vm.SelectedTab = connectionTab;
            vm.LT.ActivateTab();
            Assert.IsTrue(vm.DataLoaded);

            // Set illegal password again
            vm.CT.Username = "******";
            Assert.IsFalse(vm.SPOSettings.LoginPossible);
            Assert.IsFalse(vm.DataLoaded);
            vm.LoginButtonHandler();
            Assert.IsFalse(vm.SPOSettings.LoginPossible);
            Assert.IsFalse(vm.DataLoaded);
            // Assert.AreEqual(connectionTab, vm.SelectedTab); Can't happen at the UI. User must be on connection tab.

            // Verify case where an account becomes invalid
            vm.CT.Username = "******";
            vm.LoginButtonHandler();
            Assert.IsTrue(vm.SPOSettings.LoginPossible);
            Assert.AreEqual(listTab, vm.SelectedTab);
            vm.LT.ActivateTab();
            Assert.IsTrue(vm.DataLoaded);
            vm.CT.Username = "******";
            vm             = createViewModel(vm.SPOSettings);
            Assert.IsFalse(vm.SPOSettings.LoginPossible);
            Assert.IsFalse(vm.DataLoaded);
            Assert.AreEqual(connectionTab, vm.SelectedTab);
        }