public void RoomPermissionsUpdatedTest()
        {
            // Arrange
            var roomVm = viewModelFactory.GetViewModel <RoomViewModel>();

            roomVm.Model = room;
            var originalGrants = DesignTimeHelper.GetRoomPermissionGrants();
            var goodGrant1     = new RoomPermissionGrant {
                RoomPermissionGrantId = Guid.NewGuid(), RoomPermissionTag = Guid.NewGuid().ToString(), UserId = user.UserId, User = user, RoomId = room.RoomId
            };
            var goodGrant2 = new RoomPermissionGrant {
                RoomPermissionGrantId = Guid.NewGuid(), RoomPermissionTag = Guid.NewGuid().ToString(), UserId = user.UserId, User = user, RoomId = room.RoomId
            };
            var badGrant1 = new RoomPermissionGrant {
                RoomPermissionGrantId = Guid.NewGuid(), RoomPermissionTag = Guid.NewGuid().ToString(), UserId = Guid.NewGuid(), User = null, RoomId = room.RoomId
            };
            var badGrant2 = new RoomPermissionGrant {
                RoomPermissionGrantId = Guid.NewGuid(), RoomPermissionTag = Guid.NewGuid().ToString(), UserId = user.UserId, User = user, RoomId = Guid.NewGuid()
            };
            var newGrants = new ObservableCollection <RoomPermissionGrant> {
                goodGrant1, goodGrant2, badGrant1, badGrant2
            };
            var localPerms = viewModelFactory.GetViewModel <SecurityPrincipalRoomPermissionGrantCollectionViewModel>();

            localPerms.SecurityPrincipalId = user.UserId;
            localPerms.Models = originalGrants;

            // Act
            mockRoomService.Raise(rs => rs.RoomPermissionsForUserUpdated += null, new EventArgs <ObservableCollection <RoomPermissionGrant> >(newGrants));

            // Assert
            Assert.AreEqual(2, localPerms.ViewModelCount);
            Assert.AreEqual(2, localPerms.ViewModels.Count);
            Assert.IsTrue(localPerms.ViewModels.Any(vm => vm.Model.RoomPermissionGrantId == goodGrant1.RoomPermissionGrantId));
            Assert.IsTrue(localPerms.ViewModels.Any(vm => vm.Model.RoomPermissionGrantId == goodGrant2.RoomPermissionGrantId));
        }
        public void CalculatedPropertiesTest()
        {
            // Arrange
            var localUserVm = viewModelFactory.GetViewModel <LocalUserViewModel>();

            localUserVm.Model = guestUser;
            var roomVm = viewModelFactory.GetViewModel <RoomViewModel>();

            roomVm.Model = room;
            var stopSharingGrant = new RoomPermissionGrant()
            {
                RoomPermissionGrantId  = Guid.NewGuid(),
                RoomPermissionScopeTag = RoomPermissionScopeValues.User,
                RoomPermissionTag      = RoomPermissionValues.StopSharingOwnItem,
                UserId = guestUser.UserId,
                RoomId = room.RoomId
            };
            var stopSharingGrantVm = viewModelFactory.GetViewModel <RoomPermissionGrantViewModel>(vm => vm.Model.RoomPermissionGrantId == stopSharingGrant.RoomPermissionGrantId);

            stopSharingGrantVm.Model = stopSharingGrant;
            localUserVm.RoomPermissionGrants.ViewModels.Add(stopSharingGrantVm);

            // Act and Assert
            var unownedWb = new Data.RoomService.Whiteboard()
            {
                WhiteboardId = Guid.NewGuid(), User = user
            };
            var unownedWbVm = viewModelFactory.GetViewModel <WhiteboardViewModel>(wvm => wvm.WorkspaceItemId == unownedWb.WhiteboardId);

            Assert.IsFalse(unownedWbVm.IsReady);

            Assert.AreEqual(Guid.Empty, unownedWbVm.WorkspaceItemId);
            Assert.AreEqual(Guid.Empty, unownedWbVm.OwnerUserId);
            Assert.AreEqual(string.Empty, unownedWbVm.OwnerUserName);
            unownedWbVm.Model = unownedWb;
            Assert.AreEqual(unownedWb.WhiteboardId, unownedWbVm.WorkspaceItemId);
            Assert.AreEqual(unownedWb.User.UserId, unownedWbVm.OwnerUserId);
            Assert.AreEqual(unownedWb.User.UserName, unownedWbVm.OwnerUserName);

            unownedWb.IsClosed = null;
            Assert.IsTrue(unownedWbVm.IsShared);
            unownedWbVm.IsShared = true;
            Assert.AreEqual(true, unownedWbVm.IsShared);
            Assert.AreEqual(false, unownedWb.IsClosed);
            unownedWbVm.IsShared = false;
            Assert.AreEqual(false, unownedWbVm.IsShared);
            Assert.AreEqual(true, unownedWb.IsClosed);

            Assert.IsTrue(unownedWbVm.IsReady);
            Assert.IsFalse(unownedWbVm.IsShareAvailable);
            Assert.IsFalse(unownedWbVm.IsUnshareAvailable);
            Assert.IsFalse(unownedWbVm.IsDeleteAvailable);

            var ownedWb = new Data.RoomService.Whiteboard()
            {
                WhiteboardId = Guid.NewGuid(), User = guestUser
            };
            var ownedWbVm = viewModelFactory.GetViewModel <WhiteboardViewModel>(wvm => wvm.WorkspaceItemId == ownedWb.WhiteboardId);

            Assert.IsFalse(ownedWbVm.IsReady);
            Assert.AreEqual(Guid.Empty, ownedWbVm.WorkspaceItemId);
            Assert.AreEqual(Guid.Empty, ownedWbVm.OwnerUserId);
            Assert.AreEqual(string.Empty, ownedWbVm.OwnerUserName);
            ownedWbVm.Model = ownedWb;
            Assert.AreEqual(ownedWb.WhiteboardId, ownedWbVm.WorkspaceItemId);
            Assert.AreEqual(ownedWb.User.UserId, ownedWbVm.OwnerUserId);
            Assert.AreEqual(ownedWb.User.UserName, ownedWbVm.OwnerUserName);
            Assert.IsTrue(ownedWbVm.IsReady);
            Assert.IsTrue(ownedWbVm.IsShareAvailable);
            Assert.IsTrue(ownedWbVm.IsUnshareAvailable);
            Assert.IsTrue(ownedWbVm.IsDeleteAvailable);
        }