Esempio n. 1
0
        public async Task WHEN_repostory_is_queried_for_SportsClubs_with_parkId_THEN_all_SportClubs_with_parkId_are_returned()
        {
            // arrange

            var s1 = new SportsClub
            {
                ClubId = 1010,
                Name   = "Sport club testing one one",
                Park   = new Park {
                    ParkId = 3001
                },
                Sport = new SportType {
                    Name = "Cricket"
                },
                MembershipFee = 1000,
                Members       = 20,
                Email         = "*****@*****.**",
                President     = "someone important"
            };
            var s2 = new SportsClub
            {
                ClubId = 1011,
                Name   = "Sport club testing two one",
                Park   = new Park {
                    ParkId = 3002
                },
                Sport = new SportType {
                    Name = "Football"
                },
                MembershipFee = 300,
                Members       = 3,
                Email         = "*****@*****.**",
                President     = "someone even more important"
            };

            _repository.Add(s1);
            _repository.Add(s2);
            _repository.SaveChangesAsync().Wait();

            // act

            var result1 = await _repository.GetSportsClubsByParkIdAsync(3001);

            var result2 = await _repository.GetSportsClubsByParkIdAsync(3002);

            var result3 = await _repository.GetSportsClubsByParkIdAsync(3003);

            // assert

            Assert.NotEmpty(result1);
            Assert.NotEmpty(result2);
            Assert.Empty(result3);
            Assert.Contains(s1, result1);
            Assert.Contains(s2, result2);
        }
Esempio n. 2
0
        public async Task WHEN_repostory_is_queried_for_SportsClub_with_clubId_THEN_SportClub_with_clubId_is_returned()
        {
            // arrange

            var s1 = new SportsClub
            {
                ClubId = 1020,
                Name   = "Sport club testing one one",
                Park   = new Park(),
                Sport  = new SportType {
                    Name = "Yoga"
                },
                MembershipFee = 1000,
                Members       = 20,
                Email         = "*****@*****.**",
                President     = "someone important"
            };
            var s2 = new SportsClub
            {
                ClubId = 1021,
                Name   = "Sport club testing two one",
                Park   = new Park(),
                Sport  = new SportType {
                    Name = "Other"
                },
                MembershipFee = 300,
                Members       = 3,
                Email         = "*****@*****.**",
                President     = "someone even more important"
            };

            _repository.Add(s1);
            _repository.Add(s2);
            _repository.SaveChangesAsync().Wait();

            // act

            var result1 = await _repository.GetSportsClubByIdAsync(1020);

            var result2 = await _repository.GetSportsClubByIdAsync(1021);

            var result3 = await _repository.GetSportsClubByIdAsync(1022);

            // assert

            Assert.NotNull(result1);
            Assert.NotNull(result2);
            Assert.Null(result3);
            Assert.Equal(s1, result1);
            Assert.Equal(s2, result2);
        }
Esempio n. 3
0
        public async Task WHEN_all_SportsClubs_are_requested_THEN_all_SportClubs_are_returned()
        {
            // arrange

            var s1 = new SportsClub
            {
                ClubId = 1000,
                Name   = "Sport club testing one",
                Park   = new Park(),
                Sport  = new SportType {
                    Name = "Athletics"
                },
                MembershipFee = 20000,
                Members       = 200,
                Email         = "*****@*****.**",
                President     = "someone important"
            };
            var s2 = new SportsClub
            {
                ClubId = 1001,
                Name   = "Sport club testing two",
                Park   = new Park(),
                Sport  = new SportType {
                    Name = "Baseball"
                },
                MembershipFee = 30000,
                Members       = 300,
                Email         = "*****@*****.**",
                President     = "someone even more important"
            };

            _repository.Add(s1);
            _repository.Add(s2);
            await _repository.SaveChangesAsync();

            // act

            var result = await _repository.GetAllSportsClubsAsync();

            // assert

            Assert.NotEmpty(result);
            Assert.Contains(s1, result);
            Assert.Contains(s2, result);
        }
Esempio n. 4
0
        public async Task WHEN_repostory_is_queried_for_SportsClubs_with_sportType_THEN_all_SportClubs_with_sportType_are_returned()
        {
            // arrange

            var s1 = new SportsClub
            {
                ClubId = 1030,
                Name   = "Sport club testing one one",
                Park   = new Park(),
                Sport  = new SportType {
                    Name = "Other"
                },
                MembershipFee = 1000,
                Members       = 20,
                Email         = "*****@*****.**",
                President     = "someone important"
            };
            var s2 = new SportsClub
            {
                ClubId = 1031,
                Name   = "Sport club testing two one",
                Park   = new Park(),
                Sport  = new SportType {
                    Name = "Tennis"
                },
                MembershipFee = 300,
                Members       = 3,
                Email         = "*****@*****.**",
                President     = "someone even more important"
            };
            var s3 = new SportsClub
            {
                ClubId = 1032,
                Name   = "Sport club testing two one",
                Park   = new Park(),
                Sport  = new SportType {
                    Name = "Tennis"
                },
                MembershipFee = 300,
                Members       = 3,
                Email         = "*****@*****.**",
                President     = "someone even more important"
            };

            _repository.Add(s1);
            _repository.Add(s2);
            _repository.Add(s3);
            _repository.SaveChangesAsync().Wait();

            // act

            var result1 = await _repository.GetSportsClubsBySportAsync("Other");

            var result2 = await _repository.GetSportsClubsBySportAsync("Tennis");

            var result3 = await _repository.GetSportsClubsBySportAsync("Bowls");

            // assert

            Assert.NotEmpty(result1);
            Assert.NotEmpty(result2);
            Assert.Null(result3);
            Assert.Contains(s1, result1);
            Assert.Contains(s2, result2);
            Assert.Contains(s3, result2);
        }