示例#1
0
        public void AddQuoteTest()
        {
            string id = Guid.NewGuid().ToString();

            Console.WriteLine("About to test adding a quote and saving to disk for ID: " + id);

            QuoteList target = new QuoteList(id);

            Assert.IsTrue(target.Quotes.Count == 0, "We have not added any quotes yet but the quotelist is full for ID: " + id);

            IQuote inQuote = GetTestingQuote();
            Console.WriteLine("About to add the following test quote: " + inQuote.ToString());
            target.AddQuote(inQuote);

            inQuote = GetTestingQuote();
            Console.WriteLine("About to add the following test quote: " + inQuote.ToString());
            target.AddQuote(inQuote);

            int numberOfQuotesToSave = target.Quotes.Count;
            target.Save();

            //Now test that we get this quote back:
            target = new QuoteList(id);
            Assert.IsTrue(target.Quotes.Count == numberOfQuotesToSave, "We added " + numberOfQuotesToSave + " quote(s) so this collection should contain the same number of quotes.");

            Console.WriteLine("Test was successful.");
        }
示例#2
0
        public void DeleteQuoteTest()
        {
            string id = Guid.NewGuid().ToString();

            Console.WriteLine("About to test adding a quote for ID: " + id);

            QuoteList target = new QuoteList(id);

            IQuote quoteToDeleteLater = GetTestingQuote();
            Console.WriteLine("Adding GUID: " + quoteToDeleteLater.Id);
            target.AddQuote(quoteToDeleteLater);

            //Add a few more...
            target.AddQuote(GetTestingQuote());
            target.AddQuote(GetTestingQuote());

            int quotesAdded = target.Quotes.Count;
            target.Save();

            Console.WriteLine("Verifying all quotes exist.");
            target = new QuoteList(id);
            Assert.IsTrue(target.Quotes.Count == quotesAdded, "This collection should contain " + quotesAdded + " quotes.");

            //Now delete the GUID above.
            Console.WriteLine("About to delete the quote: " + quoteToDeleteLater.Id);
            target.DeleteQuote(quoteToDeleteLater.Id);
            target.Save();

            target = new QuoteList(id);
            Assert.IsTrue(target.Quotes.Count == (quotesAdded - 1), "This collection should contain " + (quotesAdded - 1) + " quotes.");

            Console.WriteLine("Test was successful.");
        }