Exemplo n.º 1
0
        public void SampleRoomViewModelTest()
        {
            var vm = new SampleRoomViewModel();

            Assert.AreEqual(2, vm.ModerationRequestCollectionVm.ViewModelCount);
            Assert.AreEqual(4, vm.RoomPermissionGrantCollectionVm.ViewModelCount);
        }
        public void SampleRoomViewModelTest()
        {
            var roomVm = new SampleRoomViewModel();

            Assert.IsNotNull(roomVm.RoomPermissionGrantCollectionVm);
            Assert.IsTrue(roomVm.RoomPermissionGrantCollectionVm.ViewModels.Count > 0);
            Assert.IsTrue(roomVm.RoomPermissionGrantCollectionVm.SecurityPrincipals.Count > 0);
            var securityUser = ((UserViewModel)(roomVm.RoomPermissionGrantCollectionVm.SecurityPrincipals[0])).Model;

            Assert.AreEqual(user.UserName, securityUser.UserName);
            Assert.IsTrue(roomVm.RoomPermissionGrantCollectionVm.ViewModels.Any(vm => vm.Model.RoomPermissionTag == RoomPermissionValues.Administer));
            Assert.AreEqual(2, roomVm.ModerationRequestCollectionVm.ViewModelCount);
            Assert.AreEqual(2, roomVm.ModerationRequestCollectionVm.PendingModerationRequests.Count);
        }
        public void PendingModerationRequestsTest()
        {
            var roomVm     = new SampleRoomViewModel();
            var requestsVm = roomVm.ModerationRequestCollectionVm;

            Assert.IsTrue(requestsVm.ViewModelCount > 0);
            Assert.AreEqual(requestsVm.ViewModelCount, requestsVm.PendingModerationRequests.Count);
            var requestVm = requestsVm.ViewModels.First();

            Assert.IsFalse(requestVm.Model.RespondedOn.HasValue);
            requestVm.Model.RespondedOn = DateTime.Now;
            Assert.AreEqual(requestsVm.ViewModelCount - 1, requestsVm.PendingModerationRequests.Count);
            requestVm.Model.RespondedOn = null;
            Assert.AreEqual(requestsVm.ViewModelCount, requestsVm.PendingModerationRequests.Count);
        }
        public void ModerationRequestsVisibilityTest()
        {
            // Arrange
            var roomVm     = new SampleRoomViewModel();
            var requestsVm = roomVm.ModerationRequestCollectionVm;

            Assert.IsTrue(requestsVm.ViewModelCount > 0);
            Assert.IsTrue(requestsVm.PendingModerationRequests.Count > 0);
            Assert.AreEqual(Visibility.Visible, requestsVm.ModerationRequestsVisibility);

            // Act
            foreach (var requestvm in requestsVm.PendingModerationRequests.ToList())
            {
                requestvm.Model.RespondedOn = DateTime.Now;
            }

            // Assert
            Assert.AreEqual(0, requestsVm.PendingModerationRequests.Count);
            Assert.AreEqual(Visibility.Collapsed, requestsVm.ModerationRequestsVisibility);
        }