Esempio n. 1
0
        public async void TestGetProjectsWithUserId()
        {
            var options = new DbContextOptionsBuilder <Databasecontext
                                                       >().UseInMemoryDatabase(databaseName: "Test7")
                          .Options;

            using (var context = new Databasecontext(options))
            {
                var project = new Project("user", DateTime.Now, DateTime.Now, 1.00, "test", "test")
                {
                    ProjectId      = 3,
                    UserId         = "1",
                    StartDate      = DateTime.Now,
                    EndDate        = DateTime.Now,
                    PaymentOffered = 1.00,
                    ProjectName    = "test",
                    Description    = "test"
                };


                context.Add(project);

                context.SaveChanges();

                ProjectsController projectController = new ProjectsController(context);
                var actionresult = await projectController.GetProjectByUser("1");

                var            result  = (OkObjectResult)actionresult.Result;
                List <Project> result2 = (List <Project>)result.Value;
                Assert.Equal(3, result2.Last().ProjectId);
            }
        }
Esempio n. 2
0
        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);
            }
        }
Esempio n. 3
0
        public async void TestGetLatestProjectsWithUserId()
        {
            var options = new DbContextOptionsBuilder <Databasecontext
                                                       >().UseInMemoryDatabase(databaseName: "Test3")
                          .Options;

            using (var context = new Databasecontext(options))
            {
                var project = new Project("user", DateTime.Now, DateTime.Now, 1.00, "test", "test")
                {
                    ProjectId      = 3,
                    UserId         = "1",
                    StartDate      = DateTime.Now,
                    EndDate        = DateTime.Now,
                    PaymentOffered = 1.00,
                    ProjectName    = "test",
                    Description    = "test"
                };
                var project2 = new Project("user", DateTime.Now, DateTime.Now, 1.00, "test", "test")
                {
                    ProjectId      = 4,
                    UserId         = "2",
                    StartDate      = DateTime.Now,
                    EndDate        = DateTime.Now,
                    PaymentOffered = 1.00,
                    ProjectName    = "test",
                    Description    = "test"
                };

                context.Add(project);
                context.Add(project2);
                context.SaveChanges();

                ProjectsController projectController = new ProjectsController(context);
                var actionresult = await projectController.GetLatestProjectByUser("2");

                var     result  = (OkObjectResult)actionresult.Result;
                Project result2 = (Project)result.Value;
                //       ActionResult okObjectResult = Assert.IsAssignableFrom<ActionResult>(actionresult);
                //       Project result = Assert.IsType<Project>(okObjectResult.);
                Assert.Equal(4, result2.ProjectId);
            }
        }
Esempio n. 4
0
        public async void TestDeleteNeedsSkill()
        {
            var options = new DbContextOptionsBuilder <Databasecontext
                                                       >().UseInMemoryDatabase(databaseName: "Test3")
                          .Options;

            using (var context = new Databasecontext(options))
            {
                var needskills = new PositionNeedsSkill(1, 1);

                PositionNeedsSkillsController posskill = new PositionNeedsSkillsController(context);
                context.Add(needskills);
                context.SaveChanges();
                await posskill.DeletePositionNeedsSkill(1);

                var result = context.PositionNeedsSkills.Find(1);
                Assert.Null(result);
            }
        }
Esempio n. 5
0
        public async void TestDeleteRequests()
        {
            var options = new DbContextOptionsBuilder <Databasecontext
                                                       >().UseInMemoryDatabase(databaseName: "Test7")
                          .Options;

            using (var context = new Databasecontext(options))
            {
                var hireRequest = new HireRequest(1, "1", "1");

                HireRequestsController HireRequests = new HireRequestsController(context);
                context.Add(hireRequest);
                context.SaveChanges();
                await HireRequests.DeleteHireRequest(1);

                var result = context.HireRequests.Find(1);
                Assert.Null(result);
            }
        }
Esempio n. 6
0
        public async void TestDeleteContractor()
        {
            var options = new DbContextOptionsBuilder <Databasecontext
                                                       >().UseInMemoryDatabase(databaseName: "Test4")
                          .Options;

            using (var context = new Databasecontext(options))
            {
                var contractor = new Contractor("test1", "test2", "test3", "test4", "test5");

                ContractorsController ContractorPositions = new ContractorsController(context);
                context.Add(contractor);
                context.SaveChanges();
                await ContractorPositions.DeleteContractor(1);

                var result = context.Contractors.Find(1);
                Assert.Null(result);
            }
        }
Esempio n. 7
0
        public async void TestReturnContractorId()
        {
            var options = new DbContextOptionsBuilder <Databasecontext
                                                       >().UseInMemoryDatabase(databaseName: "Test2")
                          .Options;

            using (var context = new Databasecontext(options))
            {
                var contractor = new Contractor("test1", "test2", "test3", "test4", "test5");
                context.Add(contractor);
                context.SaveChanges();
                ContractorsController ContractorPositions = new ContractorsController(context);

                var contractors = await ContractorPositions.GetContractor(1);

                Contractor result = contractors.Value;
                Assert.Equal("test1", result.Username);
            }
        }
