示例#1
0
 public PromocionesManager(PromocionesDbContext DbContext, IDateTime datetime, IProductosManager prmanager, IMedioPagoManager mpmanager)
 {
     this._DbContext = DbContext;
     this._datetime  = datetime;
     this._prmanager = prmanager;
     this._mpmanager = mpmanager;
 }
        public PromocionesTests()
        {
            testDataPromociones = new List <Promocion>()
            {
                new Promocion()
                {
                    Id                   = 1,
                    Activo               = true,
                    TipoMedioPagoIds     = null,
                    EntidadFinancieraIds = null,
                    MedioPagoIds         = new List <int> {
                        1, 2, 3
                    },
                    ProductoCategoriaIds = new List <int> {
                        1, 2, 3, 4, 5, 6
                    },
                    MaxCantidadDeCuotas = 12,
                    PorcentajeDecuento  = 15,
                    FechaInicio         = new DateTime(2018, 06, 01),
                    FechaFin            = new DateTime(2019, 06, 01)
                },
                new Promocion()
                {
                    Id                   = 2,
                    Activo               = true,
                    TipoMedioPagoIds     = null,
                    EntidadFinancieraIds = new List <int> {
                        1
                    },
                    MedioPagoIds         = null,
                    ProductoCategoriaIds = new List <int> {
                        1, 2, 3, 4, 5, 6
                    },
                    MaxCantidadDeCuotas = 12,
                    PorcentajeDecuento  = 10,
                    FechaInicio         = new DateTime(2018, 06, 01),
                    FechaFin            = new DateTime(2019, 06, 01)
                },
                new Promocion()
                {
                    Id               = 3,
                    Activo           = true,
                    TipoMedioPagoIds = new List <int> {
                        1, 2
                    },
                    EntidadFinancieraIds = null,
                    MedioPagoIds         = null,
                    ProductoCategoriaIds = new List <int> {
                        1, 2, 3, 4, 5, 6
                    },
                    MaxCantidadDeCuotas = 12,
                    PorcentajeDecuento  = 20,
                    FechaInicio         = new DateTime(2018, 06, 01),
                    FechaFin            = new DateTime(2019, 06, 01)
                },
                new Promocion()
                {
                    Id                   = 4,
                    Activo               = true,
                    TipoMedioPagoIds     = null,
                    EntidadFinancieraIds = null,
                    MedioPagoIds         = new List <int> {
                        10
                    },
                    ProductoCategoriaIds = new List <int> {
                        1, 2, 3, 4, 5, 6
                    },
                    MaxCantidadDeCuotas = null,
                    PorcentajeDecuento  = 25,
                    FechaInicio         = new DateTime(2018, 06, 01),
                    FechaFin            = new DateTime(2019, 06, 01)
                },
                new Promocion()
                {
                    Id               = 5,
                    Activo           = true,
                    TipoMedioPagoIds = new List <int> {
                        1
                    },
                    EntidadFinancieraIds = new List <int> {
                        1
                    },
                    MedioPagoIds         = null,
                    ProductoCategoriaIds = new List <int> {
                        1, 2, 3, 4, 5, 6
                    },
                    MaxCantidadDeCuotas = 12,
                    PorcentajeDecuento  = 5,
                    FechaInicio         = new DateTime(2018, 06, 01),
                    FechaFin            = new DateTime(2019, 06, 01)
                },
                new Promocion()
                {
                    Id               = 6,
                    Activo           = true,
                    TipoMedioPagoIds = new List <int> {
                        1
                    },
                    EntidadFinancieraIds = new List <int> {
                        1
                    },
                    MedioPagoIds = new List <int> {
                        1
                    },
                    ProductoCategoriaIds = new List <int> {
                        1, 2, 3, 4, 5, 6
                    },
                    MaxCantidadDeCuotas = 12,
                    PorcentajeDecuento  = 5,
                    FechaInicio         = new DateTime(2018, 01, 01),
                    FechaFin            = new DateTime(2018, 06, 01)
                }
            };
            testDataCategorias = new List <ProductoCategoria>
            {
                new ProductoCategoria()
                {
                    Id = 1, Descripcion = "Tvs"
                },
                new ProductoCategoria()
                {
                    Id = 2, Descripcion = "Heladeras"
                },
                new ProductoCategoria()
                {
                    Id = 3, Descripcion = "Lavarropas"
                },
                new ProductoCategoria()
                {
                    Id = 4, Descripcion = "Celulares"
                },
                new ProductoCategoria()
                {
                    Id = 5, Descripcion = "Notebooks"
                },
                new ProductoCategoria()
                {
                    Id = 6, Descripcion = "Gaming"
                }
            };
            testDataMediosPago = new List <MedioPago>()
            {
                new MedioPago()
                {
                    Id = 1, Descripcion = "MercadoPago"
                },
                new MedioPago()
                {
                    Id = 2, Descripcion = "Visa Debito"
                },
                new MedioPago()
                {
                    Id = 3, Descripcion = "Visa"
                },
                new MedioPago()
                {
                    Id = 4, Descripcion = "MasterCard"
                },
                new MedioPago()
                {
                    Id = 5, Descripcion = "American Express"
                }
            };


            //el contexto esta poblado con promociones vigentes este año desde junio a junio del 2018 y una promocion de enero a junio de 2018
            var options = new DbContextOptionsBuilder <PromocionesDbContext>().UseInMemoryDatabase(databaseName: "Promociones").Options;

            context = new PromocionesDbContext(options);
            context.AddRange(testDataPromociones);
            context.SaveChanges();
        }
 public PromocionRepository(PromocionesDbContext dbContext)
 {
     DbContext = dbContext;
 }