Ejemplo n.º 1
0
        public void UpdateMembertoNonexistantMemberReturnsNoMatch()
        {
            //Given
            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";

            //When
            var result = controller.UpdateMember(updatedMember, teamId, nonMatchedGuid);

            //Then
            Assert.True(result is NotFoundResult);
        }
        public void TestGetMembersReturnsMembers()
        {
            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   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);
        }
Ejemplo n.º 3
0
        public void UpdateMemeberToNonExistantMembersReturnsNoMatch()
        {
            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";
            newMember.LastName  = "Smith";
            controller.CreateMember(newMember, teamId);

            Guid   nonMatchdGuid = Guid.NewGuid();
            Member updateMember  = new Member(nonMatchdGuid);

            updateMember.FirstName = "Bob";
            var result = controller.UpdateMember(updateMember, teamId, nonMatchdGuid);

            Assert.True(result is NotFoundResult);
        }
Ejemplo n.º 4
0
        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);
        }
        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 async void TestAddsLocation()
        {
            ITeamRepository      repository     = new TestMemoryTeamRepository();
            MemoryLocationClient locationClient = new MemoryLocationClient();
            MembersController    controller     = new MembersController(repository, locationClient);

            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);

            await locationClient.AddLocation(memberId, new LocationRecord()
            {
                Timestamp = 1,
                Altitude  = 123.45f
            });

            Assert.True(locationClient.MemberLocationHistory.ContainsKey(memberId));
        }
Ejemplo n.º 7
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);

            var result   = controller.GetMembers(teamId);
            var okResult = Assert.IsType <OkObjectResult>(result.Result);
            var members  = Assert.IsAssignableFrom <ICollection <Member> >(okResult.Value);

            Assert.Equal(2, members.Count());
            Assert.NotNull(members.Where(m => m.Id == firstMemberId).First());
            Assert.NotNull(members.Where(m => m.Id == secondMemberId).First());
        }
        public async void TestGetNonExistantTeamReturnsNotFound()
        {
            ITeamRepository   repository = new TestMemoryTeamRepository();
            MembersController controller = new MembersController(repository, new MemoryLocationClient());

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

            Assert.True(result is NotFoundResult);
        }
Ejemplo n.º 9
0
        public void GetMembersForNonExistantTeamReturnNotFound()
        {
            ITeamRepository   repository = new TestMemoryTeamRepository();
            MembersController controller = new MembersController(repository);

            var result = controller.GetMembers(Guid.NewGuid());

            Assert.IsType <NotFoundResult>(result.Result);
        }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
0
        public void GetMembersForNonExistantTeamReturnNotFound()
        {
            //Given
            ITeamRepository   repository = new TestMemoryTeamRepository();
            MembersController controller = new MembersController(repository);
            //When
            var result = controller.GetMembers(Guid.NewGuid());

            //Then
            Assert.True(result is NotFoundResult);
        }
        public async void TestGetNonExistantMemberReturnsNotFound()
        {
            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);

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

            Assert.True(result is NotFoundResult);
        }
        public void TestCreateMembertoNonexistantTeamReturnsNotFound()
        {
            ITeamRepository   repository = new TestMemoryTeamRepository();
            MembersController controller = new MembersController(repository, new MemoryLocationClient());

            Guid teamId = Guid.NewGuid();

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

            Assert.True(result is NotFoundResult);
        }
        public void TestGetMembersForNewTeamIsEmpty()
        {
            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);

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

            Assert.Empty(members);
        }
Ejemplo n.º 15
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.IsType <NotFoundResult>(result.Result);
        }
Ejemplo n.º 16
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);

            var result   = controller.GetMembers(teamId);
            var okResult = Assert.IsType <OkObjectResult>(result.Result);
            var members  = Assert.IsAssignableFrom <ICollection <Member> >(okResult.Value);

            Assert.Empty(members);
        }
Ejemplo n.º 17
0
        public void CreateMembertoNonexistantTeamReturnsNotFound()
        {
            //Given
            ITeamRepository   repository = new TestMemoryTeamRepository();
            MembersController controller = new MembersController(repository);

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

            //Then
            Assert.True(result is NotFoundResult);
        }
Ejemplo n.º 18
0
        public void GetMembersForNewTeamIsEmpty()
        {
            //Given
            ITeamRepository   repository = new TestMemoryTeamRepository();
            MembersController controller = new MembersController(repository);

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

            repository.Add(team);
            //When
            ICollection <Member> members = (ICollection <Member>)(controller.GetMembers(teamId) as ObjectResult).Value;

            //Then
            Assert.Empty(members);
        }
Ejemplo n.º 19
0
        public void GetNonExistantMemberReturnsNotFound()
        {
            //Given
            ITeamRepository   repository = new TestMemoryTeamRepository();
            MembersController controller = new MembersController(repository);

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

            repository.Add(team);
            //When
            var result = controller.GetMember(teamId, Guid.NewGuid());

            //Then
            Assert.True(result is NotFoundResult);
        }
        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 async void TestGetExistingMemberReturnsMember()
        {
            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);

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

            Assert.Equal(member.ID, newMember.ID);
        }
Ejemplo n.º 22
0
        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));
        }
Ejemplo n.º 23
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 = controller.GetMember(teamId, memberId).Value;

            Assert.Equal(member.Id, newMember.Id);
        }
        public async void TestGetMemberReturnsLastLocation()
        {
            ITeamRepository   repository     = new TestMemoryTeamRepository();
            ILocationClient   locationClient = new MemoryLocationClient();
            MembersController controller     = new MembersController(repository, locationClient);

            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);

            await locationClient.AddLocation(memberId, new LocationRecord()
            {
                Timestamp = 1,
                Altitude  = 123.45f
            });

            await locationClient.AddLocation(memberId, new LocationRecord()
            {
                Timestamp = 3,
                Altitude  = 123.47f
            });

            await locationClient.AddLocation(memberId, new LocationRecord()
            {
                Timestamp = 2,
                Altitude  = 123.46f
            });

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

            Assert.Equal(member.ID, newMember.ID);
            Assert.NotNull(member.LastLocation);
            Assert.Equal(123.47f, member.LastLocation.Altitude);
        }
Ejemplo n.º 25
0
        public void GetExistingMemberReturnsMember()
        {
            //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);
            //When
            var member = (Member)(controller.GetMember(teamId, memberId) as ObjectResult).Value;

            //Then
            Assert.Equal(newMember.ID, member.ID);
        }
Ejemplo n.º 26
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);
        }