Пример #1
0
        public async Task GetLatestJobs_NullPage_ThrowsBadRequest()
        {
            // Arrange
            const int userId  = 1;
            var       session = new Session {
                UserName = "******", UserId = userId
            };
            var token = Guid.NewGuid().ToString();
            var jobsRepositoryMock       = new Mock <IJobsRepository>();
            var serviceLogRepositoryMock = new Mock <IServiceLogRepository>();
            var controller = new JobsController(jobsRepositoryMock.Object, serviceLogRepositoryMock.Object)
            {
                Request = new HttpRequestMessage()
            };

            controller.Request.Headers.Add("Session-Token", token);
            controller.Request.Properties[ServiceConstants.SessionProperty] = session;

            // Act
            try
            {
                await controller.GetLatestJobs();
            }
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(BadRequestException));
                Assert.AreEqual(((ExceptionWithErrorCode)ex).ErrorCode, ErrorCodes.PageNullOrNegative);
                throw;
            }
        }
Пример #2
0
        public async Task GetLatestJobs_UnauthenticatedUser_ThrowsAuthenticationException()
        {
            // Arrange
            var jobsRepositoryMock       = new Mock <IJobsRepository>();
            var serviceLogRepositoryMock = new Mock <IServiceLogRepository>();
            var controller = new JobsController(jobsRepositoryMock.Object, serviceLogRepositoryMock.Object)
            {
                Request = new HttpRequestMessage()
            };

            // Act
            await controller.GetLatestJobs();
        }