コード例 #1
0
        public void EmptystringISSamaAsEmptyString()
        {
            DuplicateFounder duplicateFounder = new DuplicateFounder();

            Assert.IsFalse(duplicateFounder.Same(string.Empty, "a"));
            Assert.IsTrue(duplicateFounder.Same("a", "a"));
            Assert.IsFalse(duplicateFounder.Same("a", "b"));
            Assert.IsTrue(duplicateFounder.Same("ab", "bc"));
            Assert.IsTrue(duplicateFounder.Same("abd", "bcd"));

            var lines = File.ReadAllLines("dataset2.txt");

            for (var index = 0; index < lines.Length; index++)
            {
                string s = lines[index];
                for (var j = index + 1; j < lines.Length; j++)
                {
                    var d = duplicateFounder.SameChar(s, lines[j]);
                    if (d.Count() > 0)
                    {
                        Assert.AreEqual(new string(d.ToArray()), "");
                        break;
                    }
                }
            }
        }
コード例 #2
0
        public void ShoouldRetun1When1TripleChar()
        {
            var i = "aaadferb";
            DuplicateFounder duplicateFounder = new DuplicateFounder();

            Assert.AreEqual(duplicateFounder.FindOccurence(i, 3), 1);
        }
コード例 #3
0
        public void CumpyeCheckSum()
        {
            var i = File.ReadAllLines("dataset2.txt");

            DuplicateFounder duplicateFounder = new DuplicateFounder();

            Assert.AreEqual(duplicateFounder.CumputeCheckSum(i), 12);
        }
コード例 #4
0
        public void ShoouldRetunZeroWhenInputIsEmptyOrNoDuplicate()
        {
            var i = string.Empty;
            DuplicateFounder duplicateFounder = new DuplicateFounder();

            Assert.IsTrue(duplicateFounder.FindOccurence(i, 2) == 0);
            i = "abc";
            Assert.IsTrue(duplicateFounder.FindOccurence(i, 2) == 0);
        }