public async void TestReturnSkills() { var options = new DbContextOptionsBuilder <Databasecontext >().UseInMemoryDatabase(databaseName: "Test1") .Options; using (var context = new Databasecontext(options)) { var skill = new Skill() { SkillId = 1, SkillName = "test", Description = "test" }; context.Add(skill); context.SaveChanges(); SkillsController Skills = new SkillsController(context); var skills = await Skills.GetSkills(); IEnumerable <Skill> result = skills.Value; Assert.Equal("test", result.Last().Description); Assert.Single(result); } }
public async void UpdateSkill_Put() { var query = new SkillsController(context); var newSkill = new Skills { Id = 3, Name = "ASP.NET Framework", Type = 2 }; // https://stackoverflow.com/questions/36856073/the-instance-of-entity-type-cannot-be-tracked-because-another-instance-of-this-t/42475617 var local = context.Skills.Local.Where(t => t.Id == 3).FirstOrDefault(); if (local != null) { context.Entry(local).State = EntityState.Detached; // only needed for xUnit testing } var result = await query.PutSkills(3, newSkill); // async var added = await query.GetSkills(3); // async var addedGoodRequest = Assert.IsType <Skills>(added.Value); Assert.Equal(newSkill.Name, added.Value.Name); Assert.Equal(newSkill, added.Value); Assert.Equal(newSkill, addedGoodRequest); //Assert.Equal(newSkill, result); // No Content returned so can't check it without changing return value }
public void Benchmark_FetchSkill(BenchmarkContext context) { _skillFetchCounter = context.GetCounter("SkillFetchCounter"); var postResponse = _skillController.GetSkills(); _skillFetchCounter.Increment(); }
public async void GetSkills_Returns_OK() { var query = new SkillsController(context); var result = await query.GetSkills(2); // async Assert.IsType <ActionResult <Skills> >(result); }
public async void GetSkills_Get_Id_2() { var query = new SkillsController(context); var result = await query.GetSkills(2); // async Assert.Equal("Javascript", result.Value.Name); }
public async void GetAllSkills_Returns_OK() { var query = new SkillsController(context); string sort = "name"; bool asc = true; var result = await query.GetSkills(sort, asc); // async Assert.IsType <ActionResult <IEnumerable <Skills> > >(result); }
public async void GetAllSkills_Check_Order() { var query = new SkillsController(context); string sort = "name"; bool asc = true; var result = await query.GetSkills(sort, asc); // async Assert.Equal("Angular", result.Value.First().Name); Assert.Equal("Javascript", result.Value.Last().Name); }
public async void Check_All_Received() { var query = new SkillsController(context); string sort = "name"; bool asc = true; var result = await query.GetSkills(sort, asc); // async Assert.Equal(5, result.Value.ToList().Count); Assert.Equal(5, result.Value.Count()); }
public async void PostSkills_Add() { var query = new SkillsController(context); var newSkill = new Skills { Id = 6, Name = "React", Type = 2 }; var result = await query.PostSkills(newSkill); // async var added = await query.GetSkills(6); // async var resultGoodRequest = Assert.IsType <CreatedAtActionResult>(result.Result); var addedGoodRequest = Assert.IsType <Skills>(added.Value); Assert.Equal(newSkill, added.Value); Assert.Equal(newSkill, resultGoodRequest.Value); Assert.Equal(newSkill, addedGoodRequest); }
public void GetSkillsTest() { var skillsList = skillsController.GetSkills(); Assert.IsNotNull(skillsList); }