public async void CanGetCompaniesByID() { DbContextOptions <GitHiredApiDbContext> options = new DbContextOptionsBuilder <GitHiredApiDbContext>() .UseInMemoryDatabase(databaseName: "CanGetCompany").Options; using (GitHiredApiDbContext context = new GitHiredApiDbContext(options)) { // Arrange Company c2 = new Company(); c2.ID = 2; c2.Name = "TestCo"; c2.Website = "www.Testco.com"; c2.Industry = "Testing"; c2.Headline = "tt"; // Act context.Companies.Add(c2); context.SaveChanges(); var _controller = new GetCompanyInfoController(context); var result = await _controller.GetCompany(2); Assert.True(result.Value.ID == 2); } }
public async void cangetSkillsData() { DbContextOptions <GitHiredApiDbContext> options = new DbContextOptionsBuilder <GitHiredApiDbContext>() .UseInMemoryDatabase(databaseName: "CanGetCompany").Options; using (GitHiredApiDbContext context2 = new GitHiredApiDbContext(options)) { //Ararnge Job j1 = new Job(); j1.ID = 1; j1.JobTitle = "Jr Dev"; Skill skill1 = new Skill(); skill1.ID = 1; skill1.SkillName = "aspNetCore"; Skill skill2 = new Skill(); skill2.ID = 2; skill2.SkillName = "c++"; RequiredSkill rs1 = new RequiredSkill(); rs1.Skill = skill1; RequiredSkill rs2 = new RequiredSkill(); rs2.Skill = skill2; context2.Jobs.Add(j1); context2.SaveChanges(); context2.Skills.Add(skill1); context2.SaveChanges(); context2.Skills.Add(skill2); context2.SaveChanges(); context2.RequiredSkills.Add(rs1); context2.SaveChanges(); context2.RequiredSkills.Add(rs2); context2.SaveChanges(); var _controller = new SkillsController(context2); var result = await _controller.SkillsData() as OkObjectResult; Assert.Equal(200, result.StatusCode); } }
public async void CanGetAllCompanies() { DbContextOptions <GitHiredApiDbContext> options = new DbContextOptionsBuilder <GitHiredApiDbContext>() .UseInMemoryDatabase(databaseName: "CanGetCompany").Options; using (GitHiredApiDbContext context1 = new GitHiredApiDbContext(options)) { // Arrange Company c3 = new Company(); c3.ID = 3; c3.Name = "GOGOGO"; c3.Website = "www.GOGOGO.com"; c3.Industry = "Testing"; c3.Headline = "tt"; Company c4 = new Company(); c4.ID = 4; c4.Name = "GOGO"; c4.Website = "www.GOGO.com"; c4.Industry = "Testing"; c4.Headline = "tt"; // Act context1.Companies.Add(c3); context1.SaveChanges(); context1.Companies.Add(c4); context1.SaveChanges(); var _controller = new GetCompanyInfoController(context1); var result = await _controller.GetCompanies() as OkObjectResult; Assert.Equal(200, result.StatusCode); } }
public async void canSearchQuery() { DbContextOptions <GitHiredApiDbContext> options = new DbContextOptionsBuilder <GitHiredApiDbContext>() .UseInMemoryDatabase(databaseName: "Cangetjobs").Options; using (GitHiredApiDbContext context3 = new GitHiredApiDbContext(options)) { //Arrange Company co = new Company(); co.Name = "cocacola"; Job job1 = new Job(); job1.ID = 1; // List<RequiredSkill> list1 = new List<RequiredSkill>(); Skill s1 = new Skill(); s1.SkillName = "Javatest"; Skill s2 = new Skill(); s2.SkillName = "C#test"; RequiredSkill rr1 = new RequiredSkill(); rr1.Skill = s1; RequiredSkill rr2 = new RequiredSkill(); rr2.Skill = s2; // list1.Add(rr1); // list1.Add(rr2); context3.Companies.Add(co); context3.SaveChanges(); context3.Jobs.Add(job1); context3.SaveChanges(); context3.Skills.Add(s1); context3.SaveChanges(); context3.Skills.Add(s2); context3.SaveChanges(); context3.RequiredSkills.Add(rr1); context3.SaveChanges(); context3.RequiredSkills.Add(rr2); context3.SaveChanges(); var _controller = new GetJobsController(context3); var result = await _controller.Search("cocacola") as OkObjectResult; Assert.Equal(200, result.StatusCode); } }