Beispiel #1
0
        public void GetAllInsolvenciesRecords_WhenTheCradleThrowsAnException_BubblesUpTheException()
        {
            mockDataAccessCradle
            .Setup(cradle =>
                   cradle.GetPagedDataSetAsync(
                       It.IsAny <Func <Task <IEnumerable <InsolvencyOrderModel> > > >(),
                       It.IsAny <Func <Task <int> > >()))
            .Throws <Exception>();

            var controller =
                new InsolvencyOrdersController(
                    mockDataAccessCradle.Object,
                    mockInsolvencyOrdersRepository.Object,
                    mockInsolvencyOrdersFlattenedRepository.Object,
                    mockIncludeReader.Object,
                    mockPageInformationReader.Object,
                    mockInsolvenciesHalFormatter.Object,
                    mockInsolvenciesHalCollectionFormatter.Object,
                    mockTelemetryClient.Object);

            // Act
            void Result() => controller.GetAllInsolvencyOrders().GetAwaiter().GetResult();

            // Assert
            Assert.ThrowsException <Exception>((Action)Result);
        }
Beispiel #2
0
        public void GetAllInsolvencyRecords_WhereThereAreNoneToReturn_ReturnsOkStatusCode200()
        {
            // Arrange
            const int expectedStatusCode = 200;

            var collectionResourceInfo = new CollectionResourceInfo(0, 10, 1);
            var collectionResource     =
                new CollectionResource <InsolvencyOrderModel>(collectionResourceInfo, new List <InsolvencyOrderModel>());

            mockDataAccessCradle
            .Setup(cradle =>
                   cradle.GetPagedDataSetAsync(
                       It.IsAny <Func <Task <IEnumerable <InsolvencyOrderModel> > > >(),
                       It.IsAny <Func <Task <int> > >()))
            .Returns(Task.FromResult(collectionResource));

            var controller =
                new InsolvencyOrdersController(
                    mockDataAccessCradle.Object,
                    mockInsolvencyOrdersRepository.Object,
                    mockInsolvencyOrdersFlattenedRepository.Object,
                    mockIncludeReader.Object,
                    mockPageInformationReader.Object,
                    mockInsolvenciesHalFormatter.Object,
                    mockInsolvenciesHalCollectionFormatter.Object,
                    mockTelemetryClient.Object);

            // Act
            var result = controller.GetAllInsolvencyOrders().GetAwaiter().GetResult();

            // Assert
            Assert.IsInstanceOfType(result, typeof(OkObjectResult));
            Assert.AreEqual(expectedStatusCode, ((OkObjectResult)result).StatusCode);
        }
Beispiel #3
0
        public void GetAllInsolvencyRecords_WhenThereIsAProblemGettingThePageInformation_BubblesUpTheException()
        {
            mockPageInformationReader
            .Setup(pageInformationReader => pageInformationReader.GetPageInformation())
            .Throws <Exception>();

            var controller =
                new InsolvencyOrdersController(
                    mockDataAccessCradle.Object,
                    mockInsolvencyOrdersRepository.Object,
                    mockInsolvencyOrdersFlattenedRepository.Object,
                    mockIncludeReader.Object,
                    mockPageInformationReader.Object,
                    mockInsolvenciesHalFormatter.Object,
                    mockInsolvenciesHalCollectionFormatter.Object,
                    mockTelemetryClient.Object);

            // Act
            void Result() => controller.GetAllInsolvencyOrders().GetAwaiter().GetResult();

            // Assert
            Assert.ThrowsException <Exception>((Action)Result);
        }