Esempio n. 8
0
        public async void TestReturnProjectPositions()
        {
            var options = new DbContextOptionsBuilder <Databasecontext
                                                       >().UseInMemoryDatabase(databaseName: "Test2")
                          .Options;

            using (var context = new Databasecontext(options))
            {
                var projectPositions = new ProjectPositions();
                context.Add(projectPositions);
                context.SaveChanges();
                ProjectPositionsController ProjectPositions = new ProjectPositionsController(context);

                var projectpos = await ProjectPositions.GetProjectPositions();

                IEnumerable <ProjectPositions> result = projectpos.Value;
                Assert.Single(result);
            }
        }
Esempio n. 9
0
        public async void TestReturnProjectPositionsWithId()
        {
            var options = new DbContextOptionsBuilder <Databasecontext
                                                       >().UseInMemoryDatabase(databaseName: "Test")
                          .Options;

            using (var context = new Databasecontext(options))
            {
                var projectPositions = new ProjectPositions();
                context.Add(projectPositions);
                context.SaveChanges();
                ProjectPositionsController ProjectPositions = new ProjectPositionsController(context);

                var project = await ProjectPositions.GetProjectPositions(1);

                ProjectPositions result = project.Value;
                Assert.Equal(1, result.ProjectPositionsId);
            }
        }
Esempio n. 10
0
        public async void TestNeedSkill()
        {
            var options = new DbContextOptionsBuilder <Databasecontext
                                                       >().UseInMemoryDatabase(databaseName: "Test1")
                          .Options;

            using (var context = new Databasecontext(options))
            {
                var needskills = new PositionNeedsSkill(1, 1);

                PositionNeedsSkillsController posskill = new PositionNeedsSkillsController(context);
                context.Add(needskills);
                context.SaveChanges();
                var result = await posskill.GetPositionNeedsSkill(1);

                PositionNeedsSkill results = result.Value;
                Assert.Equal(1, results.PositionId);
                Assert.IsType <PositionNeedsSkill>(results);
            }
        }
Esempio n. 11
0
        public async void TestContractorRequests()
        {
            var options = new DbContextOptionsBuilder <Databasecontext
                                                       >().UseInMemoryDatabase(databaseName: "Test5")
                          .Options;

            using (var context = new Databasecontext(options))
            {
                var hireRequest = new HireRequest(1, "1", "1");

                HireRequestsController HireRequests = new HireRequestsController(context);
                context.Add(hireRequest);
                context.SaveChanges();

                var actionresult = await HireRequests.GetContractorRequest("1");

                var result = (OkObjectResult)actionresult.Result;
                List <HireRequest> result2 = (List <HireRequest>)result.Value;
                Assert.Equal("1", result2.Last().ContractorId);
            }
        }
Esempio n. 12
0
        public async void TestHireRequestsid()
        {
            var options = new DbContextOptionsBuilder <Databasecontext
                                                       >().UseInMemoryDatabase(databaseName: "Test2")
                          .Options;

            using (var context = new Databasecontext(options))
            {
                var hireRequest = new HireRequest(1, "1", "1");

                HireRequestsController HireRequests = new HireRequestsController(context);
                context.Add(hireRequest);
                context.SaveChanges();

                var hire = await HireRequests.GetHireRequest(1);

                HireRequest result = hire.Value;

                Assert.Equal("1", result.ClientId);
            }
        }
Esempio n. 13
0
        public async void DeleteProjectPositions()
        {
            var options = new DbContextOptionsBuilder <Databasecontext
                                                       >().UseInMemoryDatabase(databaseName: "Test4")
                          .Options;

            using (var context = new Databasecontext(options))
            {
                var projectPositions = new ProjectPositions()
                {
                    ProjectId = 1
                };
                ProjectPositionsController ProjectPositions = new ProjectPositionsController(context);

                context.Add(projectPositions);
                await ProjectPositions.DeleteProjectPositions(1);

                var result = context.ProjectPositions.Find(1);
                Assert.Null(result);
            }
        }
Esempio n. 14
0
        public async void TestGetProjectPositionsByProjectId()
        {
            var options = new DbContextOptionsBuilder <Databasecontext
                                                       >().UseInMemoryDatabase(databaseName: "Test3")
                          .Options;

            using (var context = new Databasecontext(options))
            {
                var projectPositions = new ProjectPositions()
                {
                    ProjectId = 1
                };
                context.Add(projectPositions);
                context.SaveChanges();
                ProjectPositionsController ProjectPositions = new ProjectPositionsController(context);

                var actionresult = await ProjectPositions.GetPositionsByProjectId(1);

                var result = (OkObjectResult)actionresult.Result;
                List <ProjectPositions> result2 = (List <ProjectPositions>)result.Value;
                Assert.Equal(1, result2.Last().ProjectId);
            }
        }