Exemple #1
0
 public BorrowGamesController(ILogger <BorrowGamesController> logger,
                              IBorrowGameService borrowGamesService,
                              IMapper mapper)
 {
     _logger             = logger;
     _borrowGamesService = borrowGamesService;
     _mapper             = mapper;
 }
        public void Setup()
        {
            var user = new User(userName, new UserType(2), "1234");

            friend          = new Friend(user);
            game            = new Game(gameName);
            borrowedGame    = new Game(gameName);
            unityOfWorkMock = new Mock <IUnityOfWork>();
            unityOfWorkMock.Setup(c => c.Users.GetUserWithType(It.IsAny <int>())).ReturnsAsync(friend);
            unityOfWorkMock.Setup(c => c.Games.GetById(It.IsAny <int>())).ReturnsAsync(game);
            unityOfWorkMock.Setup(c => c.Games.GetGameByIdWithBorrowed(It.IsAny <int>())).ReturnsAsync(game);
            unityOfWorkMock.Setup(c => c.BorrowedGames.Create(It.IsAny <BorrowedGame>())).ReturnsAsync(new BorrowedGame(friend, borrowedGame));
            unityOfWorkMock.Setup(c => c.BorrowedGames.Delete(It.IsAny <int>())).ReturnsAsync(new BorrowedGame(friend, borrowedGame));
            unityOfWorkMock.Setup(c => c.BorrowedGames.GetBorrowedGameById(It.IsAny <int>())).ReturnsAsync(new BorrowedGame(friend, borrowedGame));

            borrowGameService = new BorrowGameService(unityOfWorkMock.Object);
        }