示例#1
0
        public ActionResult Index()
        {
            string settledFilePath   = Server.MapPath("~/Content/Files/Settled.csv");
            string unsettledFilePath = Server.MapPath("~/Content/Files/Unsettled.csv");

            List <CustomerData> settledData   = ParseCsv(settledFilePath, ",").ToList();
            List <CustomerData> unsettledData = ParseCsv(unsettledFilePath, ",").ToList();


            var output = new List <CustomerViewModel>();

            foreach (var unsettledCustomer in unsettledData)
            {
                var settledCustomerData   = settledData.Where(c => c.CustomerName == unsettledCustomer.CustomerName).ToList();
                var unsettledCustomerData = unsettledData.Where(c => c.CustomerName == unsettledCustomer.CustomerName).ToList();

                var crm = new CustomerRiskAssesmentManager(unsettledCustomer.CustomerName, unsettledCustomer.Event, settledCustomerData, unsettledCustomerData);

                var vm = new CustomerViewModel(unsettledCustomer, crm);

                output.Add(vm);
            }


            return(View(output));
        }
        public void WhenCustomerIsNotCurrentWinningOnRiskAmount()
        {
            // arrange
            List <CustomerData> unsettledData = new List <CustomerData>()
            {
                new CustomerData {
                    CustomerName = "Karlo", Event = "Event1", Participant = "Participant1", Stake = 100, Win = 100
                },
                new CustomerData {
                    CustomerName = "Karlo", Event = "Event1", Participant = "Participant1", Stake = 100, Win = 200
                },
                new CustomerData {
                    CustomerName = "Karlo", Event = "Event1", Participant = "Participant1", Stake = 100, Win = 300
                },
            };

            var crm = new CustomerRiskAssesmentManager("Karlo", "Event1", new List <CustomerData>(), unsettledData);

            Assert.IsFalse(crm.IsCurrentWinningOnRiskAmount);
        }
        public void WhenCustomerIsUnusualRateWinner()
        {
            // arrange
            List <CustomerData> settledData = new List <CustomerData>()
            {
                new CustomerData {
                    CustomerName = "Karlo", Event = "Event1", Participant = "Participant1", Stake = 100, Win = 100
                },
                new CustomerData {
                    CustomerName = "Karlo", Event = "Event1", Participant = "Participant1", Stake = 100, Win = 100
                },
                new CustomerData {
                    CustomerName = "Karlo", Event = "Event1", Participant = "Participant1", Stake = 100, Win = 100
                },
            };

            var crm = new CustomerRiskAssesmentManager("Karlo", "Event1", settledData, new List <CustomerData>());

            Assert.IsTrue(crm.IsUnusualRateWinner);
        }
        public void WhenCurrentStakeIsThirtyTimesHigherThanAverage()
        {
            // arrange
            List <CustomerData> settledData = new List <CustomerData>()
            {
                new CustomerData {
                    CustomerName = "Karlo", Event = "Event1", Participant = "Participant1", Stake = 100, Win = 100
                },
                new CustomerData {
                    CustomerName = "Karlo", Event = "Event1", Participant = "Participant1", Stake = 100, Win = 100
                },
            };
            List <CustomerData> unsettledData = new List <CustomerData>()
            {
                new CustomerData {
                    CustomerName = "Karlo", Event = "Event1", Participant = "Participant1", Stake = 3001, Win = 1000
                },
            };

            var crm = new CustomerRiskAssesmentManager("Karlo", "Event1", settledData, unsettledData);

            Assert.IsTrue(crm.IsCurrentStakeThirtyTimesHigherThanAverage);
        }