예제 #1
0
        public void GetAllTest(int expected)
        {
            this._context = this.InitContext().Result;
            ProcessorService ps = new ProcessorService(this._context);
            Processor        p1 = new Processor()
            {
                id            = "0",
                name          = "test_processor1",
                version       = "0.0.1",
                enabled       = true,
                description   = "test processor1",
                file_type     = ".fake",
                process_found = 1
            };
            Processor p2 = new Processor()
            {
                id            = "1",
                name          = "test_processor2",
                version       = "0.0.1",
                enabled       = true,
                description   = "test processor2",
                file_type     = ".fake",
                process_found = 1
            };

            this._context.Processors.AddAsync(p1);
            this._context.Processors.AddAsync(p2);
            this._context.SaveChangesAsync();

            var results = ps.GetAll().Result.ToList();

            Assert.Equal(expected, results.Count);
        }
        public async Task <IHttpActionResult> GetAll()
        {
            var processors = await processorService.GetAll();

            var processorDTO = processors.Select(x => mapper.Map <ProcessorDTO>(x));

            return(Ok(processorDTO));
        }