Example #1
0
        public void EditPostLoggedUserTest()
        {
            ModelsMocks.CleanUpBeforeTest();
            ModelsMocks.AddTestProject(true);
            ModelsMocks.AddTestTask(true, ModelsMocks.ProjectModelFirst);
            ModelsMocks.AddTestWorklog(true, ModelsMocks.TaskModelFirst);

            // Arrange
            WorklogController controller = ControllersMocks.GetControllerAsLoggedUser <WorklogController>();

            // Act
            JsonResult action = controller.Edit(ModelsMocks.WorklogModelSecond, ModelsMocks.ProjectModelFirst.ID,
                                                ModelsMocks.TaskModelFirst.ID, ModelsMocks.WorklogModelFirst.ID) as JsonResult;

            using (IUnityContainer container = UnityConfig.GetConfiguredContainer())
            {
                var repo    = container.Resolve <IWorklogRepository>();
                var worklog = repo.GetWorklogByIdWithoutTracking(ModelsMocks.WorklogModelFirst.ID);
                if (worklog.Hours != 115)
                {
                    Assert.Fail();
                }
                Assert.IsNotNull(worklog);
            }
        }
Example #2
0
        public void DeletePostLoggedUserTest()
        {
            ModelsMocks.CleanUpBeforeTest();
            ModelsMocks.AddTestProject(true);
            ModelsMocks.AddTestTask(true, ModelsMocks.ProjectModelFirst);
            ModelsMocks.AddTestWorklog(true, ModelsMocks.TaskModelFirst);

            // Arrange
            WorklogController controller = ControllersMocks.GetControllerAsLoggedUser <WorklogController>();

            // Act
            JsonResult action = controller.Delete(ModelsMocks.WorklogModelSecond, ModelsMocks.ProjectModelFirst.ID,
                                                  ModelsMocks.TaskModelFirst.ID, ModelsMocks.WorklogModelFirst.ID) as JsonResult;

            using (IUnityContainer container = UnityConfig.GetConfiguredContainer())
            {
                var repo = container.Resolve <IWorklogRepository>();
                try {
                    var worklog = repo.GetWorklogByIdWithoutTracking(ModelsMocks.WorklogModelFirst.ID);
                    Assert.Fail();
                }
                #pragma warning disable CS0168 // Variable is declared but never used
                catch (Exception ex)
                #pragma warning restore CS0168 // Variable is declared but never used
                {
                    //Passed
                }
            }
        }
Example #3
0
        public void DetailsLoggedUserTest()
        {
            ModelsMocks.CleanUpBeforeTest();
            ModelsMocks.AddTestProject(true);
            ModelsMocks.AddTestTask(true, ModelsMocks.ProjectModelFirst);
            ModelsMocks.AddTestWorklog(true, ModelsMocks.TaskModelFirst);

            // Arrange
            WorklogController controller = ControllersMocks.GetControllerAsLoggedUser <WorklogController>();

            // Act
            JsonResult action = controller.Details(ModelsMocks.ProjectModelFirst.ID,
                                                   ModelsMocks.TaskModelFirst.ID, ModelsMocks.WorklogModelFirst.ID) as JsonResult;
            var worklog = (TaskVlopper.Models.WorklogViewModel)action.Data;

            Assert.IsNotNull(worklog);
        }
Example #4
0
        public void EditGetLoggedUserTest()
        {
            ModelsMocks.CleanUpBeforeTest();
            ModelsMocks.AddTestProject(true);
            ModelsMocks.AddTestTask(true, ModelsMocks.ProjectModelFirst);
            ModelsMocks.AddTestWorklog(true, ModelsMocks.TaskModelFirst);

            // Arrange
            WorklogController controller = ControllersMocks.GetControllerAsLoggedUser <WorklogController>();

            // Act
            JsonResult action = controller.Edit(ModelsMocks.WorklogModelSecond, ModelsMocks.ProjectModelFirst.ID,
                                                ModelsMocks.TaskModelFirst.ID, ModelsMocks.WorklogModelFirst.ID) as JsonResult;

            var ok = (TaskVlopper.Models.JsonHttpViewModel)action.Data;

            Assert.AreEqual(202, ok.HttpCode);
        }