Ejemplo n.º 1
0
        public async Task GetTLevelDetailsReturnsFailedOnServiceErrors(string errorMesage, HttpStatusCode expectedHttpStatusCode)
        {
            //Set Up
            A.CallTo(() => FakeFindACoursesService.GetTLevelDetails(A <string> .Ignored, A <string> .Ignored)).Throws(new SystemException(errorMesage));

            using var controller = BuildDetailsController("*/*");
            var paramValues = new ParamValues();

            //Act
            var result = await controller.TLevelDetails(CourseId, TLevelLocationId, "testSearchTerm", paramValues).ConfigureAwait(false);

            //Asserts
            var resultStatus = result as StatusCodeResult;

            resultStatus.StatusCode.Should().Be((int)expectedHttpStatusCode);
            A.CallTo(() => FakeLogService.LogError(A <string> .Ignored)).MustHaveHappenedOnceExactly();
        }
        public async Task GetCourseDetailsReturnsFailedOnServiceErrors()
        {
            //Set Up
            A.CallTo(() => FakeFindACoursesService.GetCourseDetails(A <string> .Ignored, A <string> .Ignored)).Throws(new SystemException());

            var controller  = BuildDetailsController("*/*");
            var paramValues = new ParamValues();

            //Act
            var result = await controller.Details(CourseId, RunId, null, "testSearchTerm", paramValues).ConfigureAwait(false);

            //Asserts
            var resultStatus = result as StatusCodeResult;

            resultStatus.StatusCode.Should().Be((int)HttpStatusCode.FailedDependency);
            A.CallTo(() => FakeLogService.LogError(A <string> .Ignored)).MustHaveHappenedOnceExactly();

            controller.Dispose();
        }