private async void ConfirmResource_CatchBlock_UpdateUtilizationUserErr_ReturnsSqlException()
        {
            var errMessage   = "Internal Server Error";
            var sqlException = new SqlExceptionBuilder().WithErrorNumber(50000).WithErrorMessage(errMessage).Build();
            var position     = new Position {
                Id                    = 1,
                DisciplineId          = 1,
                ProjectId             = 1,
                ProjectedMonthlyHours = null,
                ResourceId            = "1",
                PositionName          = "",
                IsConfirmed           = false
            };

            Setup_PositionsRepo_GetAPosition_Default(position);
            Setup_PositionsRepo_UpdateAPosition_Default(position);
            Setup_PositionsRepo_GetAllPositionsOfUser_Default(Enumerable.Empty <Position>().Append(new Position()));
            Setup_OutOfOfficeRepo_GetAllOutOfOfficeForUser_Default(Enumerable.Empty <OutOfOffice>().Append(new OutOfOffice()));
            Setup_UtilizationRepo_CalculateUtilizationOfUser_Default(1);
            Setup_UsersRepo_UpdateUtilizationOfUser_ThrowsException(sqlException);

            var result = (await _controller.ConfirmResource(1)) as ObjectResult;

            Assert.Equal(StatusCodes.Status500InternalServerError, result.StatusCode);
            var response = result.Value as InternalServerException;

            Assert.Equal(errMessage, response.status);
        }
Esempio n. 2
0
        public async void GetAllProjects_CatchBlock_SqlException_GetAllProjectResourcesWithTitle()
        {
            string searchWord   = "title";
            string errMessage   = "Internal Server Error";
            var    sqlException = new SqlExceptionBuilder().WithErrorNumber(50000).WithErrorMessage(errMessage).Build();

            Setup_ProjectsRepo_GetAllProjectResourcesWithTitle_ThrowsException(sqlException);
            await GetAllProjects_CatchBlock_SqlException(searchWord, errMessage);
        }
Esempio n. 3
0
        public async void DeleteAProvince_CatchBlock_ReturnSqlException()
        {
            string errMessage   = "Internal Server Error";
            var    sqlException = new SqlExceptionBuilder().WithErrorNumber(50000).WithErrorMessage(errMessage).Build();

            Setup_LocationsRepo_DeleteAProvince_ThrowsException(sqlException);

            var result = (await _controller.DeleteAProvince("test")) as ObjectResult;

            Assert.Equal(StatusCodes.Status500InternalServerError, result.StatusCode);
            var response = result.Value as InternalServerException;

            Assert.Equal(errMessage, response.status);
        }
Esempio n. 4
0
        public async void GetAllUsers_CatchBlock_ReturnSqlException()
        {
            string errMessage   = "Internal Server Error";
            var    sqlException = new SqlExceptionBuilder().WithErrorNumber(50000).WithErrorMessage(errMessage).Build();

            Setup_UsersRepo_GetAllUserResources_ThrowsException(sqlException);

            var result = (await _controller.GetAllUsers(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <int>())) as ObjectResult;

            Assert.Equal(StatusCodes.Status500InternalServerError, result.StatusCode);
            var response = result.Value as InternalServerException;

            Assert.Equal(errMessage, response.status);
        }
        private async void AssignAResource_CatchBlock_UpdatePositionErr_ReturnSqlException()
        {
            string errMessage   = "Internal Server Error";
            var    sqlException = new SqlExceptionBuilder().WithErrorNumber(50000).WithErrorMessage(errMessage).Build();

            Setup_PositionsRepo_GetAPosition_Default(new Position());
            Setup_UsersRepo_GetAUser_Default(new User());
            Setup_PositionsRepo_UpdateAPosition_ThrowsException(sqlException);

            var result = (await _controller.AssignAResource(1, "1")) as ObjectResult;

            Assert.Equal(StatusCodes.Status500InternalServerError, result.StatusCode);
            var response = result.Value as InternalServerException;

            Assert.Equal(errMessage, response.status);
        }
