public void TestUpdateMemberOverwrites()
        {
            ITeamRepository   repository = new TestMemoryTeamRepository();
            MembersController controller = new MembersController(repository, new MemoryLocationClient());

            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");
        }
        public void UpdateMemberOverwrites()
        {
            //Given
            ITeamRepository   repository = new TestMemoryTeamRepository();
            MembersController controller = new MembersController(repository);

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

            repository.Add(team);

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

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

            Member updatedMember = new Member(memberId);

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

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

            //Then
            Assert.Equal("Bob", testMember.FirstName);
            Assert.Equal("Jones", testMember.LastName);
        }
Beispiel #3
0
        public void UpdateTeamberOverWrites()
        {
            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   newMemberId = Guid.NewGuid();
            Member newMember   = new Member(newMemberId);

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

            team = repository.Get(teamId);

            Member updateMember = new Member(newMemberId);

            updateMember.FirstName = "Bob";
            updateMember.LastName  = "Jones";
            var result = controller.UpdateMember(updateMember, teamId, newMemberId);

            Assert.True(result is OkResult);

            team = repository.Get(teamId);
            Assert.Equal(1, team.Members.Count);
            Member testMember = team.Members.Where(m => m.ID == newMemberId).First();

            Assert.NotNull(testMember);
            Assert.Equal("Bob", testMember.FirstName);
            Assert.Equal("Jones", testMember.LastName);
        }
        public void TestCreateMemberAddsTeamToList()
        {
            ITeamRepository   repository = new TestMemoryTeamRepository();
            MembersController controller = new MembersController(repository, new MemoryLocationClient());

            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));
        }
        public void CreateMemberAddsTeamToList()
        {
            //Given
            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);
            //When
            team = repository.Get(teamId);
            //Then
            Assert.True(team.Members.Contains(newMember));
        }