public void SortearFamilia()
        {
            //Arranjo
            _familiaRepositoryMock.Setup(m => m.Query()).Returns(RetornaFamiliasParaCalcularPontos());

            //Ação
            var familia = _familiaService.SortearFamilia();

            //Confirmação
            Assert.Equal(3, familia.FamiliaId);
        }
Exemple #2
0
        public List <FamiliaDto> Sorteio()
        {
            _ = new List <FamiliaDto>();
            if (!_memoryCache.TryGetValue("sorteio", out List <FamiliaDto> familias))
            {
                familias = _familiaService.SortearFamilia();
                MemoryCacheEntryOptions cacheOptions = new MemoryCacheEntryOptions();
                cacheOptions.SetPriority(CacheItemPriority.High);
                cacheOptions.AbsoluteExpiration = DateTime.Now.AddMinutes(10);
                _memoryCache.Set("sorteio", familias, cacheOptions);
            }

            return(familias);
        }
        public SorteioDto Get()
        {
            var familia = new SorteioDto();

            if (!_memoryCache.TryGetValue("sorteio", out familia))
            {
                familia = _service.SortearFamilia();
                MemoryCacheEntryOptions cacheOptions = new MemoryCacheEntryOptions();
                cacheOptions.SetPriority(CacheItemPriority.High);
                cacheOptions.AbsoluteExpiration = DateTime.Now.AddMinutes(10);
                _memoryCache.Set("sorteio", familia, cacheOptions);
            }

            return(familia);
        }
Exemple #4
0
        public void TestListaSorteadaDeFamilia()
        {
            //Arranjo
            _familiaRepositoryMock.Setup(p => p.Query()).Returns(FuncaoRetornaFamilias());

            //Acao
            var lista = _familiaService.SortearFamilia();

            //Confirmacao
            var familiaSorteada = lista.First();

            Assert.Equal("53ce49c7-e793-48c8-bf69-381c9e5dc9e3", familiaSorteada.FamiliaId);
            Assert.Equal(3, familiaSorteada.PontosECriterios.QuantidadeDeCriteriosAtendidos);
            Assert.Equal(8, familiaSorteada.PontosECriterios.TotalDePontos);
            Assert.NotNull(familiaSorteada.DataSelecao);
        }