예제 #1
0
        public async Task Ver_Listado_Promociones_Success()
        {
            CreatePromocionCommand createCommand = new CreatePromocionCommand
            {
                Bancos                = new string[] { "Galicia" },
                MediosDePago          = new string[] { "TARJETA_CREDITO" },
                CategoriasProductos   = new string[] { "ElectroCocina" },
                PorcentajeDeDescuento = 30,
                FechaInicio           = new DateTime(2021, 3, 1),
                FechaFin              = new DateTime(2021, 3, 31)
            };
            CreatePromocionCommandHandler createHandler = new CreatePromocionCommandHandler(_promocionRepositoryAsync, _mapper);
            var promocionCreada = await createHandler.Handle(createCommand, default(CancellationToken));

            GetAllPromocionesQuery        getAllCommand = new GetAllPromocionesQuery();
            GetAllPromocionesQueryHandler getAllHandler = new GetAllPromocionesQueryHandler(_promocionRepositoryAsync);

            var promociones = await getAllHandler.Handle(getAllCommand, default(CancellationToken));

            Assert.AreEqual(1, promociones.Data.Count());
            Assert.AreEqual(promocionCreada.Data, promociones.Data.First().Id);
        }
예제 #2
0
        public async Task <Response <IEnumerable <Promocion> > > Handle(GetAllPromocionesQuery request, CancellationToken cancellationToken)
        {
            var promociones = await _promocionRepository.GetAllAsync();

            return(new Response <IEnumerable <Promocion> >(promociones.ToList()));
        }