Ejemplo n.º 1
0
        public void PolicyCPayoutWithoutDescretionaryBonusViaFactoryTest()
        {
            String        myline        = "C100003,1/01/1992,13000,N,1000,42";
            PolicyData    NewPolicyData = new PolicyData(myline);
            PolicyFactory factory       = new ConcretePolicyFactory();
            Policy        policy        = factory.GetPolicy(NewPolicyData.GetPolicyType(), NewPolicyData);

            Assert.Equal((decimal)17167.8, policy.GetMaturityPayout());
        }
Ejemplo n.º 2
0
        public void PolicyCPayoutWithDescretionaryBonusViaFactoryTest()
        {
            String        myline        = "C100003,1/01/1990,17000,Y,3000,46";
            PolicyData    NewPolicyData = new PolicyData(myline);
            PolicyFactory factory       = new ConcretePolicyFactory();
            Policy        policy        = factory.GetPolicy(NewPolicyData.GetPolicyType(), NewPolicyData);

            Assert.Equal((decimal)27462.6, policy.GetMaturityPayout());
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            //if the variable is in grey its not being used so you can remove them
            string path = "";

            path = System.AppContext.BaseDirectory;
            string Filepath = path + @"\MaturityData.csv";

            List <string>     lines          = File.ReadAllLines(Filepath).ToList();
            List <PolicyData> ListOfAccounts = new List <PolicyData>();

            foreach (var line in lines)
            {
                PolicyData NewPolicyData = new PolicyData(line);
                ListOfAccounts.Add(NewPolicyData);
            }

            List <Policy> ListOfPolicys = new List <Policy>();

            foreach (PolicyData account in ListOfAccounts)

            {
                PolicyFactory factory = new ConcretePolicyFactory();
                Policy        policy  = factory.GetPolicy(account.GetPolicyType(), account);
                ListOfPolicys.Add(policy);
            }


            IDictionary <string, decimal> PolicyNumberAndPayout = new Dictionary <string, decimal>();

            foreach (Policy acco in ListOfPolicys)
            {
                PolicyNumberAndPayout.Add(acco.PolicyNumber, acco.GetMaturityPayout());
            }

            path = System.AppContext.BaseDirectory;
            string jsonOutPut = JsonSerializer.Serialize(PolicyNumberAndPayout);

            System.IO.File.WriteAllText(path + @"\jsonInsurancePolicyFile.json", jsonOutPut);
        }