Пример #1
0
        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 IHttpActionResult Get([FromUri] CedantsSearchCriteria criteria)
        {
            if (criteria == null)
            {
                return(StatusCode(HttpStatusCode.BadRequest));
            }

            if (criteria.CedantName.IsNullOrEmpty() && criteria.ParentGroupName.IsNullOrEmpty() && criteria.CedantId.IsNullOrEmpty() && criteria.ParentGroupId.IsNullOrEmpty() && criteria.LocationId.IsNullOrEmpty())
            {
                return(StatusCode(HttpStatusCode.BadRequest));
            }

            if (!criteria.CedantName.IsNullOrEmpty())
            {
                if (criteria.CedantName.Length < 2 && criteria.ParentGroupName.IsNullOrEmpty())
                {
                    return(StatusCode(HttpStatusCode.BadRequest));  //throw new NotAllowedAPIException("Search aborted! Cedant name search requires 2 or more chars ... ");
                }
            }

            if (!criteria.ParentGroupName.IsNullOrEmpty())
            {
                if (criteria.CedantName.IsNullOrEmpty() && criteria.ParentGroupName.Length < 2)
                {
                    return(StatusCode(HttpStatusCode.BadRequest));  //throw new NotAllowedAPIException("Search aborted! Cedant parent group name search requires 2 or more chars ... ");
                }
            }

            if (!criteria.CedantName.IsNullOrEmpty() && !criteria.ParentGroupName.IsNullOrEmpty())
            {
                if (criteria.CedantName.Length < 2 || criteria.ParentGroupName.Length < 2)
                {
                    return(StatusCode(HttpStatusCode.BadRequest));
                }
            }

            return(this.GetResponse(EntityManager.GetCedants(criteria.CedantName, criteria.ParentGroupName, criteria.CedantId, criteria.ParentGroupId, criteria.LocationId)));
        }
Пример #3
0
        public void CedantsController_GetCedent_NotFoundAPIException(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 Assert

            IHttpActionResult actionResult = cedantsController.Get(criteria.CedantName);
            Assert.AreEqual(HttpStatusCode.BadRequest, ((StatusCodeResult)actionResult).StatusCode);

            #endregion
        }
Пример #4
0
        private void SetupCedantRepository(out Mock <ICedantRepository> cedantRepository, CedantsSearchCriteria criteria)
        {
            cedantRepository = new Mock <ICedantRepository>();
            IList <Data.Models.grs_VGrsCedant> cedantDbData = new List <Data.Models.grs_VGrsCedant>
            {
                new Data.Models.grs_VGrsCedant
                {
                    Cedantid          = 56495,
                    Cedant            = "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"
                }
            };

            cedantRepository.Setup(p => p.GetCedants(criteria.CedantName, criteria.ParentGroupName, criteria.CedantId, criteria.ParentGroupId, criteria.LocationId)).Returns(cedantDbData);
        }