Exemplo n.º 1
0
        public void LivingWithin100KmTest()
        {
            List <Customer> expected = new List <Customer>();
            List <Customer> actual   = CustomersToInvite.LivingWithin100Km(new IntercomCustomers());

            Assert.AreEqual(16, actual.Count, "Count within Range");
            int[] expectedIds = new int[16] {
                4, 5, 6, 8, 11, 12, 13, 15, 17, 23, 24, 26, 29, 30, 31, 39
            };
            for (int i = 0; i < 16; i++)
            {
                if (actual[i].Id != expectedIds[i])
                {
                    Assert.Fail(string.Format("Expected ID: {0}, Found: {1}", expectedIds[i], actual[i].Id));
                }
            }
        }
        private void DisplayCustomersWithinRange(string pathToJsonFile)
        {
            customerJsonFile.Text = pathToJsonFile;
            List <Customer> withinRange =
                CustomersToInvite.LivingWithin100Km(new CustomerDB(pathToJsonFile));

            if (withinRange.Count > 0)
            {
                customerList.DataSource = withinRange;
                customerList.ForeColor  = System.Drawing.Color.Black;
            }
            else
            {
                customerList.DataSource = new List <string>()
                {
                    "No customers found.",
                    "Have you selected a valid file containing potential customers?"
                };
                customerList.ForeColor = System.Drawing.Color.Red;
            }
        }