/// <summary>
        /// Evbent handler for the CMCD run
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cdcRun_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            // Start the CMCD
            if (!string.IsNullOrEmpty(cdcPath.Text) && (Directory.Exists(cdcPath.Text) || File.Exists(cdcPath.Text)))
            {
                currentSessionResults = CodeIterator.Run(cdcPath.Text, new CMCD());
                List <CMCDResults> list = new List <CMCDResults>();
                foreach (var result in currentSessionResults)
                {
                    list.Add(new CMCDResults()
                    {
                        Method1 = result.MethodA.MethodName,
                        File1   = result.MethodA.FileName,
                        Method2 = result.MethodB.MethodName,
                        File2   = result.MethodB.FileName,
                        Score   = result.Score
                    });
                }

                list = list.OrderBy(c => c.Score).ToList();

                dataGridView1.DataSource        = list;
                dataGridView1.Visible           = true;
                dataGridView1.CellContentClick += DataGridView1_CellContentClick;
            }
            else
            {
                MessageBox.Show("Invalid directory or file path.", "Error");
            }
            Cursor = Cursors.Arrow;
        }
Beispiel #2
0
        public void Validate_Type3_Test()
        {
            var currentPath = "../../../SampleCode/TypeValidationTests/Type3Tests/";

            // Act
            var cmcdResults = CodeIterator.Run(currentPath, comparer);

            Assert.IsTrue(cmcdResults.Count == 10);

            foreach (var result in cmcdResults)
            {
                if (string.CompareOrdinal(result.MethodA.MethodName, "DoubledSumFunctionWithLineSubtractions") == 0 ||
                    string.CompareOrdinal(result.MethodB.MethodName, "DoubledSumFunctionWithLineSubtractions") == 0 ||
                    string.CompareOrdinal(result.MethodA.MethodName, "DoubledSumFunctionWithLineAdditions") == 0 ||
                    string.CompareOrdinal(result.MethodB.MethodName, "DoubledSumFunctionWithLineAdditions") == 0)
                {
                    Assert.IsTrue(result.Score != 0, string.Format("Test failed for {0}, {1}. Expected Score should not be 0, Actual score = 0",
                                                                   result.MethodA, result.MethodB));
                }
                else
                {
                    Assert.IsTrue(result.Score == 0, string.Format("Test failed for {0}, {1}. Expected Score = 0, Actual score = {2}",
                                                                   result.MethodA.MethodName, result.MethodB.MethodName, result.Score));
                }
            }
        }
Beispiel #3
0
        public void Run_Self_Test()
        {
            // Arrange
            var currentPath = "../../../";

            // Act
            var cmcdResults = CodeIterator.Run(currentPath, comparer);

            // Assert
            Assert.IsTrue(cmcdResults.Any());
        }
Beispiel #4
0
        public void Run_UnitTests_Test()
        {
            // Arrange
            var currentPath = "../../../SampleCode/UnitTests/";

            // Act
            var cmcdResults = CodeIterator.Run(currentPath, comparer);

            // Assert
            Assert.IsTrue(cmcdResults.Any());
            Assert.AreEqual(6, cmcdResults.Count());
            Assert.AreEqual("RiddledWithDuplicates.cs", cmcdResults[0].MethodA.FileName);
        }
Beispiel #5
0
        public void Validate_Type4_Test()
        {
            var currentPath = "../../../SampleCode/TypeValidationTests/Type4Tests/";

            // Act
            var cmcdResults = CodeIterator.Run(currentPath, comparer);

            Assert.IsTrue(cmcdResults.Count == 3);

            foreach (var result in cmcdResults)
            {
                Assert.IsTrue(result.Score == 0, string.Format("Test failed for {0}, {1}. Expected Score = 0, Actual score = {2}",
                                                               result.MethodA.MethodName, result.MethodB.MethodName, result.Score));
            }
        }