PageRenderTime 48ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/src/test/TimeTracker.UnitTests/Tasks/TimeEntryTasksSpecs/StopWorkItemSpecs/StopTimeIsLessThanStartTime.cs

https://github.com/jsmale/TimeTracker
C# | 64 lines | 59 code | 5 blank | 0 comment | 0 complexity | 9fb3ac4fe667fd54b84542a45a3a234e MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data.Linq;
  4. using System.Linq;
  5. using Microsoft.VisualStudio.TestTools.UnitTesting;
  6. using TimeTracker.DataAccess;
  7. using TimeTracker.Domain;
  8. using TimeTracker.DTO;
  9. using TimeTracker.Tasks;
  10. using Rhino.Mocks;
  11. namespace TimeTracker.UnitTests.Tasks.TimeEntryTasksSpecs.StopWorkItemSpecs
  12. {
  13. [TestClass]
  14. public class StopTimeIsLessThanStartTime : SpecificationBase<TimeEntryTasks, ITimeEntryTasks>
  15. {
  16. private DateTime stopTime;
  17. private Guid workItemId;
  18. private WorkItemTimeEntryDetails result;
  19. private Exception thrown;
  20. protected override void Given()
  21. {
  22. result = null;
  23. thrown = null;
  24. workItemId = Guid.NewGuid();
  25. var startTime = new DateTime(2010, 1, 2);
  26. stopTime = new DateTime(2010, 1, 1);
  27. IList<WorkItem> workItems = new List<WorkItem>
  28. {
  29. new WorkItem
  30. {
  31. Id = workItemId,
  32. TimeEntries = new EntitySet<TimeEntry>
  33. {
  34. new TimeEntry{StartTime = startTime}
  35. }
  36. }
  37. };
  38. GetMock<IRepository>().Stub(x => x.Query<WorkItem>())
  39. .Return(workItems.AsQueryable());
  40. }
  41. protected override void When()
  42. {
  43. try
  44. {
  45. result = CreateSut().StopWorkItem(workItemId, stopTime);
  46. }
  47. catch(Exception ex)
  48. {
  49. thrown = ex;
  50. }
  51. }
  52. [TestMethod]
  53. public void ShouldThrowException()
  54. {
  55. Assert.IsNotNull(thrown);
  56. Assert.AreEqual("Stop time may not be less than start time", thrown.Message);
  57. }
  58. }
  59. }