Exemplo n.º 1
0
        public void RansomNoteCanBeFormedWords_CanNoteBeFormed_ReturnsFalse()
        {
            string note = "  they  to  can ";
            string mag  = "        two    systems are talking to each other, they always need to specify what encoding      ";

            Assert.IsFalse(RansomNote.RansomNoteCanBeFormedWords(note, mag));
        }
Exemplo n.º 2
0
        public void TestCase3()
        {
            //Arrange
            string fileName       = "input09.txt";
            string path           = Path.Combine(Environment.CurrentDirectory, @"DictionariesAndHashmaps\Data\RansomNote\input\", fileName);
            String input          = File.ReadAllText(path);
            var    inputRows      = input.Split('\n');
            int    magazineLength = int.Parse(inputRows[0].Trim().Split(' ')[0]);
            int    noteLength     = int.Parse(inputRows[0].Trim().Split(' ')[1]);

            string[] magazine   = inputRows[1].Split(' ');
            string[] ransomNote = inputRows[2].Split(' ');

            string fileNameOutput = "output09.txt";

            path = Path.Combine(Environment.CurrentDirectory, @"DictionariesAndHashmaps\Data\RansomNote\output\", fileNameOutput);
            String output = File.ReadAllText(path);


            //Act
            var result = RansomNote.CheckMagazine(magazine, ransomNote);

            //Assert
            Assert.AreEqual(result, output);
        }
Exemplo n.º 3
0
        public void DataDrivenTest(string ransomNote, string magazine, bool canConstructExpected)
        {
            var  sut          = new RansomNote();
            bool canConstruct = sut.CanConstruct(ransomNote, magazine);

            canConstruct.Should().Be(canConstructExpected, $"{ransomNote} in {magazine}");
        }
Exemplo n.º 5
0
        public void RansomNoteCanBeFormedChars_CanBeFormed_ReturnsTrue()
        {
            string note = "aabb";
            string mag  = "aaabb";

            Assert.IsTrue(RansomNote.RansomNoteCanBeFormedChars(note, mag));
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            string[] m      = { "two", "times", "three", "is", "not", "four" };
            string[] n      = { "two", "times", "two", "is", "four" };
            string   result = RansomNote.Solution(m, n);

            Console.WriteLine(result);
        }
Exemplo n.º 7
0
        public void RansomeNoteTestMethod()
        {
            RansomNote ransomNote = new RansomNote();

            Assert.AreEqual(false, ransomNote.CanConstruct("a", "b"));
            Assert.AreEqual(false, ransomNote.CanConstruct("a", "b"));
            Assert.AreEqual(true, ransomNote.CanConstruct("aa", "aab"));
        }
Exemplo n.º 8
0
        public void Test2()
        {
            string[] m        = { "two", "times", "three", "is", "not", "four" };
            string[] n        = { "two", "times", "two", "is", "four" };
            string   expected = "No";
            string   result   = RansomNote.Solution(m, n);

            Assert.Equal(expected, result);
        }
Exemplo n.º 9
0
        public void Test3()
        {
            string[] m        = { "ive", "got", "a", "lovely", "bunch", "of", "coconuts" };
            string[] n        = { "ive", "got", "some", "coconuts" };
            string   expected = "No";
            string   result   = RansomNote.Solution(m, n);

            Assert.Equal(expected, result);
        }
Exemplo n.º 10
0
        public void Test1()
        {
            string[] m        = { "give", "me", "one", "grand", "today", "night" };
            string[] n        = { "give", "one", "grand", "today" };
            string   expected = "Yes";
            string   result   = RansomNote.Solution(m, n);

            Assert.Equal(expected, result);
        }
Exemplo n.º 11
0

        
Exemplo n.º 12
0

        
Exemplo n.º 13
0

        
Exemplo n.º 14
0

        
Exemplo n.º 15
0

        
Exemplo n.º 16
0
        public void Test1()
        {
            var result = RansomNote.checkMagazine(
                new[] { "give", "me", "one", "grand", "today", "night" },
                new[] { "give", "one", "grand", "today" });

            Assert.True(result);

            result = RansomNote.checkMagazine(
                new[] { "not", "enough", "Words" },
                new[] { "not", "enough", "words" });

            Assert.False(result);
        }
Exemplo n.º 17
0
        public void RansomNoteTest4()
        {
            string[] magazine = { "give",
                                  "me",
                                  "one",
                                  "grand",
                                  "today",
                                  "night" };

            string[] note = { "Give",
                              "one",
                              "grand",
                              "today" };

            string result = RansomNote.checkMagazine(magazine, note);

            Assert.AreEqual("No", result);
        }
Exemplo n.º 18
0
        public void RansomNoteTest5()
        {
            string[] magazine = { "there", "was",  "a",    "bird",    "in",   "my",      "bedroom",
                                  "and",   "I",    "must", "tell",    "you",  "without",
                                  "a",     "word", "of",   "doubt",   "that", "the",
                                  "bird",  "is",   "the",  "biggest", "bird", "I",       "have",
                                  "ever",  "seen" };

            string[] note = { "the",
                              "bird",
                              "is",
                              "the",
                              "word" };

            string result = RansomNote.checkMagazine(magazine, note);

            Assert.AreEqual("Yes", result);
        }
Exemplo n.º 19
0
        public void Run()
        {
            PrintProblem();

            Console.WriteLine("words on magazine: number of words on note:");
            a = System.Array.ConvertAll(Console.ReadLine().Split(' '), aTemp => Convert.ToInt64(aTemp));
            Console.WriteLine("Magazine:");
            d = Console.ReadLine().Split(' ');
            Console.WriteLine("Note:");
            e = Console.ReadLine().Split(' ');

            string result = RansomNote.checkMagazine(d, e);

            Console.WriteLine();
            Console.WriteLine("Result:");
            Console.WriteLine(result);
            Console.ReadKey();
        }
Exemplo n.º 20
0
        public void RansomNoteTest2()
        {
            string[] magazine = { "two",
                                  "times",
                                  "three",
                                  "is",
                                  "not",
                                  "four" };

            string[] note = { "two",
                              "times",
                              "two",
                              "is",
                              "four" };

            string result = RansomNote.checkMagazine(magazine, note);

            Assert.AreEqual("No", result);
        }
Exemplo n.º 21
0
        public void RansomNoteTest3()
        {
            string[] magazine = { "ive",
                                  "got",
                                  "a",
                                  "lovely",
                                  "bunch",
                                  "of",
                                  "coconuts" };

            string[] note = { "ive",
                              "got",
                              "some",
                              "coconuts" };

            string result = RansomNote.checkMagazine(magazine, note);

            Assert.AreEqual("No", result);
        }
Exemplo n.º 22
0
 public RansomNoteTest()
 {
     _sut = new RansomNote();
 }