コード例 #1
0
        public void NotifyPropertyChangedTests()
        {
            var vm = new SignOffViewModel();

            TestsHelper.TestPropertyWithNotifyPropertyChanged(vm, () => vm.Title);
            TestsHelper.TestPropertyWithNotifyPropertyChanged(vm, () => vm.Username);
            TestsHelper.TestPropertyWithNotifyPropertyChanged(vm, () => vm.Password);
            TestsHelper.TestPropertyWithNotifyPropertyChanged(vm, () => vm.PersonId);
            TestsHelper.TestPropertyWithNotifyPropertyChanged(vm, () => vm.IsOverride);
            TestsHelper.TestPropertyWithNotifyPropertyChanged(vm, () => vm.IsApproved);
            TestsHelper.TestPropertyWithNotifyPropertyChanged(vm, () => vm.IsRejected);
            TestsHelper.TestPropertyWithNotifyPropertyChanged(vm, () => vm.Error);
            TestsHelper.TestPropertyWithNotifyPropertyChanged(vm, () => vm.Comments);
            TestsHelper.TestPropertyWithNotifyPropertyChanged(vm, () => vm.CommentValidationMessage);
            TestsHelper.TestPropertyWithNotifyPropertyChanged(vm, () => vm.AuthenticationType);
        }
コード例 #2
0
        public void HasErrors_Test()
        {
            var vm = new SignOffViewModel();
            Assert.IsFalse(vm.HasErrors);

            vm = new SignOffViewModel { IsRejected = true };
            Assert.IsTrue(vm.HasErrors);

            vm = new SignOffViewModel { IsRejected = true, Comments = "test" };
            Assert.IsFalse(vm.HasErrors);

            vm = new SignOffViewModel { IsOverride = true };
            Assert.IsTrue(vm.HasErrors);

            vm = new SignOffViewModel { IsOverride = true, Comments = "test" };
            Assert.IsFalse(vm.HasErrors);
        }
コード例 #3
0
        public void Copy_Test()
        {
            const string Title = "Test Title";
            const string Username = "******";
            const string Password = "******";
            const int PersonId = 123;
            const string Comments = "comments";
            const string Error = "error";

            var vm = new SignOffViewModel
                         {
                             Title = Title,
                             Username = Username,
                             Password = Password,
                             PersonId = PersonId,
                             IsOverride = true,
                             IsApproved = true,
                             IsRejected = true,
                             Comments = Comments,
                             Error = Error,
                             AuthenticationType = AuthenticationTypes.LDAP
                         };

            var newViewModel = new SignOffViewModel();

            vm.CopyTo(newViewModel);

            Assert.AreEqual(Title, newViewModel.Title);
            Assert.AreEqual(Username, newViewModel.Username);
            Assert.AreEqual(Password, newViewModel.Password);
            Assert.AreEqual(PersonId, newViewModel.PersonId);
            Assert.IsTrue(newViewModel.IsOverride);
            Assert.IsTrue(newViewModel.IsApproved);
            Assert.IsTrue(newViewModel.IsRejected);
            Assert.AreEqual(Comments, newViewModel.Comments);
            Assert.AreEqual(Error, newViewModel.Error);
            Assert.AreEqual(AuthenticationTypes.LDAP, newViewModel.AuthenticationType);
        }
コード例 #4
0
        public void OnCancel_ShowDialog_ReturnsFalse()
        {
            // Arrange.
            const string Title = "Test Title";

            Func<bool> cancelAction = null;

            var popup = Mock.Create<PopupBuilder>(Behavior.CallOriginal);
            Mock.Arrange(() => popup.Duration(0)).CallOriginal().MustBeCalled();
            Mock.Arrange(() => popup.SetCaption(Title)).CallOriginal().MustBeCalled();
            Mock.Arrange(() => popup.SetPosition(PopupPosition.Center)).CallOriginal().MustBeCalled();
            Mock.Arrange(() => popup.SetIsModal(true)).Returns(popup).CallOriginal().MustBeCalled();
            Mock.Arrange(() => popup.Show(Arg.IsAny<Action>(), Arg.IsAny<Func<bool>>())).DoInstead<Action, Func<bool>>(
                (onOk, onCancel) =>
                    {
                        cancelAction = onCancel;
                    }).MustBeCalled();
            var popupFactory = Mock.Create<PopupFactory>(Behavior.Loose);
            Mock.Arrange(() => popupFactory.Popup()).Returns(popup);

            var vm = new SignOffViewModel { PopupFactory = popupFactory, Title = Title };
            Mock.Arrange(() => popup.SetCustomViewModel(vm)).CallOriginal().MustBeCalled();

            // Act.
            var task = vm.ShowDialog();

            // Assert.
            Mock.Assert(popup);

            Assert.IsNotNull(cancelAction);
            Assert.IsNotNull(task);
            Assert.IsFalse(task.IsCompleted);

            Assert.IsFalse(cancelAction());
            Assert.IsTrue(task.IsCompleted);
            Assert.AreEqual(false, task.Result);
        }
コード例 #5
0
        public void CloseDialog_Test()
        {
            var vm = new SignOffViewModel();
            var closed = false;

            vm.Closed += (o, e) => closed = true;

            vm.Close();

            Assert.IsTrue(closed);
        }
コード例 #6
0
        public void ApprovalResultTest()
        {
            // Arrange.
            var undecided = new SignOffViewModel { IsApproved = false, IsRejected = false };
            var approved = new SignOffViewModel { IsApproved = true, IsRejected = false };
            var rejected = new SignOffViewModel { IsApproved = false, IsRejected = true };

            // Act / Assert.
            Assert.AreEqual(ApprovalMemberResults.Undecided, undecided.ApprovalResult);
            Assert.AreEqual(ApprovalMemberResults.Approved, approved.ApprovalResult);
            Assert.AreEqual(ApprovalMemberResults.Rejected, rejected.ApprovalResult);
        }