Пример #1
0
        public void GetInsolvencyRecordById_WhenThereIsAProblemFormattingTheResponseAsHal_BubblesUpTheException()
        {
            // Arrange
            const int recordId = 1;

            mockInsolvenciesHalFormatter
            .Setup(insolvencyFormatter => insolvencyFormatter.FormatForHal(It.IsAny <InsolvencyOrderModel>()))
            .Throws <Exception>();

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

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

            // Assert
            Assert.ThrowsException <Exception>((Action)Result);
        }
Пример #2
0
        public void GetInsolvencyRecordById_WhenThereIsARecord_ReturnsStatusCode200()
        {
            // Arrange
            const int expectedStatusCode = 200;
            const int recordId           = 1;

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

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

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

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