Esempio n. 6
0
        public async void CreateADiscipline_CatchBlock_ReturnSqlException()
        {
            string errMessage   = "Internal Server Error";
            var    sqlException = new SqlExceptionBuilder().WithErrorNumber(50000).WithErrorMessage(errMessage).Build();

            Setup_DisciplinesRepo_CreateADiscipline_ThrowsException(sqlException);

            var discipline = new DisciplineResource
            {
                Name = "A Discipline Name"
            };
            var result = (await _controller.CreateADiscipline(discipline)) as ObjectResult;

            Assert.Equal(StatusCodes.Status500InternalServerError, result.StatusCode);
            var response = result.Value as InternalServerException;

            Assert.Equal(errMessage, response.status);
        }
Esempio n. 7
0
        public async void CreateALocation_CatchBlock_ReturnsSqlException()
        {
            string errMessage   = "Internal Server Error";
            var    sqlException = new SqlExceptionBuilder().WithErrorNumber(50000).WithErrorMessage(errMessage).Build();

            Setup_LocationsRepo_CreateALocation_ThrowsException(sqlException);

            var location = new LocationResource
            {
                Province = "A Province",
                City     = "A City"
            };
            var result = (await _controller.CreateALocation(location)) as ObjectResult;

            Assert.Equal(StatusCodes.Status500InternalServerError, result.StatusCode);
            var response = result.Value as InternalServerException;

            Assert.Equal(errMessage, response.status);
        }
Esempio n. 8
0
        public async void UpdateUser_CatchBlock_ReturnInternalServerException()
        {
            var errMessage   = "Internal Server Error";
            var sqlException = new SqlExceptionBuilder().WithErrorNumber(50000).WithErrorMessage(errMessage).Build();

            Setup_AllRepo_UpdateUser(It.IsAny <ResourceDiscipline>(), Enumerable.Empty <ResourceDiscipline>(),
                                     new OutOfOffice(), Enumerable.Empty <OutOfOffice>(), new ResourceSkill(), Enumerable.Empty <ResourceSkill>());
            Setup_LocationsRepo_GetALocation_Default(new Location());
            Setup_UsersRepo_UpdateAUser_ThrowsException(sqlException);

            var location = new LocationResource {
                LocationID = 1,
                City       = "city",
                Province   = "province"
            };
            var summary = new UserSummary {
                UserID             = "NoneEmpty",
                Location           = location,
                FirstName          = "first",
                LastName           = "last",
                Utilization        = 0,
                ResourceDiscipline = null,
                IsConfirmed        = false
            };
            var user = new UserProfile {
                UserSummary     = summary,
                CurrentProjects = Enumerable.Empty <ProjectSummary>(),
                Availability    = Enumerable.Empty <OutOfOfficeResource>(),
                Disciplines     = Enumerable.Empty <ResourceDisciplineResource>(),
                Positions       = Enumerable.Empty <PositionSummary>()
            };

            var result = (await _controller.UpdateUser(user, "NoneEmpty")) as ObjectResult;

            Assert.Equal(StatusCodes.Status500InternalServerError, result.StatusCode);
            var response = result.Value as InternalServerException;

            Assert.Equal(errMessage, response.status);
        }
Esempio n. 9
0
        public async void CreateAProject_CatchBlockProjectErr_ReturnsSqlException()
        {
            var errMessage   = "Internal Server Error";
            var sqlException = new SqlExceptionBuilder().WithErrorNumber(50000).WithErrorMessage(errMessage).Build();

            Setup_LocationsRepo_GetALocation_Default(new Location());
            Setup_ProjectsRepo_CreateAProject_ThrowsException(sqlException);
            var location = new LocationResource {
                LocationID = 1,
                Province   = "",
                City       = ""
            };
            var summary = new ProjectSummary {
                Title            = "",
                Location         = location,
                ProjectStartDate = new System.DateTime(),
                ProjectEndDate   = new System.DateTime(),
                ProjectNumber    = "test"
            };
            var manager = new ProjectManager {
                UserID    = "1",
                FirstName = "",
                LastName  = ""
            };
            var profile = new ProjectProfile {
                ProjectSummary = summary,
                ProjectManager = manager,
                UsersSummary   = Enumerable.Empty <UserSummary>(),
                Openings       = Enumerable.Empty <OpeningPositionsSummary>()
            };

            var result = (await _controller.CreateAProject(profile)) as ObjectResult;

            Assert.Equal(StatusCodes.Status500InternalServerError, result.StatusCode);
            var response = result.Value as InternalServerException;

            Assert.Equal(errMessage, response.status);
        }