コード例 #1
0
 public void Verify_Deactivate_Should_SetTheActivePropertyToFalseOnTheEntity()
 {
     // Arrange
     Mock<IDbSet<TeamMember>> mockSetTeamMembers;
     var mockContext = TeamMembersMockingSetup.DoMockingSetupForContext(true, out mockSetTeamMembers);
     var repository = new TeamMembersRepository(mockContext.Object);
     var teamMembers = repository.Get(1);
     // Act
     repository.Deactivate(teamMembers);
     // Assert
     Assert.Equal(false, teamMembers.Active);
 }
コード例 #2
0
        public void Verify_Get_ByKey_Should_ReturnTheCorrectTeamMember()
        {
            // Arrange
            Mock <IDbSet <TeamMember> > mockSetTeamMembers;
            var mockContext = TeamMembersMockingSetup.DoMockingSetupForContext(true, out mockSetTeamMembers);
            var repository  = new TeamMembersRepository(mockContext.Object);
            // Act
            var teamMembers = repository.Get("KING-STEPHEN");

            // Assert
            Assert.Equal("/TEST/KING-STEPHEN", teamMembers.ApiDetailUrl);
        }
コード例 #3
0
        public void Verify_Deactivate_Should_SetTheActivePropertyToFalseOnTheEntity()
        {
            // Arrange
            Mock <IDbSet <TeamMember> > mockSetTeamMembers;
            var mockContext = TeamMembersMockingSetup.DoMockingSetupForContext(true, out mockSetTeamMembers);
            var repository  = new TeamMembersRepository(mockContext.Object);
            var teamMembers = repository.Get(1);

            // Act
            repository.Deactivate(teamMembers);
            // Assert
            Assert.Equal(false, teamMembers.Active);
        }
コード例 #4
0
        public void Verify_Remove_Should_RemoveTheEntityFromTheContext()
        {
            // Arrange
            Mock <IDbSet <TeamMember> > mockSetTeamMembers;
            var mockContext = TeamMembersMockingSetup.DoMockingSetupForContext(true, out mockSetTeamMembers);
            var repository  = new TeamMembersRepository(mockContext.Object);
            var teamMembers = repository.Get(1);

            // Act
            repository.Remove(teamMembers);
            // Assert
            mockSetTeamMembers.Verify(x => x.Remove((TeamMember)teamMembers), Times.Once);
        }
コード例 #5
0
        public ActionResult Detail(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var teamMember = _teamMembersRepository.Get((int)id);

            if (teamMember == null)
            {
                return(HttpNotFound());
            }

            // Sort the teams.
            teamMember.Teams = teamMember.Teams
                               .OrderBy(t => t.Team.Event.Title)
                               .OrderByDescending(t => t.Team.TeamName)
                               .ToList();

            return(View(teamMember));
        }
コード例 #6
0
        public void Verify_Update_Should_SetTheEntityStateToModified()
        {
            // Arrange
            Mock <IDbSet <TeamMember> > mockSetTeamMembers;
            var mockContext = TeamMembersMockingSetup.DoMockingSetupForContext(true, out mockSetTeamMembers);
            var repository  = new TeamMembersRepository(mockContext.Object);
            var teamMembers = repository.Get(1);

            teamMembers.ApiDetailUrl = "/TEST";
            // Act
            repository.Update(teamMembers);
            // Assert
            mockContext.Verify(x => x.SetModified(It.IsAny <object>()), Times.Once);
        }
コード例 #7
0
 public void Verify_Get_ByID_Should_ReturnTheCorrectTeamMember()
 {
     // Arrange
     Mock<IDbSet<TeamMember>> mockSetTeamMembers;
     var mockContext = TeamMembersMockingSetup.DoMockingSetupForContext(true, out mockSetTeamMembers);
     var repository = new TeamMembersRepository(mockContext.Object);
     // Act
     var teamMembers = repository.Get(1);
     // Assert
                 Assert.Equal("/TEST/KING-STEPHEN", teamMembers.ApiDetailUrl);
 }
コード例 #8
0
 public void Verify_Update_Should_SetTheEntityStateToModified()
 {
     // Arrange
     Mock<IDbSet<TeamMember>> mockSetTeamMembers;
     var mockContext = TeamMembersMockingSetup.DoMockingSetupForContext(true, out mockSetTeamMembers);
     var repository = new TeamMembersRepository(mockContext.Object);
     var teamMembers = repository.Get(1);
     teamMembers.ApiDetailUrl = "/TEST";
     // Act
     repository.Update(teamMembers);
     // Assert
     mockContext.Verify(x => x.SetModified(It.IsAny<object>()), Times.Once);
 }
コード例 #9
0
 public void Verify_Remove_Should_RemoveTheEntityFromTheContext()
 {
     // Arrange
     Mock<IDbSet<TeamMember>> mockSetTeamMembers;
     var mockContext = TeamMembersMockingSetup.DoMockingSetupForContext(true, out mockSetTeamMembers);
     var repository = new TeamMembersRepository(mockContext.Object);
     var teamMembers = repository.Get(1);
     // Act
     repository.Remove(teamMembers);
     // Assert
     mockSetTeamMembers.Verify(x => x.Remove((TeamMember)teamMembers), Times.Once);
 }