Esempio n. 1
0
        public void CreateAContest()
        {
            var bowlingSystem = new BowlingSystem();
            var arr           = new int[] { 2026, 3002, 3003, 3004 };

            bowlingSystem.CreateANewContest(arr, 4002, 1, 1);
        }
Esempio n. 2
0
        public void Match_Has_Correct_Winner()
        {
            var system = new BowlingSystem(_bowlingRepository);

            var competition = system.FindCompetitions("FirstCompetition").FirstOrDefault();

            var player1 = system.FindParty("winner2017").FirstOrDefault();
            var player2 = system.FindParty("winner2018").FirstOrDefault();

            var players = new List <Party> {
                player1, player2
            };

            system.CreateMatch(competition, players, 2);
            var match = system.FindMatch(competition, 2);

            system.AddScore(match, player1, 100);
            system.AddScore(match, player1, 100);
            system.AddScore(match, player1, 100);

            system.AddScore(match, player2, 15);
            system.AddScore(match, player2, 15);
            system.AddScore(match, player2, 15);

            var matchWinner = match.Winner;

            Assert.Equal(player1, matchWinner);
        }
Esempio n. 3
0
        public void Can_Search_Party()
        {
            var system = new BowlingSystem(_bowlingRepository);

            var party = system.FindParty("winner2017").FirstOrDefault();

            Assert.Contains("winner2017", party.Name);
        }
Esempio n. 4
0
        public void Cannot_Add_Score_If_Match_Is_Missing_Data()
        {
            var system = new BowlingSystem(_bowlingRepository);

            var match = new Match();

            var party = system.FindParty("winner2017").FirstOrDefault();

            Assert.Throws <Exception>(() => system.AddScore(match, party, 10));
        }
Esempio n. 5
0
        public void Winner_Of_The_Year_Is_Correct()
        {
            var system = new BowlingSystem(_bowlingRepository);

            var sut1 = system.GetWinnersOfTheYear(2018).FirstOrDefault();
            var sut2 = system.GetWinnersOfTheYear(2017).FirstOrDefault();

            Assert.Equal("winner2018", sut1.Name);
            Assert.Equal("winner2017", sut2.Name);
        }
Esempio n. 6
0
        public void Can_Create_Party()
        {
            var system = new BowlingSystem(_bowlingRepository);

            system.CreateParty("Bertil Sandrasson", "451007-7835");

            var foundParty = _context.Parties.Where(p => p.Name.Contains("Bertil Sandrasson")).FirstOrDefault();

            Assert.Equal("Bertil Sandrasson", foundParty.Name);
        }
Esempio n. 7
0
        public void GetWinner()
        {
            var database = new DataBaseRepo();
            var sut      = new BowlingSystem();
            var contest  = (Contest)database.GetObject("1011", new Contest());

            contest.WinnerId = 2026;
            var result = sut.GetWinnerOfContest(contest);

            Assert.Equal(contest.ContestId, result.ContestId);
        }
Esempio n. 8
0
        public void CreateANewParty()
        {
            var party = new Party {
                LegalId = "0000000000", Address = "Vägen 1", IsManager = true, Name = "Manager Managersson"
            };
            var bowlingSystem = new BowlingSystem();
            var newParty      = bowlingSystem.CreateANewManager(party.LegalId, party.Name, party.Address);

            party.PartyId = newParty.PartyId;
            Assert.Equal(party, newParty);
        }
Esempio n. 9
0
        public void Cannot_Add_Score_If_Party_Is_Missing_Data()
        {
            var system = new BowlingSystem(_bowlingRepository);

            var competition = system.FindCompetitions("FirstCompetition").FirstOrDefault();

            var match = system.FindMatch(competition, 1);

            var party = new Party();

            Assert.Throws <Exception>(() => system.AddScore(match, party, 10));
        }
Esempio n. 10
0
        public void CanGenerateMatchesForCompetition()
        {
            var sut = new BowlingSystem(new SqlBowlingRepository(_context));
            //Arrange
            var comp        = _context.Competitions.FirstOrDefault();
            var playerCount = comp.Players.Count();
            //Act
            var list = sut.GenerateMatches(comp.CompetitionId);

            //Assert
            Assert.Equal(playerCount / 2, list.Count);
        }
        public void Can_Search_Competition()
        {
            var system = new BowlingSystem(_bowlingRepository);

            var competitionToSearchFor = _context.Competitions
                                         .FirstOrDefault(c => c.Name == "FirstCompetition");

            var competitionFoundByName = system.FindCompetitions(competitionToSearchFor.Name).FirstOrDefault();
            var competitionFoundById   = system.FindCompetitions(competitionToSearchFor.Id.ToString()).FirstOrDefault();

            Assert.Equal(competitionToSearchFor.Name, competitionFoundByName.Name);
            Assert.Equal(competitionToSearchFor.Id, competitionFoundById.Id);
        }
Esempio n. 12
0
        public void CanGetWinnerOfYear()
        {
            var sut = new BowlingSystem(new SqlBowlingRepository(_context));

            //Arrange
            var expectedWinner = _context.Players.FirstOrDefault(x => x.Name == "Stefan");

            //Act
            var winnerOfYear = sut.GetWinnerOfYear(2017);

            //Assert
            Assert.Equal(expectedWinner.PartyId, winnerOfYear);
        }
        public void Can_Create_Competition()
        {
            var system = new BowlingSystem(_bowlingRepository);

            var id        = Guid.NewGuid();
            var startDate = new DateTime(2017, 10, 04);
            var endDate   = new DateTime(2017, 11, 07);

            system.CreateCompetition("NewCompetition", id, startDate, endDate);

            bool competitionExists = _context.Competitions.ToList().Exists(c => c.Id == id);

            Assert.True(competitionExists);
        }
        public void Can_Update_Competition()
        {
            var system = new BowlingSystem(_bowlingRepository);

            var competition = _context.Competitions.FirstOrDefault(c => c.Name == "FirstCompetition");

            competition.Name = "ModifiedCompetition";

            system.SaveCompetition(competition);

            var foundCompetition = _context.Competitions.FirstOrDefault(c => c.Id == competition.Id);

            Assert.NotNull(competition);
            Assert.Equal("ModifiedCompetition", foundCompetition.Name);
        }
Esempio n. 15
0
        public void Can_Add_Score()
        {
            var system = new BowlingSystem(_bowlingRepository);

            var competition = system.FindCompetitions("FirstCompetition").FirstOrDefault();

            var player1 = system.FindParty("Agneta").FirstOrDefault();
            var player2 = system.FindParty("Ahmed").FirstOrDefault();

            var players = new List <Party> {
                player1, player2
            };

            var match = system.FindMatch(competition, 1);

            system.AddScore(match, player1, 50);
        }
        public void Can_Save_Competition()
        {
            var system = new BowlingSystem(_bowlingRepository);

            var newGuid = Guid.NewGuid();

            var competition = new Competition()
            {
                Id   = newGuid,
                Name = "Hello"
            };

            system.SaveCompetition(competition);

            var foundCompetition = _context.Competitions.FirstOrDefault(x => x.Id == newGuid);

            Assert.Equal(foundCompetition.Id, newGuid);
        }