public void Verify_Add_Should_AddTheEntityToTheContext()
 {
     // Arrange
     Mock<IDbSet<TeamMember>> mockSetTeamMembers;
     var mockContext = TeamMembersMockingSetup.DoMockingSetupForContext(false, out mockSetTeamMembers);
     var repository = new TeamMembersRepository(mockContext.Object);
     var teamMembers = new TeamMember { Active = true, CustomKey = "SALVATORE-RAA", };
     // Act
     repository.Add(teamMembers);
     // Assert
     mockSetTeamMembers.Verify(x => x.Add(teamMembers), Times.Once);
 }
Example #2
0
        public void Verify_Add_Should_AddTheEntityToTheContext()
        {
            // Arrange
            Mock <IDbSet <TeamMember> > mockSetTeamMembers;
            var mockContext = TeamMembersMockingSetup.DoMockingSetupForContext(false, out mockSetTeamMembers);
            var repository  = new TeamMembersRepository(mockContext.Object);
            var teamMembers = new TeamMember {
                Active = true, CustomKey = "SALVATORE-RAA",
            };

            // Act
            repository.Add(teamMembers);
            // Assert
            mockSetTeamMembers.Verify(x => x.Add(teamMembers), Times.Once);
        }
        public ActionResult Add(TeamMember teamMember)
        {
            ValidateTeamMember(teamMember);

            if (ModelState.IsValid)
            {
                _teamMembersRepository.Add(teamMember);

                TempData["Message"] = "Your team member was successfully added!";

                return(RedirectToAction("Detail", new { id = teamMember.Id }));
            }

            return(View(teamMember));
        }