private IHttpContextAccessor _httpContextAccessor; // Lo usao para acceder al contexto del usuario logeado

        public PersonasController(ApplicationDbContext context, IPersonaQueryRepository personasQueryRepository, IPersonaCommandService personaCommandService, IPersonaQueryService personaQueryService, IHttpContextAccessor httpContextAccessor)
        {
            this.db = context;
            this._personasQueryRepository = personasQueryRepository;
            this._personaCommandService   = personaCommandService;
            this._personaQueryService     = personaQueryService;
            this._httpContextAccessor     = httpContextAccessor;
        }
예제 #2
0
        public void Setup()
        {
            //ESTO ES PORQUE ESTO SE INICIALIZA EN LA APLICACION EN GLOBAL.ASAX DONDE EL AUTOFAC Y SI NO LO HAGO EL Dispatcher siempre es null y peta
            DomainEvents.Dispatcher = new Infrastructure.Messaging.MassTransit.Middleware();
            this.listaPersona       = new List <Persona>()
            {
                new Persona(1, "30948980c", "Juan", "Garcia", 635654565),
                new Persona(2, "30985679T", "Carmen", "Lara", 620897634),
            };

            //Deshabilito la cache
            cacheRepositoryPersona.Setup(r => r.Get(It.IsAny <string>())).Returns((IEnumerable <Persona>)null);

            this.connection = new SqlConnection(CONNECTION_STRING);
            //Creo la conexion
            this.connectionFactory.Setup(x => x.Create()).Returns(connection);
            // Creo el objeto QueryRepository con la conexion y la cache , para poder acceder a las funciones que estan en el Test
            this.personaQueryRepository = new PersonaQueryRepository(this.connectionFactory.Object, cacheRepositoryPersona.Object);
        }
 public PersonaQueryService(IPersonaQueryRepository personaQueryRepository)
 {
     this.personaQueryRepository = personaQueryRepository;
 }
예제 #4
0
 public PersonasController(IPersonaQueryRepository personasQuery, IPersonaQueryService personaQueryService, IPersonaCommandService personaCommandService)
 {
     this._personasQueryRepository = personasQuery;
     this._personaCommandService   = personaCommandService;
     this._personaQueryService     = personaQueryService;
 }