public void GetByIdTest() { 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 }; this._context.Processors.AddAsync(p1); this._context.SaveChangesAsync(); var result = ps.GetById(p1.name).Result; Assert.NotNull(result); var badResult = ps.GetById("fakeID").Result; Assert.Null(badResult); }
public async Task <IHttpActionResult> GetById(int id) { var processor = await processorService.GetById(id); if (processor == null) { return(NotFound()); } var processorDTO = mapper.Map <ProcessorDTO>(processor); return(Ok(processorDTO)); }