public void AddRewardTest() { Team _team = new Team(); _team.Name = "Barcelona"; _team.TeamId = 1; _team.Password = "******"; _team.Mail = "*****@*****.**"; Player player = new Player(); player.Name = "Messi"; player.PlayerId = 1; player.Born = new DateTime(1987, 12, 23); player.Position = "Middle Attacker"; player.Surname = "Lionel"; player.TeamId = 1; Reward reward = new Reward(); reward.Name = "Reward"; reward.Date = "1987-01-23"; reward.TeamId = 1; Reward reward1 = new Reward(); reward1.Name = "Reward1"; reward1.Date = "1989-01-23"; reward1.TeamId = 1; // Arrange var mockHighService = new Mock <IHighLevelSoccerManagerService>(); var mockLowService = new Mock <ILowLevelSoccerManagmentService>(); mockHighService.Setup(service => service.GetAllTeam()).Returns(new List <Team>() { _team }); mockLowService.Setup(service => service.GetAllPlayers()).Returns(new List <Player>() { player }); mockLowService.Setup(service => service.GetAllRewards()).Returns(new List <Reward>() { reward }); var store = new Mock <IUserStore <User> >(); var mockUserStore = new Mock <IUserStore <User> >(); var mockUserRoleStore = mockUserStore.As <IUserRoleStore <User> >(); var userManager = new Mock <UserManager <User> >(mockUserStore.Object, null, null, null, null, null, null, null, null); userManager.Setup(u => u.GetUserAsync(It.IsAny <ClaimsPrincipal>())).ReturnsAsync( new User() { UserName = "******", UserId = 1 }); TeamController controller = new TeamController(mockHighService.Object, mockLowService.Object, userManager.Object); controller.ControllerContext = new ControllerContext { HttpContext = new DefaultHttpContext { User = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.Name, "Test") })) } }; // Act RedirectToActionResult result = (RedirectToActionResult)controller.AddReward(reward).Result; // Assert var viewResult = Assert.IsType <RedirectToActionResult>(result); }