public void BoardRepositoryEnsureICanGetAllBoards()
        {
            /* Begin Arrange */

            // 1. Your data must be Queryable
            // 2. Mocks can only cast to an Interface (e.g. IQueryable, IDbSet, etc).
            // 3. You must ensure Provider, GetEnumerator(), ElementType, and Expression are defined
            //    with your collection class (the container class that holds your data).

            my_list.Add(new Board {
                Title = "Tim's Board", Owner = owner
            });
            my_list.Add(new Board {
                Title = "Sally's Board", Owner = owner
            });
            ConnectMocksToDataSource();

            BoardRepository board_repo = new BoardRepository(mock_context.Object);
            /* End Arrange */

            /* Begin Act */
            List <Board> boards = board_repo.GetAllBoards();

            /* End Act */

            /* Begin Assert */
            Assert.AreEqual(2, boards.Count);
            /* End Assert */
        }
Exemplo n.º 2
0
        public List <Board> GetBoardsThatUserIsPartOf(JunaUser user)
        {
            var selectedBoardsList = new List <Board>();

            if (user != null)
            {
                var createdBoards = _boardRepository.GetBoardsCreatedByUser(user);
                selectedBoardsList.AddRange(createdBoards);
                //boards that user is following
                var boards = _boardRepository.GetAllBoards();
                foreach (var board in boards)
                {
                    var followActivity = _activityRepository.GetByActorVerbAndObject($"JunaUser:{user.ObjectId}", BoardInteractionMetadata.INTERACTION_FOLLOW, $"Board-{board.Id}");
                    if (followActivity != null)
                    {
                        var selectedBoard = _boardRepository.GetById(Guid.Parse(followActivity.Object.Split(new char[] { '-' }, 2)[1]));
                        selectedBoardsList.Add(selectedBoard);
                    }
                }
            }
            return(selectedBoardsList);
        }
        public void BoardRepositoryEnsureICanGetAllBoards()
        {
            /* Begin Arrange */

                // 1. Your data must be Queryable
                // 2. Mocks can only cast to an Interface (e.g. IQueryable, IDbSet, etc).
                // 3. You must ensure Provider, GetEnumerator(), ElementType, and Expression are defined
                //    with your collection class (the container class that holds your data).

                my_game.Add(new Game { Title = "Tim's Board", Owner = owner });
                my_list.Add(new Board { Title = "Sally's Board", Owner = owner });
                ConnectMocksToDataSource();

                BoardRepository board_repo = new BoardRepository(mock_context.Object);
                /* End Arrange */

                /* Begin Act */
                List<Board> boards = board_repo.GetAllBoards();
                /* End Act */

                /* Begin Assert */
                Assert.AreEqual(2, boards.Count);
                /* End Assert */
        }