public void GetAddressesByAddressId_WhenThereIsAProblemFormattingTheResponseAsHal_BubblesUpTheException() { // Arrange const int recordId = 1; mockHalFormatter .Setup(insolvencyFormatter => insolvencyFormatter.FormatForHal(It.IsAny <InsolvencyOrderAddressModel>())) .Throws <Exception>(); // Act var insolvencyOrdersController = new InsolvencyOrderAddressesController( mockDataAccessCradle.Object, mockAddressesRepository.Object, mockIncludeReader.Object, mockPageInformationProvider.Object, mockHalFormatter.Object, mockHalCollectionFormatter.Object, mockTelemetryClient.Object); // Act void Result() => insolvencyOrdersController.GetAddressesByAddressId(recordId).GetAwaiter().GetResult(); // Assert Assert.ThrowsException <Exception>((Action)Result); }
public void GettingAddressesDetailsByInsolvencyOrderId_WhenTheCradleThrowsAnException_BubblesUpTheException() { // Arrange const int insolvencyOrderId = 1237654; mockDataAccessCradle .Setup(cradle => cradle.GetPagedDataSetAsync( It.IsAny <Func <Task <IEnumerable <InsolvencyOrderAddressModel> > > >(), It.IsAny <Func <Task <int> > >())) .Throws <Exception>(); var controller = new InsolvencyOrderAddressesController( mockDataAccessCradle.Object, mockAddressesRepository.Object, mockIncludeReader.Object, mockPageInformationProvider.Object, mockHalFormatter.Object, mockHalCollectionFormatter.Object, mockTelemetryClient.Object); // Act void Result() => controller.GetAddressesByInsolvencyIdAsync(insolvencyOrderId).GetAwaiter().GetResult(); // Assert Assert.ThrowsException <Exception>((Action)Result); }
public void GetAddressesByAddressId_WhenThereIsARecord_ReturnsStatusCode200() { // Arrange const int expectedStatusCode = 200; const int recordId = 1; mockDataAccessCradle .Setup(insolvencyOrdersCradle => insolvencyOrdersCradle.GetItemAsync(It.IsAny <Func <Task <InsolvencyOrderAddressModel> > >())) .Returns(Task.FromResult(new InsolvencyOrderAddressModel())); // Act var insolvencyOrdersController = new InsolvencyOrderAddressesController( mockDataAccessCradle.Object, mockAddressesRepository.Object, mockIncludeReader.Object, mockPageInformationProvider.Object, mockHalFormatter.Object, mockHalCollectionFormatter.Object, mockTelemetryClient.Object); // Act var result = insolvencyOrdersController.GetAddressesByAddressId(recordId).GetAwaiter().GetResult(); // Assert Assert.IsInstanceOfType(result, typeof(OkObjectResult)); Assert.AreEqual(expectedStatusCode, ((OkObjectResult)result).StatusCode); }
public void GettingAddressesDetailsByInsolvencyOrderId_WhenThereAreNoneToReturn_ReturnsOkStatusCode200() { // Arrange const int insolvencyOrderId = 7654321; const int expectedStatusCode = 200; var collectionResourceInfo = new CollectionResourceInfo(0, 10, 1); var collectionResource = new CollectionResource <InsolvencyOrderAddressModel>(collectionResourceInfo, new List <InsolvencyOrderAddressModel>()); mockDataAccessCradle .Setup(cradle => cradle.GetPagedDataSetAsync( It.IsAny <Func <Task <IEnumerable <InsolvencyOrderAddressModel> > > >(), It.IsAny <Func <Task <int> > >())) .Returns(Task.FromResult(collectionResource)); var controller = new InsolvencyOrderAddressesController( mockDataAccessCradle.Object, mockAddressesRepository.Object, mockIncludeReader.Object, mockPageInformationProvider.Object, mockHalFormatter.Object, mockHalCollectionFormatter.Object, mockTelemetryClient.Object); // Act var result = controller.GetAddressesByInsolvencyIdAsync(insolvencyOrderId).GetAwaiter().GetResult(); // Assert Assert.IsInstanceOfType(result, typeof(OkObjectResult)); Assert.AreEqual(expectedStatusCode, ((OkObjectResult)result).StatusCode); }