Пример #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_Loteca_Test()
        {
            var listOfValuesLoteca = new List <List <string> >
            {
                new List <string>
                {
                    "1",
                    "18/02/2002",
                    "2",
                    "",
                    "BA",
                    "55.985,99",
                    "NÃO",
                    "0,00",
                    "44",
                    "2.544,81",
                    "1028",
                    "144,68",
                    "2",
                    "1",
                    "1",
                    "2",
                    "1",
                    "2",
                    "x",
                    "1",
                    "x",
                    "1",
                    "1",
                    "2",
                    "1",
                    "1",
                    " - ",
                    " - "
                }
            };
            var expectedLoteca = new List <Loteca>
            {
                new Loteca
                {
                    LotteryId     = 1,
                    DateRealized  = new DateTime(2002, 02, 18),
                    Winners14     = 2,
                    City          = string.Empty,
                    UF            = "BA",
                    Average14     = 55985.99m,
                    IsAcumulated  = false,
                    AmountValue14 = 0.00m,
                    Winners13     = 44,
                    AmountValue13 = 2544.81m,
                    Winners12     = 1028,
                    AmountValue12 = 144.68m,
                    Dozens        = new List <string> {
                        "2", "1", "1", "2", "1", "2", "x", "1", "x", "1", "1", "2", "1", "1"
                    }.OrderBy(c => c).ToList(),
                    TotalAmount    = 0,
                    EstimatedPrize = 0
                }
            };
            var actualResult = LotecaExtensionMethods.Load(listOfValuesLoteca).ToList();

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