public async Task PolicyServiceCLient_FetchAll_Returns_All()
        {
            //Arrange
            var mockHttp        = new MockHttpMessageHandler();
            var insurancePolicy = new InsurancePolicy
            {
                EffectiveDate  = DateTime.Now,
                Expiration     = DateTime.Now,
                PolicyNumber   = "123456",
                PrimaryInsured = new PrimaryInsured
                {
                    PrimaryInsuredFirstName = "Mark",
                    PrimaryInsuredLastName  = "Wilson"
                }
            };

            mockHttp.When("http://localhost:50697/api/Policy/fetchall*")
            .Respond("application/json", JsonConvert.SerializeObject(
                         new List <InsurancePolicy> {
                insurancePolicy
            }));

            var client = mockHttp.ToHttpClient();
            var sut    = new PolicyServiceClient(client);

            //Act
            var displayPolicies = await sut.FetchAll();

            //Assert
            Assert.IsTrue(displayPolicies.Count() == 1);
            Assert.AreEqual(123456, displayPolicies.First().PolicyNumber);
        }
        public async Task PolicyServiceCLient_GetConstructionTypes_Returns_Types()
        {
            //Arrange
            var mockHttp      = new MockHttpMessageHandler();
            var buildingTypes = new BuildingType
            {
                Id   = "1",
                Name = "one"
            };

            mockHttp.When("http://localhost:50697/api/constructiontype/fetchall*")
            .Respond("application/json", JsonConvert.SerializeObject(
                         new List <BuildingType> {
                buildingTypes
            }));

            var client = mockHttp.ToHttpClient();
            var sut    = new PolicyServiceClient(client);

            //Act
            var constructionTypes = await sut.GetConstructionTypes();

            //Assert
            Assert.IsTrue(constructionTypes.Count() == 1);
            Assert.AreEqual("1", constructionTypes.First().Id);
        }
