Beispiel #1
0
        public void UpdateMemberOverwrites()
        {
            ITeamRepository   repository = new TestMemoryTeamRepository();
            MembersController controller = new MembersController(repository);

            Guid teamId    = Guid.NewGuid();
            Team team      = new Team("TestTeam", teamId);
            var  debugTeam = repository.Add(team);

            Guid   memberId  = Guid.NewGuid();
            Member newMember = new Member(memberId);

            newMember.FirstName = "Jim";
            newMember.LastName  = "Smith";
            controller.CreateMember(newMember, teamId);

            team = repository.Get(teamId);

            Member updatedMember = new Member(memberId);

            updatedMember.FirstName = "Bob";
            updatedMember.LastName  = "Jones";
            controller.UpdateMember(updatedMember, teamId, memberId);

            team = repository.Get(teamId);
            Member testMember = team.Members.Where(m => m.ID == memberId).First();

            Assert.Equal(testMember.FirstName, "Bob");
            Assert.Equal(testMember.LastName, "Jones");
        }
Beispiel #2
0
        public void GetMembersReturnsMembers()
        {
            ITeamRepository   repository = new TestMemoryTeamRepository();
            MembersController controller = new MembersController(repository);

            Guid teamId    = Guid.NewGuid();
            Team team      = new Team("TestTeam", teamId);
            var  debugTeam = repository.Add(team);

            Guid   firstMemberId = Guid.NewGuid();
            Member newMember     = new Member(firstMemberId);

            newMember.FirstName = "Jim";
            newMember.LastName  = "Smith";
            controller.CreateMember(newMember, teamId);

            Guid secondMemberId = Guid.NewGuid();

            newMember           = new Member(secondMemberId);
            newMember.FirstName = "John";
            newMember.LastName  = "Doe";
            controller.CreateMember(newMember, teamId);

            ICollection <Member> members = (ICollection <Member>)(controller.GetMembers(teamId) as ObjectResult).Value;

            Assert.Equal(2, members.Count());
            Assert.NotNull(members.Where(m => m.ID == firstMemberId).First().ID);
            Assert.NotNull(members.Where(m => m.ID == secondMemberId).First().ID);
        }
Beispiel #3
0
        public void GetNonExistantTeamReturnsNotFound()
        {
            ITeamRepository   repository = new TestMemoryTeamRepository();
            MembersController controller = new MembersController(repository);

            var result = controller.GetMember(Guid.NewGuid(), Guid.NewGuid());

            Assert.True(result is NotFoundResult);
        }
Beispiel #4
0
        public void CreateMembertoNonexistantTeamReturnsNotFound()
        {
            ITeamRepository   repository = new TestMemoryTeamRepository();
            MembersController controller = new MembersController(repository);

            Guid teamId = Guid.NewGuid();

            Guid   newMemberId = Guid.NewGuid();
            Member newMember   = new Member(newMemberId);
            var    result      = controller.CreateMember(newMember, teamId);

            Assert.True(result is NotFoundResult);
        }
Beispiel #5
0
        public void GetNonExistantMemberReturnsNotFound()
        {
            ITeamRepository   repository = new TestMemoryTeamRepository();
            MembersController controller = new MembersController(repository);

            Guid teamId    = Guid.NewGuid();
            Team team      = new Team("TestTeam", teamId);
            var  debugTeam = repository.Add(team);

            var result = controller.GetMember(teamId, Guid.NewGuid());

            Assert.True(result is NotFoundResult);
        }
Beispiel #6
0
        public void GetMembersForNewTeamIsEmpty()
        {
            ITeamRepository   repository = new TestMemoryTeamRepository();
            MembersController controller = new MembersController(repository);

            Guid teamId    = Guid.NewGuid();
            Team team      = new Team("TestTeam", teamId);
            var  debugTeam = repository.Add(team);

            ICollection <Member> members = (ICollection <Member>)(controller.GetMembers(teamId) as ObjectResult).Value;

            Assert.Empty(members);
        }
Beispiel #7
0
        public void CreateMemberAddsTeamToList()
        {
            ITeamRepository   repository = new TestMemoryTeamRepository();
            MembersController controller = new MembersController(repository);

            Guid teamId = Guid.NewGuid();
            Team team   = new Team("TestController", teamId);

            repository.Add(team);

            Guid   newMemberId = Guid.NewGuid();
            Member newMember   = new Member(newMemberId);

            controller.CreateMember(newMember, teamId);

            team = repository.Get(teamId);
            Assert.True(team.Members.Contains(newMember));
        }
Beispiel #8
0
        public void GetExistingMemberReturnsMember()
        {
            ITeamRepository   repository = new TestMemoryTeamRepository();
            MembersController controller = new MembersController(repository);

            Guid teamId    = Guid.NewGuid();
            Team team      = new Team("TestTeam", teamId);
            var  debugTeam = repository.Add(team);

            Guid   memberId  = Guid.NewGuid();
            Member newMember = new Member(memberId);

            newMember.FirstName = "Jim";
            newMember.LastName  = "Smith";
            controller.CreateMember(newMember, teamId);

            Member member = (Member)(controller.GetMember(teamId, memberId) as ObjectResult).Value;

            Assert.Equal(member.ID, newMember.ID);
        }
Beispiel #9
0
        public void UpdateMembertoNonexistantMemberReturnsNoMatch()
        {
            ITeamRepository   repository = new TestMemoryTeamRepository();
            MembersController controller = new MembersController(repository);

            Guid teamId = Guid.NewGuid();
            Team team   = new Team("TestController", teamId);

            repository.Add(team);

            Guid   memberId  = Guid.NewGuid();
            Member newMember = new Member(memberId);

            newMember.FirstName = "Jim";
            controller.CreateMember(newMember, teamId);

            Guid   nonMatchedGuid = Guid.NewGuid();
            Member updatedMember  = new Member(nonMatchedGuid);

            updatedMember.FirstName = "Bob";
            var result = controller.UpdateMember(updatedMember, teamId, nonMatchedGuid);

            Assert.True(result is NotFoundResult);
        }