public void HandleParcel(Parcel parcel) { IParcelHandler handler = new InsuranceHandler(); handler.SetNext(new PackagingHandler()); handler.Handle(parcel); }
static void Main(string[] args) { //Izveidot Clientu objektu //Izvēlēties Produkta ID //izdomāt test piemēru , kā izsaukt getprice metodi InsuranceHandler insuranceHandler = new InsuranceHandler(); ClientRepository clientRepository = new ClientRepository(); Client clientsClient = clientRepository.GetClientBySsn("121290-11233"); //insuranceHandler.GetPrice(client: clientsClient, productId: 1); //salīdzināt iegūto rezultātu decimal premiumResult = insuranceHandler.GetPrice(client: clientsClient, productId: 1); Console.WriteLine(premiumResult == 50); premiumResult = insuranceHandler.GetPrice(client: clientsClient, productId: 2); Console.WriteLine(premiumResult == 40); Console.ReadKey(); // atrod polisi, kas tika izveidota GetPrice metodes lika //parbauda, vai stuss ir draft // izsauc metodi buyinsurance, //atrod polisi, parbauda vai statuss ir active //pietrukst: // 1. getprice metode jaatgriez policy tips // 2. test piemera cenu jaizgust no polises }
public IHandler <Parcel, ProcessorResult> Create() { var handler = new InsuranceHandler(); handler.SetNext(new MailHandler()) .SetNext(new RegularHandler()) .SetNext(new HeavyHandler()); return(handler); }
static void Main(string[] args) { //Izveidot Clientu objektu //Izvēlēties Produkta ID //izdomāt test piemēru , kā izsaukt getprice metodi InsuranceHandler insuranceHandler = new InsuranceHandler(); ClientRepository clientRepository = new ClientRepository(); ProductRepository productRepository = new ProductRepository(); // Read client Name // string name; Console.WriteLine("Please enter one of clients names -> Anna or Juris or Zinta"); string name = Console.ReadLine(); // Console.WriteLine(name); // Console.WriteLine("Please enter product id -> 1 or 2 or 3"); Client clientsClient = clientRepository.GetClientByName(name); // Product product = productRepository.GetProductById(id: 1); //if (clientsClient != null) //{ // return clientsClient; // Console.WriteLine(" Your seleted clients name is {0} and surname is {1}", clientsClient.Name, clientsClient.Surname); //} //else //{ // // throw new ApplicationException("Policy with "+ policyNumber +" not found"); // throw new ApplicationException($"Client with {name} not found"); //} Console.WriteLine(" Your seleted client's name - '{0}' and surname - '{1}' and SSN - '{2}' and Address -'{3}'", clientsClient.Name, clientsClient.Surname, clientsClient.SocialSecurityNumber, clientsClient.Address); Console.WriteLine("************************************************************************************************ "); Console.WriteLine("Please add Product id -> 1 or 2 or 3"); string id = Console.ReadLine(); Product product = productRepository.GetProductById(id: id); // Client clientsClient = clientRepository.GetClientBySsn("121290-11233"); //insuranceHandler.GetPrice(client: clientsClient, productId: 1 ); //salīdzināt iegūto rezultātu decimal premiumResult = insuranceHandler.GetPrice(client: clientsClient, productId: product); if (product.ProductId == "1") { // decimal premiumResult = insuranceHandler.GetPrice(client: clientsClient, productId: product); //product = productRepository.GetProductById(id: "1"); Console.WriteLine(" ************** Unit Test Nr 1 ******************** "); Console.WriteLine("Verify that Client with SSN = {0} price for product {2} is 20 -> {1}", clientsClient.SocialSecurityNumber, premiumResult == 20, product.ProductName); } if (product.ProductId == "2") { //Product product2 = productRepository.GetProductById(id: "2"); Console.WriteLine(" ************** Unit Test Nr 2 ******************** "); Console.WriteLine("Verify that Client with SSN = {0} price for product {2} is 100 -> {1}", clientsClient.SocialSecurityNumber, premiumResult == 100, product.ProductName); } if (product.ProductId == "3") { Console.WriteLine(" ************** Unit Test Nr 3 ******************** "); Console.WriteLine("Verify that Client with SSN = {0} price for product {2} is 300 -> {1}", clientsClient.SocialSecurityNumber, premiumResult == 300, product.ProductName); } premiumResult = insuranceHandler.GetPrice(client: clientsClient, productId: product); //product = productRepository.GetProductById(id: "1"); // Console.WriteLine(" ************** Unit Test Nr 1 ******************** "); // Console.WriteLine("Verify that Client with SSN = {0} price for product {2} is 20 -> {1}",clientsClient.SocialSecurityNumber, premiumResult == 20, product.ProductName); //premiumResult = insuranceHandler.GetPrice(client: clientsClient, productId: "2"); //Product product2 = productRepository.GetProductById(id: "2"); //Console.WriteLine(" ************** Unit Test Nr 2 ******************** "); //Console.WriteLine("Verify that Client with SSN = {0} price for product {2} is 100 -> {1}", clientsClient.SocialSecurityNumber, premiumResult == 100, product2.ProductName); //premiumResult = insuranceHandler.GetPrice(client: clientsClient, productId: "3"); //Product product1 = productRepository.GetProductById(id: "3"); //Console.WriteLine(" ************** Unit Test Nr 3 ******************** "); //Console.WriteLine("Verify that Client with SSN = {0} price for product {2} is 300 -> {1}", clientsClient.SocialSecurityNumber, premiumResult == 300, product1.ProductName); // atrod polisi, kas tika izveidota GetPrice metodes lika // string policyNumber = insuranceHandler.GetPolicy(client: clientsClient, productId: product); // Console.WriteLine(" Policy Number is {0} " , policyNumber); Console.ReadKey(); //parbauda, vai statuss ir draft // izsauc metodi buyinsurance, //atrod polisi, parbauda vai statuss ir active //pietrukst: // 1. getprice metode jaatgriez policy tips // 2. test piemera cenu jaizgust no polises }
public InsuranceController(InsuranceHandler insuranceHandler, IInsuranceRepository iInsuranceRepository) { _insuranceHandler = insuranceHandler; _iInsuranceRepository = iInsuranceRepository; }
public void BeforeEachTest() { _sut = new InsuranceHandler(); }
static void Main(string[] args) { InsuranceHandler insuranceHandler = new InsuranceHandler(); ClientRepository clientRepository = new ClientRepository(); ProductRepository productRepository = new ProductRepository(); Console.WriteLine("Please enter one of client's names -> Anna or Juris or Zinta"); Console.WriteLine(" "); string name = Console.ReadLine(); Client clientsClient = clientRepository.GetClientByName(name); Console.WriteLine($"You selected Client is -> {clientsClient.Name}, {clientsClient.Surname}, {clientsClient.SocialSecurityNumber}, {clientsClient.Sex}, {clientsClient.Address}"); Console.WriteLine(" "); Console.WriteLine("Please enter product id -> 1 or 2 or 3"); Console.WriteLine(" "); string id = Console.ReadLine(); Product product = productRepository.GetProductById(id: id); Console.WriteLine($"Your selected Product is {product.ProductName}, cost -> {product.Premium}"); Console.WriteLine(" "); decimal premiumResult = insuranceHandler.GetPrice(client: clientsClient, productId: product); //Console.WriteLine("Your selected Product Premium is -> {0}", premiumResult); string policyNumber = insuranceHandler.GetPolicy(client: clientsClient, productId: product); //Console.WriteLine("Your Policy number is -> {0}", policyNumber); Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "); Console.WriteLine("OFFER: -> {0}'s {1} Policy Premium will be {2} ", name, product.ProductName, premiumResult); Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "); Console.WriteLine(" "); Policy policy = insuranceHandler.GetPolicyData(client: clientsClient, productId: product); //Console.WriteLine($"Policy start date = {policy.StartDate}, end date = {policy.EndDate}, state = {policy.State}, client = {policy.Client}"); Console.WriteLine("If you would like to buy this Policy , then write -> Y "); Console.WriteLine(" "); string answer = Console.ReadLine(); if (answer == "Y") { //BuyInsurance will change state to Active and call SavePolicy method Policy policy1 = insuranceHandler.BuyInsurance(client: clientsClient, productId: product); //Policy presentation Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "); Console.WriteLine($"Your client '{clientsClient.Name.ToUpper()} {clientsClient.Surname.ToUpper()}' bought '{product.ProductName}' Policy and Policy details are:"); Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "); Console.WriteLine($"Policy Number = {policy1.PolicyNumber}, "); Console.WriteLine($"Start date = {policy1.StartDate}"); Console.WriteLine($"End date = {policy1.EndDate}"); Console.WriteLine($"client name = {policy1.Client}"); Console.WriteLine($"State = {policy1.State.ToUpper()}"); // Console.WriteLine($"client = {policy1.Client}, State = {policy1.State}, Start date = {policy1.StartDate}, End date = {policy1.EndDate}"); Console.ReadKey(); } else { Console.WriteLine("See you next time!"); } Console.ReadKey(); //parbauda, vai stuss ir draft // izsauc metodi buyinsurance, //atrod polisi, parbauda vai statuss ir active //pietrukst: // 1. getprice metode jaatgriez policy tips // 2. test piemera cenu jaizgust no polises }