Exemplo n.º 1
0
        public void GettingTradingDetailsByInsolvencyOrderId_WhenTheCradleThrowsAnException_BubblesUpTheException()
        {
            // Arrange
            const int insolvencyOrderId = 1237654;

            mockDataAccessCradle
            .Setup(cradle =>
                   cradle.GetPagedDataSetAsync(
                       It.IsAny <Func <Task <IEnumerable <InsolvencyOrderHistoryModel> > > >(),
                       It.IsAny <Func <Task <int> > >()))
            .Throws <Exception>();

            var controller = new InsolvencyOrderHistoriesController(
                mockDataAccessCradle.Object,
                mockHistoriesRepository.Object,
                mockIncludeReader.Object,
                mockPageInformationProvider.Object,
                mockHalFormatter.Object,
                mockHalCollectionFormatter.Object,
                mockTelemetryClient.Object);

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

            // Assert
            Assert.ThrowsException <Exception>((Action)Result);
        }
Exemplo n.º 2
0
        public void GettingTradingDetailsByInsolvencyOrderId_WhenThereIsAProblemFormattingTheResponseAsHal_BubblesUpTheException()
        {
            // Arrange
            const int insolvencyOrderId = 9876543;

            mockHalCollectionFormatter
            .Setup(insolvencyCollectionFormatter =>
                   insolvencyCollectionFormatter.FormatForHal(It.IsAny <CollectionResource <InsolvencyOrderHistoryModel> >()))
            .Throws <Exception>();

            var controller =
                new InsolvencyOrderHistoriesController(
                    mockDataAccessCradle.Object,
                    mockHistoriesRepository.Object,
                    mockIncludeReader.Object,
                    mockPageInformationProvider.Object,
                    mockHalFormatter.Object,
                    mockHalCollectionFormatter.Object,
                    mockTelemetryClient.Object);

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

            // Assert
            Assert.ThrowsException <Exception>((Action)Result);
        }
Exemplo n.º 3
0
        public void GettingTradingDetailsByInsolvencyOrderId_WhenThereAreNoneToReturn_ReturnsOkStatusCode200()
        {
            // Arrange
            const int insolvencyOrderId  = 7654321;
            const int expectedStatusCode = 200;

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

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

            var controller =
                new InsolvencyOrderHistoriesController(
                    mockDataAccessCradle.Object,
                    mockHistoriesRepository.Object,
                    mockIncludeReader.Object,
                    mockPageInformationProvider.Object,
                    mockHalFormatter.Object,
                    mockHalCollectionFormatter.Object,
                    mockTelemetryClient.Object);

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

            // Assert
            Assert.IsInstanceOfType(result, typeof(OkObjectResult));
            Assert.AreEqual(expectedStatusCode, ((OkObjectResult)result).StatusCode);
        }