コード例 #1
0
        public void TestResults()
        {
            string file = System.IO.Path.GetFullPath(@"..\..\..\Data\\data.csv");

            if (FileAccess.ValidateFormat(file))
            {
                string error = null;
                People_Class.ReadAllPeople(file, out error);

                List <string> expectedFirstNameList = new List <string>();
                expectedFirstNameList.AddRange(new string[] { "Iago Tieman", "Cordie Bleibaum", "Shandie Rowles", "Genny Seys", "Renault Millichap", "Shandie Rowles", "Iago Tieman", "Genny Seys", "Iago Tieman" });
                List <string> expectedAddressList = new List <string>();
                expectedAddressList.AddRange(new string[] { "42 Basil Park", "74584 Moose Parkway", "81075 Killdeer Road", "2 Nova Circle", "32 Butterfield Drive" });

                List <string> actualFirstNameList = People_Class.GetFullNameList();
                List <string> actualAddressList   = People_Class.GetAddressList();

                CollectionAssert.AreEqual(expectedFirstNameList, actualFirstNameList);
                CollectionAssert.AreEqual(expectedAddressList, actualAddressList);
            }
        }
コード例 #2
0
        //Populate the count of the items passed from the csv file, populate to grid and ask to open file
        private void btnPopularity_Click(object sender, EventArgs e)
        {
            var firstNameSurnameCount = Sorter.GetWordCountDescendingOrder(People_Class.GetFullNameList());
            var names = (from row in firstNameSurnameCount select new { Name = row.Key, Count = row.Value });

            dataGridView1.DataSource = names.ToList();

            string error = null;

            Helpers.FileAccess.WriteAllLines(_file1, names.Select(x => x.Name + "\t" + x.Count), out error);

            if (string.IsNullOrEmpty(error))
            {
                toolStripStatusLabel.Text = "File with Names Count generated";
                if (MessageBox.Show("File generated succesfully, would you like to open the file now?", "Open File", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    Process.Start("notepad.exe", _file1);
                }
            }
            else
            {
                toolStripStatusLabel.Text = error;
            }
        }