public void GetTradingDetailsByTradingDetailsIdAsync_WhenThereIsAProblemFormattingTheResponseAsHal_BubblesUpTheException()
        {
            // Arrange
            const int recordId = 1;

            mockHalFormatter
            .Setup(insolvencyFormatter => insolvencyFormatter.FormatForHal(It.IsAny <InsolvencyOrderTradingDetailsModel>()))
            .Throws <Exception>();

            // Act
            var insolvencyOrdersController = new InsolvencyOrderTradingDetailsController(
                mockDataAccessCradle.Object,
                mockTradingDetailsRepository.Object,
                mockIncludeReader.Object,
                mockPageInformationProvider.Object,
                mockHalFormatter.Object,
                mockHalCollectionFormatter.Object,
                mockTelemetryClient.Object);

            // Act
            void Result() => insolvencyOrdersController.GetTradingDetailsByTradingDetailsIdAsync(recordId).GetAwaiter().GetResult();

            // Assert
            Assert.ThrowsException <Exception>((Action)Result);
        }
        public void GettingTradingDetailsByInsolvencyOrderId_WhenTheCradleThrowsAnException_BubblesUpTheException()
        {
            // Arrange
            const int insolvencyOrderId = 1237654;

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

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

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

            // Assert
            Assert.ThrowsException <Exception>((Action)Result);
        }
        public void GetTradingDetailsByTradingDetailsIdAsync_WhenThereIsARecord_ReturnsStatusCode200()
        {
            // Arrange
            const int expectedStatusCode = 200;
            const int recordId           = 1;

            mockDataAccessCradle
            .Setup(insolvencyOrdersCradle =>
                   insolvencyOrdersCradle.GetItemAsync(It.IsAny <Func <Task <InsolvencyOrderTradingDetailsModel> > >()))
            .Returns(Task.FromResult(new InsolvencyOrderTradingDetailsModel()));

            // Act
            var insolvencyOrdersController = new InsolvencyOrderTradingDetailsController(
                mockDataAccessCradle.Object,
                mockTradingDetailsRepository.Object,
                mockIncludeReader.Object,
                mockPageInformationProvider.Object,
                mockHalFormatter.Object,
                mockHalCollectionFormatter.Object,
                mockTelemetryClient.Object);

            // Act
            var result = insolvencyOrdersController.GetTradingDetailsByTradingDetailsIdAsync(recordId).GetAwaiter().GetResult();

            // Assert
            Assert.IsInstanceOfType(result, typeof(OkObjectResult));
            Assert.AreEqual(expectedStatusCode, ((OkObjectResult)result).StatusCode);
        }
        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 <InsolvencyOrderTradingDetailsModel>(collectionResourceInfo, new List <InsolvencyOrderTradingDetailsModel>());

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

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

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

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