Пример #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_DuplaSena_Test()
        {
            var listOfValuesDuplaSena = new List <List <string> >
            {
                new List <string>
                {
                    "1",
                    "06/11/2001",
                    "41",
                    "48",
                    "15",
                    "07",
                    "24",
                    "50",
                    "0,00",
                    "0",
                    "&nbsp",
                    "&nbsp",
                    "0,00",
                    "SIM",
                    "588.519,68",
                    "0",
                    "0,00",
                    "0",
                    "0,00",
                    "0",
                    "0,00",
                    "43",
                    "37",
                    "41",
                    "49",
                    "44",
                    "09",
                    "0",
                    "0,00",
                    "55",
                    "2.317,59",
                    "1307",
                    "97,16",
                    "0",
                    "0,00",
                    "0,00",
                    "0,00"
                }
            };
            var expectedDuplaSena = new List <DuplaSena>
            {
                new DuplaSena
                {
                    LotteryId    = 1,
                    DateRealized = new DateTime(2001, 11, 06),
                    DozensRound1 = new List <int> {
                        07, 15, 24, 41, 48, 50
                    }.OrderBy(c => c).ToList(),
                    TotalAmount           = 0.00m,
                    Winners6NumbersRound1 = 0,
                    City = string.Empty,
                    UF   = string.Empty,
                    Average6NumbersRound1  = 0.00m,
                    IsAccumulated          = true,
                    AccumulatedValueRound1 = 588519.68m,
                    Winners5NumbersRound1  = 0,
                    Average5NumbersRound1  = 0.00m,
                    Winners4NumbersRound1  = 0,
                    Average4NumbersRound1  = 0.00m,
                    Winners3NumbersRound1  = 0,
                    Average3NumbersRound1  = 0.00m,
                    DozensRound2           = new List <int> {
                        09, 37, 41, 43, 44, 49
                    }.OrderBy(c => c).ToList(),
                    Winners6NumbersRound2     = 0,
                    Average6NumbersRound2     = 0.00m,
                    Winners5NumbersRound2     = 55,
                    Average5NumbersRound2     = 2317.59m,
                    Winners4NumbersRound2     = 1307,
                    Average4NumbersRound2     = 97.16m,
                    Winners3NumbersRound2     = 0,
                    Average3NumbersRound2     = 0.00m,
                    EstimatedPrize            = 0.00m,
                    AccumulatedEspecialPascoa = 0.00m
                }
            };

            var actualResult = DuplaSenaExtensionMethods.Load(listOfValuesDuplaSena).ToList();

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