示例#1
0
        public void GetPersonsByPersonId_WhenThereIsAProblemFormattingTheResponseAsHal_BubblesUpTheException()
        {
            // Arrange
            const int recordId = 1;

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

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

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

            // Assert
            Assert.ThrowsException <Exception>((Action)Result);
        }
示例#2
0
        public void GetPersonsByPersonId_WhenThereIsARecord_ReturnsStatusCode200()
        {
            // Arrange
            const int expectedStatusCode = 200;
            const int recordId           = 1;

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

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

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

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