Exemplo n.º 1
0
        public IEnumerable <MongoModel> ChooseLottery(List <List <string> > htmlLines, string lotteryName)
        {
            _logger.LogDebug($"Initializing loading for lottery {lotteryName}");
            switch (lotteryName)
            {
            case "DuplaSena":
                return(DuplaSenaExtensionMethods.Load(htmlLines));

            case "Federal":
                return(FederalExtensionMethods.Load(htmlLines));

            case "TimeMania":
                return(TimeManiaExtensionMethods.Load(htmlLines));

            case "Quina":
                return(QuinaExtensionMethods.Load(htmlLines));

            case "LotoMania":
                return(LotoManiaExtensionMethods.Load(htmlLines));

            case "LotoGol":
                return(LotoGolExtensionMethods.Load(htmlLines));

            case "LotoFacil":
                return(LotoFacilExtensionMethods.Load(htmlLines));

            case "Loteca":
                return(LotecaExtensionMethods.Load(htmlLines));

            case "MegaSena":
                return(MegaSenaExtensionMethods.Load(htmlLines));

            default:
                _logger.LogError($"Error when try to load lottery {lotteryName}.");
                throw new NotSupportedException($"Lottery {lotteryName} did not support.");
            }
        }
        public void ExtensioMethod_LotoMania_Test()
        {
            var listOfValuesLotoMania = new List <List <string> >
            {
                new List <string>
                {
                    "1",
                    "02/10/1999",
                    "16",
                    "11",
                    "88",
                    "32",
                    "25",
                    "00",
                    "70",
                    "78",
                    "73",
                    "61",
                    "90",
                    "89",
                    "46",
                    "95",
                    "06",
                    "33",
                    "34",
                    "21",
                    "14",
                    "22",
                    "0,00",
                    "0",
                    "&nbsp",
                    "&nbsp",
                    "1",
                    "46",
                    "446",
                    "2716",
                    "0",
                    "0,00",
                    "118.746,87",
                    "2.581,46",
                    "132,62",
                    "21,78",
                    "0,00",
                    "178.120,31",
                    "0,00",
                    "0,00",
                    "0,00",
                    "0,00",
                    "59.373,46",
                    "0,00",
                    ""
                }
            };
            var expectedLotoMania = new List <LotoMania>
            {
                new LotoMania
                {
                    LotteryId    = 1,
                    DateRealized = new DateTime(1999, 10, 02),
                    Dozens       = new List <int> {
                        16, 11, 88, 32, 25, 00, 70, 78, 73, 61, 90, 89, 46, 95, 06, 33, 34, 21, 14, 22
                    }.OrderBy(c => c).ToList(),
                    TotalValue            = 0.00m,
                    TotalWinners20        = 0,
                    City                  = string.Empty,
                    UF                    = string.Empty,
                    TotalWinners19        = 1,
                    TotalWinners18        = 46,
                    TotalWinners17        = 446,
                    TotalWinners16        = 2716,
                    TotalWinnersNoNumbers = 0,
                    TotalValueNumbers20   = 0.00m,
                    TotalValueNumbers19   = 118746.87m,
                    TotalValueNumbers18   = 2581.46m,
                    TotalValueNumbers17   = 132.62m,
                    TotalValueNumbers16   = 21.78m,
                    TotalValueNoNumbers   = 0.00m,
                    Acumulated20          = 178120.31m,
                    Acumulated19          = 0.00m,
                    Acumulated18          = 0.00m,
                    Acumulated17          = 0.00m,
                    Acumulated16          = 0.00m,
                    AcumulatedNoNumbers   = 59373.46m,
                    PrizeEstimated        = 0.00m,
                    SpecialPrizeEstimated = 0m
                }
            };
            var actualResult = LotoManiaExtensionMethods.Load(listOfValuesLotoMania).ToList();

            Assert.AreEqual(expectedLotoMania.ToString(), actualResult.ToString());
            CollectionAssert.AreEqual(expectedLotoMania, actualResult);
            Assert.AreNotEqual(expectedLotoMania.First().GetHashCode(), actualResult.First().GetHashCode());
        }