public void DealsCoverageController_Get_Returns_OKResponseCode(int dealnumber) { #region Arrange SetupUserIdentity(); SetupDealCoveragesRepository(out Mock <IDealCoveragesRepository> dealsCoverageRepository, dealnumber); #endregion #region Act var httpRequest = new HttpRequestMessage(new HttpMethod(AppSettings.HTTPGET), $"{AppSettings.BASEURL}{RouteHelper.DealsCoverageRoutePrefix}/{dealnumber}"); DealCoveragesManager dealCoveragesManager = new DealCoveragesManager(userManager.Object, cacheStoreManager.Object, mockLogManager.Object, dealsCoverageRepository.Object, dealLockManager.Object, transformationManager); GlobalReAPIManager globalReAPIManager = new GlobalReAPIManager(userManager.Object, cacheStoreManager.Object, mockLogManager.Object, new Mock <IDealManager>().Object, new Mock <IDealStatusSummariesManager>().Object, new Mock <IPersonsManager>().Object, dealLockManager.Object, dealCoveragesManager, new Mock <INotesManager>().Object); DealsCoverageController dealsCoverageController = new DealsCoverageController(userManager.Object, globalReAPIManager) { Request = httpRequest, Configuration = new HttpConfiguration() }; var response = dealsCoverageController.Get(dealnumber); #endregion #region Expected Data var expectedDealsCoverage = new DealCoverages() // grs_VGrsDealCoverage() { DealNumber = dealnumber, Cover_Id = 13, Cover_Name = "California Earthquake" }; #endregion #region Assert var contentResult = response as NegotiatedContentResult <ResponseCollection <DealCoverages> >; if (contentResult != null) { Assertions.AssertOkResponse(contentResult); var dealCoveragesData = contentResult.Content.results; for (int i = 0; i <= dealCoveragesData.Count - 1; i++) { var actualDealsCoverage = dealCoveragesData[i].data; Assert.AreEqual(expectedDealsCoverage.DealNumber, actualDealsCoverage.DealNumber); Assert.AreEqual(expectedDealsCoverage.Cover_Id, actualDealsCoverage.Cover_Id); Assert.AreEqual(expectedDealsCoverage.Cover_Name, actualDealsCoverage.Cover_Name); Assert.IsEmpty(dealCoveragesData[i].messages); } } #endregion }
public void DealCoveragesManager_Get_ShouldThrow_IllegalArgumentAPIException(int dealNumber) { //Arrange SetupUserIdentity(); // Arrange dealCoveragesRepository = new Mock <IDealCoveragesRepository>(); //SetupDealCoveragesRepository(dealCoveragesRepository, dealNumber); IList <Data.Models.grs_VGrsDealCoverage> CoveragesDbData = new List <Data.Models.grs_VGrsDealCoverage> { new Data.Models.grs_VGrsDealCoverage { Dealnum = dealNumber, CoverId = 13, CoverName = "California Earthquake" } }; // Get method dealCoveragesRepository.Setup(p => p.GetDealCoverages(dealNumber)).Returns(CoveragesDbData); DealCoveragesManager dealCovergaresManager = new DealCoveragesManager(userManager.Object, cacheStoreManager.Object, mockLogManager.Object, dealCoveragesRepository.Object, new Mock <IEntityLockManager>().Object, transformationManager); //Assert Assert.Throws <IllegalArgumentAPIException>(delegate { dealCovergaresManager.GetDealCoverages(dealNumber); }); }
public void DealCoveragesManager_Get_ShouldCall_GetCoverages(int dealNumber) { //Arrange SetupUserIdentity(); // Arrange dealCoveragesRepository = new Mock <IDealCoveragesRepository>(); //SetupDealCoveragesRepository(dealCoveragesRepository, dealNumber); IList <Data.Models.grs_VGrsDealCoverage> CoveragesDbData = new List <Data.Models.grs_VGrsDealCoverage> { new Data.Models.grs_VGrsDealCoverage { Dealnum = dealNumber, CoverId = 13, CoverName = "California Earthquake" } }; // Get method dealCoveragesRepository.Setup(p => p.GetDealCoverages(dealNumber)).Returns(CoveragesDbData); DealCoveragesManager dealCovergaresManager = new DealCoveragesManager(userManager.Object, cacheStoreManager.Object, mockLogManager.Object, dealCoveragesRepository.Object, new Mock <IEntityLockManager>().Object, transformationManager); //Act EntityResult <IEnumerable <BLL_DealCoverages> > actual = dealCovergaresManager.GetDealCoverages(dealNumber); //Assert Assert.IsNotEmpty(actual.Data); }
private DealCoveragesController CreateDealCoveragesController(HttpRequestMessage httpRequest, IDealCoveragesRepository dealCoveragesRepository) { DealCoveragesManager dealCoveragesManager = new DealCoveragesManager(userManager.Object, cacheStoreManager.Object, mockLogManager.Object, dealCoveragesRepository, dealLockManager.Object, transformationManager); DealAPIManager dealAPIManager = new DealAPIManager(userManager.Object, cacheStoreManager.Object, mockLogManager.Object, dealCoveragesManager); DealCoveragesController dealCoveragesController = new DealCoveragesController(userManager.Object, dealAPIManager) { Request = httpRequest, Configuration = new HttpConfiguration() }; return(dealCoveragesController); }
public void DealsCoverageController_Get_Null_ValidationAPIException(int dealnumber) { #region Arrange SetupUserIdentity(); SetupDealCoveragesRepository(out Mock <IDealCoveragesRepository> dealsCoverageRepository, dealnumber); #endregion #region Act var httpRequest = new HttpRequestMessage(new HttpMethod(AppSettings.HTTPGET), $"{AppSettings.BASEURL}{RouteHelper.DealsCoverageRoutePrefix}/{dealnumber}"); DealCoveragesManager dealCoveragesManager = new DealCoveragesManager(userManager.Object, cacheStoreManager.Object, mockLogManager.Object, dealsCoverageRepository.Object, dealLockManager.Object, transformationManager); GlobalReAPIManager globalReAPIManager = new GlobalReAPIManager(userManager.Object, cacheStoreManager.Object, mockLogManager.Object, new Mock <IDealManager>().Object, new Mock <IDealStatusSummariesManager>().Object, new Mock <IPersonsManager>().Object, dealLockManager.Object, dealCoveragesManager, new Mock <INotesManager>().Object); DealsCoverageController dealsCoverageController = new DealsCoverageController(userManager.Object, globalReAPIManager) { Request = httpRequest, Configuration = new HttpConfiguration() }; var response = dealsCoverageController.Get(dealnumber); #endregion #region Expected Data var expectedDealsCoverage = new grs_VGrsDealCoverage() { Dealnum = dealnumber, CoverId = 13, CoverName = "California Earthquake" }; #endregion #region Act & Assert if (response.ToString() == "System.Web.Http.Results.StatusCodeResult") { response = null; } Assert.IsNull(response); #endregion }
public void DealsCoverageController_Get_IsNullorEmpty_ValidationAPIException(int dealnumber) { #region Arrange SetupUserIdentity(); SetupDealCoveragesRepository(out Mock <IDealCoveragesRepository> dealsCoverageRepository, dealnumber); #endregion #region Act var httpRequest = new HttpRequestMessage(new HttpMethod(AppSettings.HTTPGET), $"{AppSettings.BASEURL}{RouteHelper.DealsCoverageRoutePrefix}/{dealnumber}"); DealCoveragesManager dealCoveragesManager = new DealCoveragesManager(userManager.Object, cacheStoreManager.Object, mockLogManager.Object, new Mock <IDealCoveragesRepository>().Object, dealLockManager.Object, transformationManager); GlobalReAPIManager globalReAPIManager = new GlobalReAPIManager(userManager.Object, cacheStoreManager.Object, mockLogManager.Object, new Mock <IDealManager>().Object, new Mock <IDealStatusSummariesManager>().Object, new Mock <IPersonsManager>().Object, dealLockManager.Object, dealCoveragesManager, new Mock <INotesManager>().Object); DealsCoverageController dealsCoverageController = new DealsCoverageController(userManager.Object, globalReAPIManager) { Request = httpRequest, Configuration = new HttpConfiguration() }; #endregion #region Act & Assert System.Web.Http.IHttpActionResult response = null; try { response = dealsCoverageController.Get(dealnumber); } catch (Exception) { Assert.IsNull(response); } #endregion }