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); }
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); }
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); }
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); }
public void GettingInsolvencyOrderEntitysByResidenceId_WhenThereIsAProblemGettingThePageInformation_BubblesUpTheException() { // Arrange const int residenceId = 1234567; 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.GetInsolvencyOrdersByResidenceId(residenceId).GetAwaiter().GetResult(); // Assert Assert.ThrowsException <Exception>((Action)Result); }
public void GetAllInsolvenciesRecords_WhenThereIsAProblemGettingTheIncludes_BubblesUpTheException() { mockIncludeReader .Setup(includeReader => includeReader.GetIncludes()) .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); }