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."); }
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."); }
/// <summary> ///I commented the [TestMethod()] attribute because this is a utility that should not be used ///unless needed. ///</summary> //[TestMethod()] public void Utility_ResetQuoteIDs() { string id = "";//"ed32da6e-da85-477e-9b21-ddf131a532e8"; Console.WriteLine("About to reset all QuoteIDs for ID: " + id); QuoteList target = new QuoteList(id); foreach (IQuote quote in target.Quotes) { quote.Id = Guid.NewGuid().ToString(); Console.WriteLine("Reset quote: " + quote.ToString()); } target.Save(); Console.WriteLine("Reset was successful."); }