public void DealDocumentsController_GetKeyDocuments_OKResponse(DocuemntSearchCriteria criteria) { #region Arrange SetupUserIdentity(); SetupDealKeyDocumentsRepository(out Mock <IDealDocumentsRepository> dealDocumentsRepository, criteria); var httpRequest = new HttpRequestMessage(new HttpMethod(AppSettings.HTTPGET), $"{AppSettings.BASEURL}{RouteHelper.DealsRoutePrefix}/{criteria.FileNumber}/keydoctypes/{criteria.GetDoctypes}"); DealDocumentsController dealDocumentController = CreateDealDocumentsController(httpRequest, dealDocumentsRepository.Object); #endregion #region Act var contentResult = dealDocumentController.Get(criteria.FileNumber.ToString(), criteria.GetDoctypes) as NegotiatedContentResult <ResponseCollection <DealDocuments> >; #endregion #region Expected Data var expectedDocuments = new DealDocuments() { KeyDocid = 0, FileNumber = 103324, Producer = 0, Docid = "", DocName = "", SortOrder = 1, Location = "", Drawer = "", Folderid = "06", FolderName = "Final Documents", DocType = "Contract - Final RI", ErmsClassType = "", FileType = "", DmsPath = "u-rdc-wsdms01\\active\\[Deal]\\06-Final Documents ([DealNum])", ItemCategoryid = 4, ErmsCategory = "Signed Contract", LastUpdatedUser = "", LastTimeStamp = DateTime.Parse("2019-01-17T15:29:29.523"), DmsCreated = DateTime.Parse("2019-01-17T15:29:29.523"), DmsUpdated = DateTime.Parse("2019-01-17T15:29:29.523") }; #endregion #region Assert Assertions.AssertOkResponse(contentResult); for (int i = 0; i <= contentResult.Content.results.Count - 1; i++) { var actualData = contentResult.Content.results[i].data; Assertions.AssertData(expectedDocuments, actualData); Assert.IsEmpty(contentResult.Content.results[i].messages); } #endregion }
public void CedantsController_GetCedant_OKResponse(CedantsSearchCriteria criteria) { #region Arrange SetupUserIdentity(); SetupCedantRepository(out Mock <ICedantRepository> cedantRepository, criteria); var httpRequest = new HttpRequestMessage(new HttpMethod(AppSettings.HTTPPOST), $"{AppSettings.BASEURL}{RouteHelper.CedantsRoutePrefix}"); CedantsController cedantsController = CreateCedantController(httpRequest, cedantRepository.Object); #endregion #region Act #endregion #region Expected Data var expectedCedants = new Cedant() // grs_VGrsCedant() { Cedantid = 56495, Name = "Starr Indemnity & Liability Company", //Parentgrouptypeid = 10011, //Parentgrouptype = "Reinsurance Cedant Group", Cedantgroupid = 1019169, Cedantgroupname = "Starr International Company, Inc.", Locationid = 244894, //Locationname = "Starr Indemnity", Locationaddress = "8401 N Central Expressway", Locationcity = "Dallas", Locationstate = "TX", Locationpostcode = null, Country = "United States" //Parentcompanyname = null, //Cedantcategories = "Global Re Cedant", //Cedantcategoryid = "90" }; #endregion #region Assert if (cedantsController.Get(criteria) is NegotiatedContentResult <ResponseCollection <Cedant> > contentResult) { Assertions.AssertOkResponse(contentResult); for (int i = 0; i <= contentResult.Content.results.Count - 1; i++) { var actualCedants = contentResult.Content.results[i].data; Assertions.AssertData(expectedCedants, actualCedants); Assert.IsEmpty(contentResult.Content.results[i].messages); } } #endregion }
public void DealCoveragesController_GetCoverages_OKResponse(int dealnumber) { #region Arrange SetupUserIdentity(); SetupDealCoveragesRepository(out Mock <IDealCoveragesRepository> dealCoveragesRepository, dealnumber); var httpRequest = new HttpRequestMessage(new HttpMethod(AppSettings.HTTPGET), $"{AppSettings.BASEURL}{RouteHelper.DealsRoutePrefix}/{dealnumber}/covergaes"); DealCoveragesController dealCoveragesController = CreateDealCoveragesController(httpRequest, dealCoveragesRepository.Object); #endregion #region Act var response = dealCoveragesController.Get(dealnumber); #endregion #region Expected Data var expectedDealCoverages = 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 actualDealCoverages = dealCoveragesData[i].data; Assertions.AssertData(expectedDealCoverages, actualDealCoverages); Assert.IsEmpty(dealCoveragesData[i].messages); } } #endregion }
public void UserViewController_DefaultGetWithViewID_Returns_OKResponseCode(UserViewIDSearch vwId) { #region Arrange var ViewID = vwId.viewId; SetupUserViewRepository(); var httpRequest = new HttpRequestMessage(new HttpMethod(AppSettings.HTTPGET), $"{AppSettings.BASEURL}{RouteHelper.UserviewRoutePrefix}/{ViewID}"); UserViewController userViewController = CreateUserViewController(httpRequest, userViewRepository.Object, userViewScreenRepository.Object); #endregion #region Act var response = userViewController.Get(ViewID); var contentResult = response as NegotiatedContentResult <ResponseItem <UserView> >; #endregion #region Assert #region Expected Data var expectedUserView = new UserView() { ViewId = 101, UserId = 100, Default = false, ScreenName = "GRS.UW_Workbench", ViewName = "mysubmissions", Layout = "SomeJason", CustomView = false, SortOrder = 1 }; #endregion Assertions.AssertOkResponse(contentResult); var UserViewsData = contentResult.Content.data; //Data var actualUserView = UserViewsData; Assertions.AssertData(expectedUserView, actualUserView); //Links & Messages // Assert.IsEmpty(contentResult.Content.links); Assert.IsEmpty(contentResult.Content.messages); #endregion }
public void PersonsController_Get_Returns_OKResponseCode(PersonSearchCriteria personSearchCriteria) { #region Arrange SetupUserIdentity(); SetupPersonRepository(personSearchCriteria, out Mock <IPersonRepository> personRepository, out IPaginatedList <TbPerson> expected); var httpRequest = new HttpRequestMessage(new HttpMethod(AppSettings.HTTPGET), $"{AppSettings.BASEURL}{RouteHelper.PersonRoutePrefix}/{personSearchCriteria}"); PersonsController personsController = CreatePersonsController(httpRequest, personRepository.Object); #endregion #region Act var response = personsController.Search(personSearchCriteria); //var response = personsController.Get(It.IsAny<int>()); var contentResult = response as NegotiatedContentResult <ResponsePaginatedCollection <Person> >; #endregion #region Assert #region Expected Data var expectedPerson = new Person() { PersonId = (personSearchCriteria.PersonId) == 0 ? userIdentity.UserId : 123, FirstName = "John", LastName = "Smith", DisplayName = "John Smith" }; #endregion Assertions.AssertOkResponse(contentResult); var personsData = contentResult.Content.results; for (int i = 0; i <= personsData.Count - 1; i++) { //Data var actualPerson = personsData[i].data; Assertions.AssertData(expectedPerson, actualPerson); } #endregion }
public void UserViewController_Post_Returns_Created(UserView userViews) { #region Arrange SetupUserIdentity(); userViewRepository = new Mock <IUserViewRepository>(); //SetupUserViewRepository(out Mock<IUserViewRepository> userviewsRepository); var httpRequest = new HttpRequestMessage(new HttpMethod(AppSettings.HTTPPOST), $"{AppSettings.BASEURL}{RouteHelper.UserviewRoutePrefix}"); UserViewController userviewController = CreateUserViewController(httpRequest, userViewRepository.Object, userViewScreenRepository.Object); var userviewdata = new grs_TblUserview() { ViewId = 101, Userid = 100, Default = false, Screenname = "GRS.UW_Workbench", Viewname = "mysubmissions", Layout = "SomeJason", Customview = false, Sortorder = 1 }; grs_TblUserview nullData = null; userViewRepository.SetupSequence(p => p.Get(It.IsAny <Expression <Func <grs_TblUserview, bool> > >())) .Returns(nullData) .Returns(userviewdata); #endregion #region Act var response = userviewController.Post(userViews); #endregion #region Expected Data var expectedUserViewdata = new UserView() { ViewId = 101, UserId = 100, Default = false, ScreenName = "GRS.UW_Workbench", ViewName = "mysubmissions", Layout = "SomeJason", CustomView = false, SortOrder = 1 }; #endregion #region Assert var contentResult = response as NegotiatedContentResult <ResponseItem <UserView> >; Assertions.AssertCreatedResponse(contentResult); var usrViewData = contentResult.Content.data; //Data var actualUserViewdata = usrViewData; Assertions.AssertData(expectedUserViewdata, actualUserViewdata); //Links & Messages // Assert.IsEmpty(contentResult.Content.links); Assert.IsEmpty(contentResult.Content.messages); #endregion }
public void ChecklistsController_Get_Returns_OKResponseCode() { #region Arrange SetupUserIdentity(); int dealNumber = 123; var httpRequest = new HttpRequestMessage(new HttpMethod(AppSettings.HTTPGET), $"{AppSettings.BASEURL}{RouteHelper.DealsRoutePrefix}/{dealNumber}/checklists"); Mock <ITblCheckListRepository> checkListRepository = new Mock <ITblCheckListRepository>(); IList <grs_VGrsChecklistsByDeal> data = new List <grs_VGrsChecklistsByDeal> { new grs_VGrsChecklistsByDeal { Dealnum = 1392041, Entitynum = 1, Category = 17, CategoryName = "Pre-Bind Processing", Catorder = 14, Chklistnum = 276, ChecklistName = "Actuarial Analysis", Sortorder = 3, Readonly = false, Checked = true, PersonId = 714027, PersonName = "Dhanraj Patil", Note = "", FirstName = "Dhanraj", LastName = "Patil", MiddleName = null } }; checkListRepository.Setup(p => p.GetAllDealChecklists(123)).Returns(data); CheckListsController checkListsController = CreateChecklistsController(httpRequest, checkListRepository.Object); #endregion #region Act var response = checkListsController.Get(dealNumber); var contentResult = response as NegotiatedContentResult <ResponseCollection <ChkCategoryTree> >; #endregion #region Assert #region Expected Data var expectedchktree = new CheckListTree { ChkListNum = 276, ChkListName = "Actuarial Analysis", SortOrder = 3, ReadOnly = false, Checked = true, PersonId = 714027, PersonName = "Dhanraj Patil", Note = "", FirstName = "Dhanraj", LastName = "Patil", MiddleName = null }; var expectedData = new List <ChkCategoryTree> { new ChkCategoryTree { DealNumber = 1392041, EntityNum = 1, CategoryID = 17, CategoryName = "Pre-Bind Processing", CatOrder = 14, Checklists = new List <CheckListTree> { expectedchktree } } }; //expectedData[0].Checklists.Add(expectedchktree); var chklistdata = contentResult.Content.results; for (int i = 0; i <= chklistdata.Count - 1; i++) { //Data var actualchklistdata = chklistdata[i].data; Assertions.AssertData(expectedData[0], actualchklistdata); Assert.IsEmpty(chklistdata[i].messages); } #endregion Assertions.AssertOkResponse(contentResult); #endregion }
public void ChecklistsController_Put_Returns_OKResponseCode(int dealnumber, int checklistnum, bool chkstatus, ChkCategoryTree checklist) { #region Arrange SetupUserIdentity(); var httpRequest = new HttpRequestMessage(new HttpMethod(AppSettings.HTTPGET), $"{AppSettings.BASEURL}{RouteHelper.DealsRoutePrefix}/{dealnumber}/checklists/{checklistnum}"); Mock <ITblCheckListRepository> checkListRepository = new Mock <ITblCheckListRepository>(); IList <grs_VGrsChecklistsByDeal> data = new List <grs_VGrsChecklistsByDeal> { new grs_VGrsChecklistsByDeal { Dealnum = 1392041, Entitynum = 1, Category = 17, CategoryName = "Pre-Bind Processing", Catorder = 14, Chklistnum = 276, ChecklistName = "Actuarial Analysis", Sortorder = 3, Readonly = false, Checked = true, PersonId = 714027, PersonName = "Dhanraj Patil", Note = "Test DP", FirstName = "Dhanraj", LastName = "Patil", MiddleName = null } }; if (chkstatus) { checkListRepository.Setup(p => p.IsValidDealCheckedStatus(data[0].Dealnum, data[0].Chklistnum)).Returns(1); } else { checkListRepository.Setup(p => p.IsValidDealCheckedStatus(data[0].Dealnum, data[0].Chklistnum)).Returns(0); } checkListRepository.Setup(p => p.GetPersonByUserId(data[0].PersonId ?? 0)).Returns(data[0].PersonName); checkListRepository.Setup(p => p.GetCheckNumByDealChecklists(data[0].Dealnum, data[0].Chklistnum)).Returns(data); var chklistval = new TbChklistval { PersonId = 714027 }; checkListRepository.Setup(p => p.Get(It.IsAny <Expression <Func <TbChklistval, bool> > >())).Returns(chklistval); CheckListsController checkListsController = CreateChecklistsController(httpRequest, checkListRepository.Object); #endregion #region Act var response = checkListsController.Put(dealnumber, checklistnum, checklist); #endregion #region Assert #region Expected Data var expectedchktree = new CheckListTree { ChkListNum = 276, ChkListName = "Actuarial Analysis", SortOrder = 3, ReadOnly = false, Checked = true, PersonId = 714027, PersonName = "Dhanraj Patil", Note = "Test DP", FirstName = "Dhanraj", LastName = "Patil", MiddleName = null }; var expectedData = new List <ChkCategoryTree> { new ChkCategoryTree { DealNumber = 1392041, EntityNum = 1, CategoryID = 17, CategoryName = "Pre-Bind Processing", CatOrder = 14, Checklists = new List <CheckListTree> { expectedchktree } } }; #endregion if (chkstatus && !(checklist.Checklists[0].Checked ?? false)) { var contentResult = response as NegotiatedContentResult <Response>; Assertions.AssertOkResponse(contentResult); } else { var contentResult = response as NegotiatedContentResult <ResponseItem <ChkCategoryTree> >; var chklistdata = contentResult.Content.data; Assertions.AssertData(expectedData[0], chklistdata); Assertions.AssertOkResponse(contentResult); } #endregion }
public void DealStatusSummariesController_Get_Returns_OKResponseCode(DealSearchCriteria criteria) { #region Arrange SetupUserIdentity(); //Create mock repository var dealStatusSummariesRepository = new Mock <IDealStatusSummariesRepository>(); //Build response IList <Data.Models.grs_PrGetGrsDealCountByStatus> dealDbData = new List <Data.Models.grs_PrGetGrsDealCountByStatus> { new Data.Models.grs_PrGetGrsDealCountByStatus { StatusGroup = 3, StatusGroupName = "Bound - Pending Actions", StatusGroupSortOrder = 3, StatusCode = 1000, StatusName = "Bound - Pending Actions", StatusSortOrder = 1, Count = 1578, WorkflowID = 1, WorkflowName = "Default" } }; // Search method dealStatusSummariesRepository.Setup(p => p.GetAllDealStatusSummaries(It.IsAny <string>(), It.IsAny <string>())) .Returns(dealDbData); dealStatusSummariesRepository.Setup(p => p.ValidPerson(It.IsAny <int>())) .Returns(true); dealStatusSummariesRepository.Setup(x => x.GetGlobalReExposureTree()).Returns(new List <grs_VExposureTreeExt> { new grs_VExposureTreeExt { SubdivisionCode = 1, SubdivisionName = "Casualty", ProductLineCode = 1001, ProductLineName = "Auto Reins", ExposureGroupCode = 59, ExposureGroupName = "CA - Auto - Commercial", ExposureTypeCode = 5916, ExposureTypeName = "CA - Auto - Commercial - Non Trucking" }, new grs_VExposureTreeExt { SubdivisionCode = 2, SubdivisionName = "Casualty", ProductLineCode = 1001, ProductLineName = "Auto Reins", ExposureGroupCode = 59, ExposureGroupName = "CA - Auto - Commercial", ExposureTypeCode = 5922, ExposureTypeName = "CA - Auto - Commercial - Non Trucking" } }); //Manager DealStatusSummariesManager dealStatusSummariesManager = new DealStatusSummariesManager(userManager.Object, cacheStoreManager, mockLogManager.Object, dealStatusSummariesRepository.Object, transformationManager); var httpRequest = new HttpRequestMessage(new HttpMethod(AppSettings.HTTPGET), $"{AppSettings.BASEURL}{RouteHelper.DealStatusSummaryRoutePrefix}"); DealAPIManager dealAPIManager = new DealAPIManager(userManager.Object, cacheStoreManager, mockLogManager.Object, dealStatusSummariesManager); DealStatusSummariesController dealStatusSummariesController = new DealStatusSummariesController(userManager.Object, dealAPIManager) { Request = httpRequest, Configuration = new HttpConfiguration() }; #endregion #region Act var response = dealStatusSummariesController.GetAll(criteria); var contentResult = response as NegotiatedContentResult <ResponseCollection <DealStatusSummary> >; #endregion #region Assert #region Expected var expectedDealSummary = new DealStatusSummary { StatusCode = 1000, StatusName = "Bound - Pending Actions", SortOrder = 3, Count = 1578, WorkflowId = 1, WorkflowName = "Default" }; var expectedGetLink = new Link(LinkType.RelatedEntity, EntityType.Deals, $"v1/deals?statuscodes={expectedDealSummary.StatusCode}", HttpMethodType.GET); #endregion Assertions.AssertOkResponse(contentResult); var summaryData = contentResult.Content.results; for (int i = 0; i <= summaryData.Count - 1; i++) { //Data var actualDealSummary = summaryData[i].data; Assertions.AssertData(expectedDealSummary, actualDealSummary); //Links & Messages Assert.Multiple(() => { Assert.IsNotEmpty(summaryData[i].links); Assert.AreEqual(1, summaryData[i].links.Count); Assertions.AssertLink(expectedGetLink, summaryData[i].links[0]); }); Assert.IsEmpty(summaryData[i].messages); } #endregion }
public void ExposureTreeController_Get_Returns_OKResponseCode() { #region Arrange SetupUserIdentity(); //Create mock repository var exposureTreeRepository = new Mock <IExposureTreeRepository>(); //Build response IList <grs_VExposureTreeExt> exposureTreeDbData = new List <grs_VExposureTreeExt> { new grs_VExposureTreeExt { SubdivisionCode = 300, SubdivisionName = "Casualty", ProductLineCode = 1001, ProductLineName = "Auto Reins", ExposureGroupCode = 59, ExposureGroupName = "CA - Auto - Commercial", ExposureTypeCode = 5909, ExposureTypeName = "CA - Auto - Commercial - Non Trucking" } }; exposureTreeRepository.Setup(p => p.GetGlobalReExposureTree()) .Returns(exposureTreeDbData); //Manager ExposureTreeManager exposureTreeManager = new ExposureTreeManager(userManager.Object, cacheStoreManager, mockLogManager.Object, exposureTreeRepository.Object, transformationManager); var httpRequest = new HttpRequestMessage(new HttpMethod(AppSettings.HTTPGET), $"{AppSettings.BASEURL}{RouteHelper.LookupsExposureTreeRoutePrefix}"); DealAPIManager dealAPIManager = new DealAPIManager(userManager.Object, cacheStoreManager, mockLogManager.Object, exposureTreeManager); ExposureTreeController exposureTreeController = new ExposureTreeController(userManager.Object, dealAPIManager) { Request = httpRequest, Configuration = new HttpConfiguration() }; #endregion #region Act var response = exposureTreeController.GetGlobalReExposureTree(); var contentResult = response as NegotiatedContentResult <ResponseCollection <ExposureTree> >; #endregion #region Assert #region Expected ExposureTree expectedExposureTree = new ExposureTree { SubdivisionCode = 300, SubdivisionName = "Casualty", ProductLineCode = 1001, ProductLineName = "Auto Reins", ExposureGroupCode = 59, ExposureGroupName = "CA - Auto - Commercial", ExposureTypeCode = 5909, ExposureTypeName = "CA - Auto - Commercial - Non Trucking" }; #endregion Assertions.AssertOkResponse(contentResult); var summaryData = contentResult.Content.results; for (int i = 0; i <= summaryData.Count - 1; i++) { //Data var actualExposureTree = summaryData[i].data; Assertions.AssertData(expectedExposureTree, actualExposureTree); Assert.IsEmpty(summaryData[i].messages); } #endregion }
public void UserViewScreenController_Get_Returns_OKResponseCode(UserViewSearchCriteria criteria) { #region Arrange SetupUserIdentity(); //Build response IList <grs_VGrsUserView> userViewScreenDbData = new List <grs_VGrsUserView> { new grs_VGrsUserView { ViewId = 101, Userid = 100, Default = false, Screenname = "GRS.UW_Workbench", Viewname = "mysubmissions", Layout = "SomeJason", Customview = false, Sortorder = 1 } }; // Search method userViewScreenRepository.Setup(p => p.GetMany(It.IsAny <Expression <Func <grs_VGrsUserView, bool> > >())).Returns(userViewScreenDbData); var httpRequest = new HttpRequestMessage(new HttpMethod(AppSettings.HTTPGET), $"{AppSettings.BASEURL}{RouteHelper.UserviewRoutePrefix}"); UserViewController userviewController = CreateUserViewController(httpRequest, userViewRepository.Object, userViewScreenRepository.Object); #endregion #region Act var response = userviewController.Get(criteria); var contentResult = response as NegotiatedContentResult <ResponseCollection <UserView> >; #endregion #region Assert #region Expected var expectedUserViewScreen = new UserView { ViewId = 101, UserId = 100, Default = false, ScreenName = "GRS.UW_Workbench", ViewName = "mysubmissions", Layout = null, CustomView = false, SortOrder = 1 }; //var expectedGetLink = new Link(LinkType.RelatedEntity, EntityType.Notes, $"v1/userviews?screenname={expectedUserViewScreen.ScreenName}", HttpMethodType.GET); #endregion Assertions.AssertOkResponse(contentResult); var summaryData = contentResult.Content.results; for (int i = 0; i <= summaryData.Count - 1; i++) { //Data var actualUserViewScreen = summaryData[i].data; Assertions.AssertData(expectedUserViewScreen, actualUserViewScreen); // Links & Messages //Assert.Multiple(() => //{ // Assert.IsNotEmpty(summaryData[i].links); // Assert.AreEqual(1, summaryData[i].links.Count); // Assertions.AssertLink(expectedGetLink, summaryData[i].links[0]); //}); Assert.IsEmpty(summaryData[i].messages); } #endregion }
public void DealNotesController_Post_Returns_CreatedCode(Notes dealNotes) { #region Arrange SetupUserIdentity(); SetupDealNotesRepo(out Mock <ITbDealNotesRepository> dealNotesRepository, dealNotes); #endregion var notesRepository = new Mock <INotesRepository>(); var httpRequest = new HttpRequestMessage(new HttpMethod(AppSettings.HTTPPOST), $"{AppSettings.BASEURL}{RouteHelper.NotesRoutePrefix}"); NotesController dealNotesController = CreateDealNotesController(httpRequest, notesRepository.Object); //Build response IList <Data.Models.grs_VGrsNote> dealDbData = new List <Data.Models.grs_VGrsNote> { new Data.Models.grs_VGrsNote { Dealnum = 101, Notenum = 100, Notetype = 3, Notes = "Test Notes Desc", Notedate = Convert.ToDateTime("03/01/2019"), Whoentered = 8069, Name = "Chris Downey", FirstName = "Chris", MiddleName = null, LastName = "Downey" } }; notesRepository.Setup(p => p.GetNotebyNoteNumber(0)).Returns(dealDbData); #region Act var response = dealNotesController.Post(dealNotes); #endregion #region Expected Data var expectedDealNote = new Notes() { DealNumber = 101, Notenum = 100, Notetype = 3, NoteText = "Test Notes Desc", Notedate = Convert.ToDateTime("03/01/2019"), Whoentered = 8069, Name = "Chris Downey", FirstName = "Chris", MiddleName = null, LastName = "Downey" }; #endregion #region Assert var contentResult = response as NegotiatedContentResult <ResponseItem <Notes> >; Assertions.AssertCreatedResponse(contentResult); var dealNoteData = contentResult.Content.data; //Data var actualDealNote = dealNoteData; Assertions.AssertData(expectedDealNote, actualDealNote); //Links & Messages // Assert.IsEmpty(contentResult.Content.links); Assert.IsEmpty(contentResult.Content.messages); #endregion }
public void UserViewController_Put_Returns_OkCode(UserView userveiws) { #region Arrange SetupUserIdentity(); SetupUserViewRepository(out Mock <IUserViewRepository> userViewRepository); var usrViewRepository = new Mock <IUserViewRepository>(); #endregion #region Act var usrViewDbData = new grs_TblUserview() { ViewId = 46, Userid = 4896, Default = false, Screenname = "GRS.UW_Workbench", Viewname = "mysubmissions", Layout = "SomeJason", Customview = false, Sortorder = 1 }; usrViewRepository.Setup(p => p.Get(It.IsAny <Expression <Func <grs_TblUserview, bool> > >())).Returns(usrViewDbData); usrViewRepository.Setup(p => p.Get(46)).Returns(usrViewDbData); var httpRequest = new HttpRequestMessage(new HttpMethod(AppSettings.HTTPPOST), $"{AppSettings.BASEURL}{RouteHelper.UserviewRoutePrefix}"); UserViewManager UserViewManager = new UserViewManager(userManager.Object, cacheStoreManager.Object, mockLogManager.Object, usrViewRepository.Object, transformationManager); UserPreferencesAPIManager userViewAPIManager = new UserPreferencesAPIManager(userManager.Object, cacheStoreManager.Object, mockLogManager.Object, UserViewManager); UserViewController userviewController = new UserViewController(userManager.Object, userViewAPIManager) { Request = httpRequest, Configuration = new HttpConfiguration() }; #endregion #region Act var response = userviewController.Put(userveiws.ViewId, userveiws); #endregion #region Expected Data var expectedUserViewdata = new UserView() { ViewId = 46, UserId = 4896, Default = false, ScreenName = "GRS.UW_Workbench", ViewName = "mysubmissions", Layout = "SomeJason", CustomView = false, SortOrder = 1 }; #region Assert var contentResult = response as NegotiatedContentResult <ResponseItem <UserView> >; Assertions.AssertOkResponse(contentResult); var usrViewData = contentResult.Content.data; //Data var actualUserViewdata = usrViewData; Assertions.AssertData(expectedUserViewdata, actualUserViewdata); //Links & Messages // Assert.IsEmpty(contentResult.Content.links); Assert.IsEmpty(contentResult.Content.messages); #endregion }
public void WritingCompanyController_Get_Returns_OKResponseCode(Boolean isGRSFlag) { #region Arrange SetupUserIdentity(); SetupWritingCompanyRepository(out Mock <IWritingCompanyRepository> writingCompanyRepository, isGRSFlag); var httpRequest = new HttpRequestMessage(new HttpMethod(AppSettings.HTTPPOST), $"{AppSettings.BASEURL}{RouteHelper.WritingCompanyRoutePrefix}"); WritingCompaniesController writingCompanyController = CreateWritingCompanyController(httpRequest, writingCompanyRepository.Object); #endregion #region Act var response = writingCompanyController.Get(isGRSFlag); #endregion #region Expected Data var expectedWritingCompany = new WritingCompany() { Papernum = 16, Companyname = "Markel Global Reinsurance Company", Cpnum = 201178, Addr1 = "535 Springfield Avenue", Addr2 = "", Addr3 = "", City = "Summit", State = "NJ", Postalcode = "07901-2608", Country = "United States", Phone = null, Fax = null, Imagefilename = "images\\Markel.jpg", CompanyShortname = "ARUI", SlTrequired = 0, IpTrequired = 0, PaperToken = null, Currency = null, Territory = null, Active = 1, HideUnusedClaimCategory = true, JeCode = "102", }; #endregion #region Assert var contentResult = response as NegotiatedContentResult <ResponseCollection <WritingCompany> >; if (contentResult != null) { Assertions.AssertOkResponse(contentResult); var writingcompanyData = contentResult.Content.results; for (int i = 0; i <= writingcompanyData.Count - 1; i++) { var actualWritingCompany = writingcompanyData[i].data; Assertions.AssertData(expectedWritingCompany, actualWritingCompany); Assert.IsEmpty(writingcompanyData[i].messages); } } #endregion }
// [TestCaseSource(typeof(ContractTypeSearchData), "TestCases")] public void ContractTypeController_Get_Returns_OKResponseCode() { #region Arrange SetupUserIdentity(); //string assumedOrceded = "assumed"; //Create mock repository var contractTypeRepository = new Mock <IContractTypesLookupRepository>(); //Build response IList <Data.Models.grs_VGrsContractType> contractTypeDbData = new List <Data.Models.grs_VGrsContractType> { new Data.Models.grs_VGrsContractType { Code = 11, Exposurename = "Reinsurance - Treaty", InsuranceName = "test", AssumedFlag = 1, AssumedName = "Treaty", CededFlag = null, Exposuretype = 1, Active = true, Catorder = 1, CededName = "ceded", RowId = 1 }, }; #endregion // Search method contractTypeRepository.Setup(p => p.GetContractTypes()) .Returns(contractTypeDbData); //Manager //ContractTypesManager contractTypeManager = new ContractTypesManager(userManager.Object, cacheStoreManager.Object, mockLogManager.Object, contractTypeRepository.Object, transformationManager, new Mock<IPersonProfileManager>().Object); ContractTypesManager contractTypeManager = new ContractTypesManager(userManager.Object, cacheStoreManager.Object, mockLogManager.Object, contractTypeRepository.Object, transformationManager); var httpRequest = new HttpRequestMessage(new HttpMethod(AppSettings.HTTPGET), $"{AppSettings.BASEURL}{RouteHelper.LookupsContractTypesRoutePrefix}"); DealAPIManager dealAPIManager = new DealAPIManager(userManager.Object, cacheStoreManager.Object, mockLogManager.Object, new Mock <IDealManager>().Object, new Mock <IEntityLockManager>().Object); ContractTypesLookupController contractTypeController = new ContractTypesLookupController(userManager.Object, dealAPIManager) { Request = httpRequest, Configuration = new HttpConfiguration() }; #region Act //var response = contractTypeController.Get(criteria); // CoverageBasisSearchCriteria dsc = new CoverageBasisSearchCriteria { assumedOrCededFlag = "assumed" }; var response = contractTypeController.Get(); //var response = contractTypeController.Get(It.IsAny<DealNotesSearchCriteria>()); var contentResult = response as NegotiatedContentResult <ResponseCollection <ContractTypes> >; #endregion #region Assert var expectedContractType = new ContractTypes { name = "Treaty", value = "11", group = "1", isActive = true }; if (contentResult != null) { Assertions.AssertOkResponse(contentResult); var contractTypeData = contentResult.Content.results; for (int i = 0; i <= contractTypeData.Count - 1; i++) { var actualcontractTypes = contractTypeData[i].data; Assertions.AssertData(expectedContractType, actualcontractTypes); Assert.IsEmpty(contractTypeData[i].messages); } } #endregion }
public void NotesController_Get_Returns_OKResponseCode(NotesSearchCriteria criteria) { #region Arrange SetupUserIdentity(); //Create mock repository var dealNotesRepository = new Mock <INotesRepository>(); //Build response IList <Data.Models.grs_VGrsNote> dealDbData = new List <Data.Models.grs_VGrsNote> { new Data.Models.grs_VGrsNote { Notenum = 698, Dealnum = 233, Notedate = Convert.ToDateTime("2001-06-19 00:00:00.000"), Notes = "Left message for John Kenney to let him no that we would most likely not be able to quote on the submission due the relatively small size of the deal, and the amount of risk transfer that appeared that they were looking for (in the slip: winner take all w/ no agg limit)", Notetype = 22, Whoentered = 8069, Name = "Chris Downey", FirstName = "Chris", MiddleName = null, LastName = "Downey" } }; // Search method dealNotesRepository.Setup(p => p.GetNotes(criteria.DealNumber)).Returns(dealDbData); var httpRequest = new HttpRequestMessage(new HttpMethod(AppSettings.HTTPGET), $"{AppSettings.BASEURL}{RouteHelper.NotesRoutePrefix}"); NotesController dealNotesController = CreateDealNotesController(httpRequest, dealNotesRepository.Object); #endregion #region Act //var response = dealNotesController.Get(criteria); //DealNotesSearchCriteria dsc = new DealNotesSearchCriteria { DealNumber = 233 }; var response = dealNotesController.Get(criteria); //var response = dealNotesController.Get(It.IsAny<DealNotesSearchCriteria>()); var contentResult = response as NegotiatedContentResult <ResponseCollection <Notes> >; #endregion #region Assert #region Expected var expectedDealNotes = new Notes { Notenum = 698, DealNumber = 233, Notedate = Convert.ToDateTime("2001-06-19 00:00:00.000"), NoteText = "Left message for John Kenney to let him no that we would most likely not be able to quote on the submission due the relatively small size of the deal, and the amount of risk transfer that appeared that they were looking for (in the slip: winner take all w/ no agg limit)", Notetype = 22, Whoentered = 8069, Name = "Chris Downey", FirstName = "Chris", MiddleName = null, LastName = "Downey" }; var expectedGetLink = new Link(LinkType.RelatedEntity, EntityType.Notes, $"v1/notes?dealnumber={expectedDealNotes.DealNumber}", HttpMethodType.GET); #endregion Assertions.AssertOkResponse(contentResult); var summaryData = contentResult.Content.results; for (int i = 0; i <= summaryData.Count - 1; i++) { //Data var actualDealNotes = summaryData[i].data; Assertions.AssertData(expectedDealNotes, actualDealNotes); // Links & Messages //Assert.Multiple(() => //{ // Assert.IsNotEmpty(summaryData[i].links); // Assert.AreEqual(1, summaryData[i].links.Count); // Assertions.AssertLink(expectedGetLink, summaryData[i].links[0]); //}); Assert.IsEmpty(summaryData[i].messages); } #endregion }
public void DealNotesController_Put_Returns_OkCode(Notes dealNotes) { #region Arrange SetupUserIdentity(); SetupDealNotesRepo(out Mock <ITbDealNotesRepository> dealNotesRepository, dealNotes); var notesRepository = new Mock <INotesRepository>(); var httpRequest = new HttpRequestMessage(new HttpMethod(AppSettings.HTTPPOST), $"{AppSettings.BASEURL}{RouteHelper.NotesRoutePrefix}"); NotesManager dealNotesManager = new NotesManager(userManager.Object, cacheStoreManager.Object, mockLogManager.Object, notesRepository.Object, transformationManager, dealNotesRepository.Object); DealAPIManager dealAPIManager = new DealAPIManager(userManager.Object, cacheStoreManager.Object, mockLogManager.Object, dealNotesManager); NotesController dealNotesController = new NotesController(userManager.Object, dealAPIManager) { Request = httpRequest, Configuration = new HttpConfiguration() }; #endregion #region Act //Build response IList <Data.Models.grs_VGrsNote> dealDbData = new List <Data.Models.grs_VGrsNote> { new Data.Models.grs_VGrsNote { Dealnum = 101, Notenum = 100, Notetype = 3, Notes = "Test Notes Desc", Notedate = Convert.ToDateTime(DateTime.Now.ToString("MM-dd-yyyy")), Whoentered = 8069, Name = "Chris Downey", FirstName = "Chris", MiddleName = null, LastName = "Downey" } }; #endregion #region Act notesRepository.Setup(p => p.GetNotebyNoteNumber(100)).Returns(dealDbData); #endregion #region Act var response = dealNotesController.Put(dealNotes); #endregion #region Expected Data var expectedDealNote = new Notes() { DealNumber = 101, Notenum = 100, Notetype = 3, NoteText = "Test Notes Desc", Notedate = Convert.ToDateTime(DateTime.Now.ToString("MM-dd-yyyy")), Whoentered = 8069, Name = "Chris Downey", FirstName = "Chris", MiddleName = null, LastName = "Downey" }; #endregion #region Assert var contentResult = response as NegotiatedContentResult <ResponseItem <Notes> >; Assertions.AssertOkResponse(contentResult); var dealNoteData = contentResult.Content.data; //Data var actualDealNote = dealNoteData; Assertions.AssertData(expectedDealNote, actualDealNote); //Links & Messages // Assert.IsEmpty(contentResult.Content.links); Assert.IsEmpty(contentResult.Content.messages); #endregion }