Exemplo n.º 1
0
        public async void CanGetPercentageOfFlightsPerMonthFromDestinations()
        {
            // Arrange
            var itemsLGA =
                Builder <FlightDc>
                .CreateListOfSize(78)
                .All()
                .With(x => x.Year, 2013)
                .TheFirst(1)
                .With(x => x.Month, 1)
                .With(x => x.Origin = "EWR")
                .TheNext(2)
                .With(x => x.Month, 2)
                .With(x => x.Origin = "JFK")
                .TheNext(3)
                .With(x => x.Month, 3)
                .With(x => x.Origin = "LGA")
                .TheNext(4)
                .With(x => x.Month, 4)
                .With(x => x.Origin = "EWR")
                .TheNext(5)
                .With(x => x.Month, 5)
                .With(x => x.Origin = "JFK")
                .TheNext(6)
                .With(x => x.Month, 6)
                .With(x => x.Origin = "LGA")
                .TheNext(7)
                .With(x => x.Month, 7)
                .With(x => x.Origin = "EWR")
                .TheNext(8)
                .With(x => x.Month, 8)
                .With(x => x.Origin = "JFK")
                .TheNext(9)
                .With(x => x.Month, 9)
                .With(x => x.Origin = "LGA")
                .TheNext(10)
                .With(x => x.Month, 10)
                .With(x => x.Origin = "EWR")
                .TheNext(11)
                .With(x => x.Month, 11)
                .With(x => x.Origin = "JFK")
                .TheNext(12)
                .With(x => x.Month, 12)
                .With(x => x.Origin = "LGA")
                .Build();

            context.Flights.AddRange(itemsLGA);

            context.SaveChanges();
            //Act
            var result = await flightsRepository.GetPercentageOfFlightsPerMonthFromDestinations();

            result.GroupBy(x => x.Month);

            //Assert
            Assert.Equal(100, result.ElementAt(0).EWR);
            Assert.Equal(100, result.ElementAt(1).JFK);
            Assert.Equal(100, result.ElementAt(2).LGA);
            Assert.Equal(100, result.ElementAt(3).EWR);
            Assert.Equal(100, result.ElementAt(4).JFK);
            Assert.Equal(100, result.ElementAt(5).LGA);
            Assert.Equal(100, result.ElementAt(6).EWR);
            Assert.Equal(100, result.ElementAt(7).JFK);
            Assert.Equal(100, result.ElementAt(8).LGA);
            Assert.Equal(100, result.ElementAt(9).EWR);
            Assert.Equal(100, result.ElementAt(10).JFK);
            Assert.Equal(100, result.ElementAt(11).LGA);
        }