public void TesDeleteEvents_NoEventsAtAll() { FastEventsManager eventManager = new FastEventsManager(); int deletedEvents = eventManager.DeleteEventsByTitle("title"); Assert.AreEqual(0, deletedEvents); }
internal static void Main() { // FastEventsManager is faster than EventManager - bottleneck IEventsManager eventsManager = new FastEventsManager(); CommandProcessor commandProcessor = new CommandProcessor(eventsManager); // With StringBuider it's easier to view the output and it's around 10s faster than // printing every time the command's output - bottleneck StringBuilder output = new StringBuilder(); while (true) { string inputLine = Console.ReadLine(); if (inputLine == "End" || inputLine == null) { break; } try { Command commandToProcess = Command.Parse(inputLine); output.AppendLine(commandProcessor.ProcessCommand(commandToProcess)); } catch (ArgumentException argException) { Console.WriteLine(argException.Message); } } Console.Write(output.ToString()); }
public void TestDeleteEvents_Delete1CheckCaseSensitivity() { FastEventsManager eventManager = new FastEventsManager(); Event eventItem = new Event(); eventItem.Date = DateTime.ParseExact( "2001-01-01T10:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); eventItem.Title = "pArTy"; eventItem.Location = "nowhere"; eventManager.AddEvent(eventItem); int deletedEvents = eventManager.DeleteEventsByTitle("party"); Assert.AreEqual(1, deletedEvents); }
public void TestDeleteEvents_Delete2Of3() { FastEventsManager eventManager = new FastEventsManager(); Event eventItem1 = new Event(); eventItem1.Date = DateTime.ParseExact( "2001-01-01T10:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); eventItem1.Title = "party"; eventItem1.Location = "nowhere"; eventManager.AddEvent(eventItem1); Event eventItem2 = new Event(); eventItem2.Date = DateTime.ParseExact( "2001-01-01T10:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); eventItem2.Title = "no party"; eventManager.AddEvent(eventItem2); Event eventItem3 = new Event(); eventItem3.Date = DateTime.ParseExact( "2011-02-01T10:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); eventItem3.Title = "party"; eventItem3.Location = "Telerik"; eventManager.AddEvent(eventItem3); int deletedEvents = eventManager.DeleteEventsByTitle("party"); Assert.AreEqual(2, deletedEvents); }
public void TestListEvents_OneEventBeforeTheSearchedOne() { FastEventsManager eventManager = new FastEventsManager(); Event eventItem1 = new Event(); eventItem1.Date = DateTime.ParseExact( "2001-01-01T10:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); eventItem1.Title = "party"; eventItem1.Location = "nowhere"; eventManager.AddEvent(eventItem1); Event eventItem2 = new Event(); eventItem2.Date = DateTime.ParseExact( "2001-01-01T10:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); eventItem2.Title = "no party"; eventManager.AddEvent(eventItem2); Event eventItem3 = new Event(); eventItem3.Date = DateTime.ParseExact( "2000-02-01T10:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); eventItem3.Title = "C#"; eventItem3.Location = "Telerik"; eventManager.AddEvent(eventItem3); var eventsList = eventManager.ListEvents( DateTime.ParseExact( "2001-01-01T10:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture), 10); int eventsCount = eventsList.Count(); Assert.AreEqual(2, eventsCount); }
public void TestListEvents_NoEventsAtAll() { FastEventsManager eventManager = new FastEventsManager(); var eventsList = eventManager.ListEvents( DateTime.ParseExact( "2001-01-01T10:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture), 10); int eventsCount = eventsList.Count(); Assert.AreEqual(0, eventsCount); }
public void TestListEvents_List1() { FastEventsManager eventManager = new FastEventsManager(); Event eventItem = new Event(); eventItem.Date = DateTime.ParseExact( "2001-01-01T10:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); eventItem.Title = "party"; eventItem.Location = "nowhere"; eventManager.AddEvent(eventItem); var eventsList = eventManager.ListEvents( DateTime.ParseExact( "2001-01-01T10:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture), 10); int eventsCount = eventsList.Count(); Assert.AreEqual(1, eventsCount); }