Beispiel #1
0
        public async void Given_CompetitionsWithCountryExist_When_GetCompetitionsByCountry_Then_CompetitionsAreReturned()
        {
            // Arrange
            var leagues     = CreateTeamLeagues();
            var contextMock = MockDbContext(leagues.AsQueryable());
            var handler     = new GetCompetitionsQueryHandler(
                contextMock.Object,
                CreateMapper());

            //Act
            var result = await handler.Handle(
                new GetCompetitionsQuery { Country = "England" },
                CancellationToken.None);

            //Assert
            result.Count().Should().Be(2);
            var list = result.ToList();

            list[0].Name.Should().Be("Premier League 2018-2019");
            list[0].Country.Should().Be("England");
            list[0].Competitors.Count().Should().Be(2);

            list[1].Name.Should().Be("Premier League 2019-2020");
            list[1].Country.Should().Be("England");
            list[1].Competitors.Count().Should().Be(2);
        }
Beispiel #2
0
        public async void Given_NoCompetitionsExist_When_GetCompetitions_Then_EmptyListIsReturned()
        {
            // Arrange
            var leagues     = new List <TeamLeague>();
            var contextMock = MockDbContext(leagues.AsQueryable());
            var handler     = new GetCompetitionsQueryHandler(
                contextMock.Object,
                CreateMapper());

            //Act
            var result = await handler.Handle(
                new GetCompetitionsQuery(),
                CancellationToken.None);

            //Assert
            result.Count().Should().Be(0);
        }