コード例 #1
0
        public void Test_Get_Success()
        {
            var controller = new quotesController();

            var actual = controller.Get(0);

            Assert.That(actual.Value.ID, Is.EqualTo(0));
            Assert.That(actual.Value.Quote, Is.EqualTo("To be or not to be."));
            Assert.That(actual.Value.Author, Is.EqualTo("William Shakespeare"));

            actual = controller.Get(1);
            Assert.That(actual.Value.ID, Is.EqualTo(1));
            Assert.That(actual.Value.Quote, Is.EqualTo("So many books, so little time."));
            Assert.That(actual.Value.Author, Is.EqualTo("Frank Zappa"));

            actual = controller.Get(3);
            Assert.That(actual.Value.ID, Is.EqualTo(3));
            Assert.That(actual.Value.Quote, Is.EqualTo("If you tell the truth, you don't have to remember anything."));
            Assert.That(actual.Value.Author, Is.EqualTo("Mark Twain"));

            actual = controller.Get(6);
            Assert.That(actual.Value.ID, Is.EqualTo(6));
            Assert.That(actual.Value.Quote, Is.EqualTo("The man who does not read has no advantage over the man who cannot read."));
            Assert.That(actual.Value.Author, Is.EqualTo("Mark Twain"));
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: trantruc44/CS480B
        private static void Main(string[] args)
        {
            var controller = new quotesController();
            var actual2    = controller.Get();

            Console.WriteLine(actual2.Value);

            IEnumerable <string>        quotesList = new string[] { "quote1", "quote2", "quote3", "quote4", "quote5", "quotes6" };
            SimpleRandomQuoteProvider   object1    = new SimpleRandomQuoteProvider();
            DefaultRandomQuoteGenerator object2    = new DefaultRandomQuoteGenerator(quotesList);

            if (args.Length > 0)
            {
                Console.WriteLine("Number of quotes wanted (enter a number):" + args[0]);
                object1.printNumberofQuotes(Convert.ToInt64(args[0]));
                object2.printNumberofQuotes(Convert.ToInt64(args[0]));
            }

            else
            {
                Console.WriteLine("No command line arguments found.");
            }

            Console.ReadKey();

            // test code to see if simpleRandomQuoteProvider and DefaultRandomQuoteGenerator works
            object1.printNumberofQuotes(3);
            Console.WriteLine("---------------------");
            object2.printNumberofQuotes(4);
        }
コード例 #3
0
        public void Test_Get_Success2()
        {
            var controller = new quotesController();
            var actual     = controller.Get();

            Assert.That(actual.Value.Length, Is.EqualTo(7));
            Assert.That(actual.Value.GetValue(0), Is.EqualTo(quotesController.quotesObjects[0]));
            Assert.That(actual.Value.GetValue(3), Is.EqualTo(quotesController.quotesObjects[3]));
            Assert.That(actual.Value.GetValue(5), Is.EqualTo(quotesController.quotesObjects[5]));
            Assert.That(actual.Value, Is.EqualTo(quotesController.quotesObjects));
        }
コード例 #4
0
        public void Test_Get_2()
        {
            IEnumerable <string> quoteList = System.IO.File.ReadLines(@"C:\Users\drayl20\source\repos\PleaseWork480b\quotable\quotable.core\quotesFile");

            DefaultRandomQuoteGenerator generator  = new DefaultRandomQuoteGenerator(quoteList);
            quotesController            controller = new quotesController(generator);

            var actual = controller.Get(2.ToString());



            //String instead of object
            Assert.That(actual.Value.id, Is.EqualTo(2.ToString()));
            Assert.That(actual.Value.quote, Is.EqualTo("Anything can happen in life, especially nothing"));
            Assert.That(actual.Value.author, Is.EqualTo("Michel Houellebecq"));
        }
コード例 #5
0
        public void Test_Get_1()
        {
            IEnumerable <string> quoteList = System.IO.File.ReadLines(@"C:\Users\drayl20\source\repos\PleaseWork480b\quotable\quotable.core\quotesFile");

            DefaultRandomQuoteGenerator generator  = new DefaultRandomQuoteGenerator(quoteList);
            quotesController            controller = new quotesController(generator);

            var actual = controller.Get(1.ToString());



            //String instead of object
            Assert.That(actual.Value.id, Is.EqualTo(1.ToString()));
            Assert.That(actual.Value.quote, Is.EqualTo("Never regret anything that made you smile"));
            Assert.That(actual.Value.author, Is.EqualTo("Mark Twain"));
        }
コード例 #6
0
        public void Test_Get_0()
        {
            IEnumerable <string> quoteList = System.IO.File.ReadLines(@"C:\Users\drayl20\source\repos\PleaseWork480b\quotable\quotable.core\quotesFile");

            DefaultRandomQuoteGenerator generator  = new DefaultRandomQuoteGenerator(quoteList);
            quotesController            controller = new quotesController(generator);

            var actual = controller.Get(0.ToString());



            //String instead of object
            Assert.That(actual.Value.id, Is.EqualTo(0.ToString()));
            Assert.That(actual.Value.quote, Is.EqualTo("You can get straight A's and still flunk life"));
            Assert.That(actual.Value.author, Is.EqualTo("Walker Percy"));
        }
コード例 #7
0
        public void Test_GetAll()
        {
            IEnumerable <string>        quoteList  = System.IO.File.ReadLines(@"C:\Users\drayl20\source\repos\PleaseWork480b\quotable\quotable.core\quotesFile");
            DefaultRandomQuoteGenerator generator  = new DefaultRandomQuoteGenerator(quoteList);
            quotesController            controller = new quotesController(generator);



            int sizeOfList  = 0;
            int count       = 0;
            int actualCount = 0;
            var actual      = controller.Get();

            foreach (QuotableData quote in actual.Value)
            {
                sizeOfList++;
                if (quote.quote == generator.RetrieveQuoteById(count.ToString()) && quote.author == generator.RetrieveAuthorById(count.ToString()))
                {
                    actualCount++;
                }
                count++;
            }
            Assert.AreEqual(actualCount, sizeOfList);
        }
コード例 #8
0
        public void Test()
        {
            // arrange
            var    generator      = new quotesController();
            int    index          = 4;
            int    expectedID     = 4;
            string expectedQuote  = "Without music, life would be a mistake.";
            string expectedAuthor = "Friedrich Nietzsche";

            // act
            var actual = generator.Get(index);

            // assert
            Assert.AreEqual(expectedID, actual.Value.ID);
            Assert.AreEqual(expectedQuote, actual.Value.Quote);
            Assert.AreEqual(expectedAuthor, actual.Value.Author);

            // arrange
            index          = 6;
            expectedID     = 6;
            expectedQuote  = "The man who does not read has no advantage over the man who cannot read.";
            expectedAuthor = "Mark Twain";

            // act
            actual = generator.Get(index);

            // assert
            Assert.AreEqual(expectedID, actual.Value.ID);
            Assert.AreEqual(expectedQuote, actual.Value.Quote);
            Assert.AreEqual(expectedAuthor, actual.Value.Author);


            // arrange
            index          = 0;
            expectedID     = 0;
            expectedQuote  = "To be or not to be.";
            expectedAuthor = "William Shakespeare";

            // act
            actual = generator.Get(index);

            // assert
            Assert.AreEqual(expectedID, actual.Value.ID);
            Assert.AreEqual(expectedQuote, actual.Value.Quote);
            Assert.AreEqual(expectedAuthor, actual.Value.Author);

            // arrange
            index          = 5;
            expectedID     = 5;
            expectedQuote  = "We accept the love we think we deserve.";
            expectedAuthor = "Stephen Chbosky";

            // act
            actual = generator.Get(index);

            // assert
            Assert.AreEqual(expectedID, actual.Value.ID);
            Assert.AreEqual(expectedQuote, actual.Value.Quote);
            Assert.AreEqual(expectedAuthor, actual.Value.Author);

            // arrange
            index          = 2;
            expectedID     = 2;
            expectedQuote  = "Be the change you wish in the world.";
            expectedAuthor = "Mahatma Gandhi";

            // act
            actual = generator.Get(index);

            // assert
            Assert.AreEqual(expectedID, actual.Value.ID);
            Assert.AreEqual(expectedQuote, actual.Value.Quote);
            Assert.AreEqual(expectedAuthor, actual.Value.Author);
        }