Example #3
0
        static void Main(string[] args)
        {
            DoLogin();

            PolicyServiceClient         client   = new PolicyServiceClient();
            ContextInformationInspector behavior = new ContextInformationInspector();

            client.Endpoint.Behaviors.Add((IEndpointBehavior)behavior);

            SST.PortalProd.AdmCartera.Common.Entities.Currency[] currencies = client.GetCurrencyList();
        }
        public async Task PolicyServiceCLient_Save_Posts_To_Add()
        {
            //Arrange
            var expectedResult = JsonConvert.SerializeObject(new { test = "Hello World" });

            AutoMapperConfig.RegisterMappings();
            var mockHttp = new MockHttpMessageHandler();

            mockHttp.When("http://localhost:50697/api/Policy/add*")
            .Respond("application/json", expectedResult);

            var client = mockHttp.ToHttpClient();
            var sut    = new PolicyServiceClient(client);

            //Act
            var response = await sut.Save(new AddPolicy { PolicyNumber = "123456" });

            //Assert
            Assert.AreEqual(expectedResult, response);
        }
        public void CreatePolicy(ref PetfirstCustomer mCustomer, List<Pet> lstPets)
        {
            mCustomer.WebserviceErrorMsg = "";
            PolicyServiceSellPolicyRequest pRequest = new PolicyServiceSellPolicyRequest();
            if (!string.IsNullOrEmpty(mCustomer.CcNumber))
            {
                pRequest.CreditCard = new CreditCard()
                {
                    Address1 = mCustomer.BillingInfo.Address1,
                    Address2 = mCustomer.BillingInfo.Address2,
                    City = mCustomer.BillingInfo.City,
                    Cvvs2 = mCustomer.SecCode,
                    ExpirationMonth = mCustomer.ExpirationMonth,
                    ExpirationYear = mCustomer.ExpirationYear,
                    FirstName = mCustomer.BillingInfo.FirstName,
                    LastName = mCustomer.BillingInfo.LastName,
                    Number = mCustomer.CcNumber,
                    StateId = mCustomer.BillingInfo.StateId,
                    ZipCode = mCustomer.BillingInfo.Zip

                };
            }
            if (mCustomer.GiftCards != null)
            {
                int gcCount = mCustomer.GiftCards.Count;
                pRequest.GiftCards = new PolicyServiceReference.GiftCard[gcCount];
                int i =0;
                foreach (GiftCard gc in mCustomer.GiftCards)
                {
                    PolicyServiceReference.GiftCard pGC = new PolicyServiceReference.GiftCard();
                    pGC.Pin = gc.Pin;
                    pGC.SrcRefNum = 0;
                    pRequest.GiftCards[i] = pGC;
                    i++;
                }
            }
            pRequest.Customer = new PolicyServiceReference.Customer()
            {
                ZipCode = mCustomer.MembershipInfo.Zip,
                WorkPhone = String.Empty,
                StreetAddress2 = mCustomer.MembershipInfo.Address2,
                StreetAddress = mCustomer.MembershipInfo.Address1,
                StateId = mCustomer.MembershipInfo.StateId,
                MobilePhone = String.Empty,
                LastName = mCustomer.MembershipInfo.LastName,
                FirstName = mCustomer.MembershipInfo.FirstName,
                HomePhone = mCustomer.MembershipInfo.Phone,
                CityName = mCustomer.MembershipInfo.City,
                EmailAddress = mCustomer.MembershipInfo.Email
            };
            pRequest.CoInsurance = 1-lstPets[0].Reimbursement;
            pRequest.Deductible = lstPets[0].DeductibleAmount;
            pRequest.EnrollmentCode = mCustomer.EnrollmentCode;
            pRequest.PlanId = lstPets[0].PlanId;
            pRequest.PaymentFrequencyId = (int)mCustomer.PayFrequency;//annual
            pRequest.IncludeRoutine = false;
            pRequest.IncludeRoutine125 = false;
            pRequest.IncludeRoutine250 = false;
            pRequest.IncludeRoutine400 = false;
            if (!lstPets[0].Routine.ToLower().Equals("0"))
            {
                pRequest.IncludeRoutine = true;
                switch (lstPets[0].Routine.ToLower())
                {
                    case "routine125":
                        pRequest.IncludeRoutine125 = true;
                        break;
                    case "routine250":
                        pRequest.IncludeRoutine250 = true;
                        break;
                    case "routine400": pRequest.IncludeRoutine400 = true;
                        break;

                }
            }

            pRequest.InternetDiscount = mCustomer.DiscountInternetPurchase;
            pRequest.MilitaryDiscount = mCustomer.DiscountMilitarySelected;
            pRequest.VetDiscount = mCustomer.DiscountVetSelected;
            int nPlan = lstPets[0].PlanId;
            int stateid = mCustomer.MembershipInfo.StateId;
            int underwriter = mCustomer.Underwriter;
            pRequest.UnderwriterID = mCustomer.Underwriter;
            pRequest.FilingID = (from pts in context.v_PlansToStates
                                 where pts.stateProvinceID.Equals(stateid) &&
                                     pts.UnderwriterID.Equals(underwriter) &&
                                     pts.plan_id == nPlan
                                 select pts.FilingID).First();

            pRequest.IncludeBreeders = lstPets[0].Breeder;
            if (lstPets[0].Hereditary.ToLower().Equals("hereditary100"))
            {
                pRequest.IncludeHereditary100 = true;
            }
            else if (lstPets[0].Hereditary.ToLower().Equals("hereditary25"))
            {
                pRequest.IncludeHereditary25 = true;
            }
            else
            {
                pRequest.IncludeHereditary100 = false;
                pRequest.IncludeHereditary25 = false;
            }
            pRequest.IncludePrescriptionFood = lstPets[0].PrescriptionFood;
            pRequest.KrogerLoyaltyNumber = string.Empty;

            PolicyServiceReference.Pet p1 = CreatePolicyRequestPet(lstPets[0]);
            if (lstPets.Count ==3)//3 pets
            {
                pRequest.Pets = new PolicyServiceReference.Pet[3];
                pRequest.Pets[0] = p1;
                pRequest.Pets[1] = CreatePolicyRequestPet(lstPets[1]);
                pRequest.Pets[2] = CreatePolicyRequestPet(lstPets[2]);
            }
            else if (lstPets.Count ==2)
            {
                pRequest.Pets = new PolicyServiceReference.Pet[2];
                pRequest.Pets[0] = p1;
                pRequest.Pets[1] = CreatePolicyRequestPet(lstPets[1]);
            }
            else
            {
                pRequest.Pets = new PolicyServiceReference.Pet[1];
                pRequest.Pets[0] = p1;
            }

            PolicyServiceClient pc = new PolicyServiceClient();
            try
            {
                PolicyServiceSellPolicyResponse resp = pc.SellPolicy(pRequest);
                if (string.IsNullOrEmpty(resp.Error))
                {
                    foreach (Pet p in lstPets)
                    {
                        p.PolicyNumber = resp.PolicyNumber;
                        p.PolicyId = resp.PolicyId;
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(resp.PolicyNumber))
                    {
                        foreach (Pet p in lstPets)
                        {
                            p.PolicyNumber = resp.PolicyNumber;
                            p.PolicyId = resp.PolicyId;
                        }
                    }
                    mCustomer.WebserviceErrorMsg = resp.Error;
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                try
                {
                    if (pc.State == CommunicationState.Faulted)
                        pc.Abort();
                    else if (pc.State == CommunicationState.Opened)
                        pc.Close();
                }
                catch { }
            }
        }
        public void CreateQuote_Success()
        {
            // Assign
            long actualTimeStamp = 0; 

            IPolicyService subscribeService = new PolicyServiceClient();
            var policyContract = new PolicyContract
            {
                UnitPsu = "AGY",
                PolTy = "NONMARINE",
                EntSt = "PARTIAL",
                InsdNm= "- N/A",
                InsdId= 182396,
                PolDsc= "Unit Test Submission",
                Uwr= "AED",
                DOM= "AD",
                BkrSeqId= 822,
                CtcNm= "ALLAN MURRAY",
                IncpDt= "20130628",
                ExpyDt= "20140628",
                AccYr= "2013",
                SettDueDt= "20130628",
                Brokerage= 1,
                DeclineReason= null,
                COB= "AD",
                MOA= "FA",
                NonLonBkr= null, 
                OrigOff= "LON",
                FacyPolId= null,
                RenPolId= null,
                PolId= null,
                LmtCcy= "USD",
                LmtAmt= null,
                ExsCcy= "USD",
                ExsAmt= null,
                BindSt= "PRE",
                PctgAmt= "AMT",
                PricingCcy= "USD",
                Method= "UW",
                TechPrm= null,
                BenchPrm= null,
                Status= "SUBMITTED",
                TimeStamp= null,
                BkrPsu= "AAA",
                BkrNo= "???",
                TechPmTy= "TechPm"
            };
            var request = new CreateQuoteRequest { objPolicyContract = policyContract };

            // Act
            var actualResponse = subscribeService.CreateQuote(request);

            if (actualResponse.CreateQuoteResult.ErrorInfo != null)
            {
                _logHandler.WriteLog(actualResponse.CreateQuoteResult.ErrorInfo.Description, LogSeverity.Error,
                                     LogCategory.BusinessComponent);
                _logHandler.WriteLog(actualResponse.CreateQuoteResult.ErrorInfo.ErrorXML, LogSeverity.Error,
                                     LogCategory.BusinessComponent);
                _logHandler.WriteLog(actualResponse.CreateQuoteResult.ErrorInfo.DetailedDescription, LogSeverity.Error,
                                     LogCategory.BusinessComponent);
                _logHandler.WriteLog(actualResponse.CreateQuoteResult.ErrorInfo.Severity.ToString(), LogSeverity.Error,
                                     LogCategory.BusinessComponent);
            }

            var doc = new XmlDocument();
            doc.LoadXml(actualResponse.CreateQuoteResult.OutputXml);

            _subscribeReference = doc.GetElementsByTagName("PolId")[0].InnerText;

            long subscribeTimestamp;
            actualTimeStamp = long.TryParse(doc.GetElementsByTagName("TimeStamp")[0].InnerText, out subscribeTimestamp) ?
                subscribeTimestamp : 0;

            // Assert
            Assert.IsNull(actualResponse.CreateQuoteResult.ErrorInfo);
            Assert.AreNotEqual(actualTimeStamp, 0);
            Assert.IsNotNull(_subscribeReference);
        }
        public void GetReference_Success()
        {
            // Assign
            var xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(IntegrationFixtureBase.GetReferenceResponseXml());
            var expectedResponsePolicyType = xmlDoc.GetElementsByTagName("PolId")[0].InnerText;
            
            IPolicyService subscribeService = new PolicyServiceClient();
            var getReferenceRequest = new GetReferenceRequest {strPolId = "ADF169034A13" };

            // Act
            var actualResponse = subscribeService.GetReference(getReferenceRequest);

            if (actualResponse.GetReferenceResult.ErrorInfo != null)
            {
                _logHandler.WriteLog(actualResponse.GetReferenceResult.ErrorInfo.ErrorXML, LogSeverity.Error,
                                     LogCategory.BusinessComponent);
                _logHandler.WriteLog(actualResponse.GetReferenceResult.ErrorInfo.Description, LogSeverity.Error,
                                     LogCategory.BusinessComponent);
                _logHandler.WriteLog(actualResponse.GetReferenceResult.ErrorInfo.DetailedDescription, LogSeverity.Error,
                                     LogCategory.BusinessComponent);
            }

            Assert.IsNotNull(actualResponse.GetReferenceResult.OutputXml);

            var xmlDoc1 = new XmlDocument();
            xmlDoc1.LoadXml(actualResponse.GetReferenceResult.OutputXml);

            Assert.AreEqual(expectedResponsePolicyType, xmlDoc1.GetElementsByTagName("PolId")[0].InnerText);
        }
        public void GetReference_ErrorReturned()
        {
            // Assign
            IPolicyService subscribeService = new PolicyServiceClient();
            var getReferenceRequest = new GetReferenceRequest();

            // Act
            var actualGetReferenceResponse = subscribeService.GetReference(getReferenceRequest);

            // Assert
            Assert.IsNotNull(actualGetReferenceResponse.GetReferenceResult.ErrorInfo);
        }
        public void UpdatePolicy_Fail()
        {
            // Assign
            IPolicyService subscribeService = new PolicyServiceClient();

            var policyContract = new PolicyContract
            {
                UnitPsu = "AGY",
                PolTy = "NONMARINE",
                EntSt = "PARTIAL",
                InsdNm = "- N/A",
                InsdId = 182396,
                PolDsc = "Unit Test Submission",
                Uwr = "AED",
                DOM = "AD",
                BkrSeqId = 822,
                CtcNm = "ALLAN MURRAY",
                IncpDt = "20130628",
                ExpyDt = "20140628",
                AccYr = "2013",
                SettDueDt = "20130628",
                Brokerage = 1,
                DeclineReason = null,
                COB = "AD",
                MOA = "FA",
                NonLonBkr = null,
                OrigOff = "LON",
                FacyPolId = null,
                RenPolId = null,
                PolId = null,
                LmtCcy = "USD",
                LmtAmt = null,
                ExsCcy = "USD",
                ExsAmt = null,
                BindSt = "PRE",
                PctgAmt = "AMT",
                PricingCcy = "USD",
                Method = "UW",
                TechPrm = null,
                BenchPrm = null,
                Status = "SUBMITTED",
                TimeStamp = null,
                BkrPsu = "AAA",
                BkrNo = "???",
                TechPmTy = "TechPm"
            };

            var updatePolicyRequest = new UpdatePolicyRequest { objPolicyContract = policyContract };

            // Act
            var actualResponse = subscribeService.UpdatePolicy(updatePolicyRequest);

            // Assert
            Assert.IsNotNull(actualResponse.UpdatePolicyResult.ErrorInfo);
        }
        public void CreateQuote_Fail()
        {
            // Assign

            IPolicyService subscribeService = new PolicyServiceClient();
            var policyContract = new PolicyContract
                {
                    UnitPsu = "",
                    PolTy = "",
                    EntSt = "",
                    InsdNm = "",
                    InsdId = 0,
                    PolDsc = "",
                    Uwr = "",
                    DOM = "",
                    BkrSeqId = 0,
                    CtcNm = "",
                    IncpDt = "",
                    ExpyDt = "",
                    AccYr = "",
                    SettDueDt = "",
                    Brokerage = 0,
                    DeclineReason = "",
                    COB = "",
                    MOA = "",
                    NonLonBkr = "",
                    OrigOff = "",
                    FacyPolId = "",
                    RenPolId = "",
                    PolId = "",
                    LmtCcy = "",
                    LmtAmt = null,
                    ExsCcy = "",
                    ExsAmt = null,
                    BindSt = "",
                    PctgAmt = "",
                    PricingCcy = "",
                    Method = "",
                    TechPrm = null,
                    BenchPrm = null,
                    Status = "",
                    TimeStamp = null,
                    BkrPsu = "",
                    BkrNo = "",
                    TechPmTy = ""
                };

            var request = new CreateQuoteRequest { objPolicyContract = policyContract };

            // Act
            var actualResponse = subscribeService.CreateQuote(request);

            // Assert
            Assert.IsNotNull(actualResponse.CreateQuoteResult.ErrorInfo);
        }
        public void CreateQuote_ExpectedException()
        {
            // Assign
            long actualTimeStamp = 0;

            IPolicyService subscribeService = new PolicyServiceClient();
            var policyContract = new PolicyContract();
            
            var request = new CreateQuoteRequest { objPolicyContract = policyContract };

            // Act
            var actualResponse = subscribeService.CreateQuote(request);

            // Assert
            Assert.IsNotNull(actualResponse.CreateQuoteResult.ErrorInfo);
        }