PageRenderTime 59ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 1ms

/Main/FluentAssertions.Specs/FluentDateTimeSpecs.cs

http://fluentassertions.codeplex.com
C# | 211 lines | 98 code | 29 blank | 84 comment | 0 complexity | c7c178737a1844188c5a550ef75bd141 MD5 | raw file
  1. using System;
  2. #if WINRT
  3. using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
  4. #else
  5. using Microsoft.VisualStudio.TestTools.UnitTesting;
  6. #endif
  7. namespace FluentAssertions.Specs
  8. {
  9. [TestClass]
  10. public class FluentDateTimeSpecs
  11. {
  12. [TestMethod]
  13. public void When_fluently_specifying_a_date_in_january_it_should_return_the_correct_date_time_value()
  14. {
  15. //-----------------------------------------------------------------------------------------------------------
  16. // Act
  17. //-----------------------------------------------------------------------------------------------------------
  18. DateTime date = 10.January(2011);
  19. //-----------------------------------------------------------------------------------------------------------
  20. // Assert
  21. //-----------------------------------------------------------------------------------------------------------
  22. Assert.AreEqual(new DateTime(2011, 1, 10), date);
  23. }
  24. [TestMethod]
  25. public void When_fluently_specifying_a_date_in_february_it_should_return_the_correct_date_time_value()
  26. {
  27. //-----------------------------------------------------------------------------------------------------------
  28. // Act
  29. //-----------------------------------------------------------------------------------------------------------
  30. DateTime date = 10.February(2011);
  31. //-----------------------------------------------------------------------------------------------------------
  32. // Assert
  33. //-----------------------------------------------------------------------------------------------------------
  34. Assert.AreEqual(new DateTime(2011, 2, 10), date);
  35. }
  36. [TestMethod]
  37. public void When_fluently_specifying_a_date_in_march_it_should_return_the_correct_date_time_value()
  38. {
  39. //-----------------------------------------------------------------------------------------------------------
  40. // Act
  41. //-----------------------------------------------------------------------------------------------------------
  42. DateTime date = 10.March(2011);
  43. //-----------------------------------------------------------------------------------------------------------
  44. // Assert
  45. //-----------------------------------------------------------------------------------------------------------
  46. Assert.AreEqual(new DateTime(2011, 3, 10), date);
  47. }
  48. [TestMethod]
  49. public void When_fluently_specifying_a_date_in_april_it_should_return_the_correct_date_time_value()
  50. {
  51. //-----------------------------------------------------------------------------------------------------------
  52. // Act
  53. //-----------------------------------------------------------------------------------------------------------
  54. DateTime date = 10.April(2011);
  55. //-----------------------------------------------------------------------------------------------------------
  56. // Assert
  57. //-----------------------------------------------------------------------------------------------------------
  58. Assert.AreEqual(new DateTime(2011, 4, 10), date);
  59. }
  60. [TestMethod]
  61. public void When_fluently_specifying_a_date_in_may_it_should_return_the_correct_date_time_value()
  62. {
  63. //-----------------------------------------------------------------------------------------------------------
  64. // Act
  65. //-----------------------------------------------------------------------------------------------------------
  66. DateTime date = 10.May(2011);
  67. //-----------------------------------------------------------------------------------------------------------
  68. // Assert
  69. //-----------------------------------------------------------------------------------------------------------
  70. Assert.AreEqual(new DateTime(2011, 5, 10), date);
  71. }
  72. [TestMethod]
  73. public void When_fluently_specifying_a_date_in_june_it_should_return_the_correct_date_time_value()
  74. {
  75. //-----------------------------------------------------------------------------------------------------------
  76. // Act
  77. //-----------------------------------------------------------------------------------------------------------
  78. DateTime date = 10.June(2011);
  79. //-----------------------------------------------------------------------------------------------------------
  80. // Assert
  81. //-----------------------------------------------------------------------------------------------------------
  82. Assert.AreEqual(new DateTime(2011, 6, 10), date);
  83. }
  84. [TestMethod]
  85. public void When_fluently_specifying_a_date_in_july_it_should_return_the_correct_date_time_value()
  86. {
  87. //-----------------------------------------------------------------------------------------------------------
  88. // Act
  89. //-----------------------------------------------------------------------------------------------------------
  90. DateTime date = 10.July(2011);
  91. //-----------------------------------------------------------------------------------------------------------
  92. // Assert
  93. //-----------------------------------------------------------------------------------------------------------
  94. Assert.AreEqual(new DateTime(2011, 7, 10), date);
  95. }
  96. [TestMethod]
  97. public void When_fluently_specifying_a_date_in_august_it_should_return_the_correct_date_time_value()
  98. {
  99. //-----------------------------------------------------------------------------------------------------------
  100. // Act
  101. //-----------------------------------------------------------------------------------------------------------
  102. DateTime date = 10.August(2011);
  103. //-----------------------------------------------------------------------------------------------------------
  104. // Assert
  105. //-----------------------------------------------------------------------------------------------------------
  106. Assert.AreEqual(new DateTime(2011, 8, 10), date);
  107. }
  108. [TestMethod]
  109. public void When_fluently_specifying_a_date_in_september_it_should_return_the_correct_date_time_value()
  110. {
  111. //-----------------------------------------------------------------------------------------------------------
  112. // Act
  113. //-----------------------------------------------------------------------------------------------------------
  114. DateTime date = 10.September(2011);
  115. //-----------------------------------------------------------------------------------------------------------
  116. // Assert
  117. //-----------------------------------------------------------------------------------------------------------
  118. Assert.AreEqual(new DateTime(2011, 9, 10), date);
  119. }
  120. [TestMethod]
  121. public void When_fluently_specifying_a_date_in_october_it_should_return_the_correct_date_time_value()
  122. {
  123. //-----------------------------------------------------------------------------------------------------------
  124. // Act
  125. //-----------------------------------------------------------------------------------------------------------
  126. DateTime date = 10.October(2011);
  127. //-----------------------------------------------------------------------------------------------------------
  128. // Assert
  129. //-----------------------------------------------------------------------------------------------------------
  130. Assert.AreEqual(new DateTime(2011, 10, 10), date);
  131. }
  132. [TestMethod]
  133. public void When_fluently_specifying_a_date_in_november_it_should_return_the_correct_date_time_value()
  134. {
  135. //-----------------------------------------------------------------------------------------------------------
  136. // Act
  137. //-----------------------------------------------------------------------------------------------------------
  138. DateTime date = 10.November(2011);
  139. //-----------------------------------------------------------------------------------------------------------
  140. // Assert
  141. //-----------------------------------------------------------------------------------------------------------
  142. Assert.AreEqual(new DateTime(2011, 11, 10), date);
  143. }
  144. [TestMethod]
  145. public void When_fluently_specifying_a_date_in_december_it_should_return_the_correct_date_time_value()
  146. {
  147. //-----------------------------------------------------------------------------------------------------------
  148. // Act
  149. //-----------------------------------------------------------------------------------------------------------
  150. DateTime date = 10.December(2011);
  151. //-----------------------------------------------------------------------------------------------------------
  152. // Assert
  153. //-----------------------------------------------------------------------------------------------------------
  154. Assert.AreEqual(new DateTime(2011, 12, 10), date);
  155. }
  156. [TestMethod]
  157. public void When_fluently_specifying_a_date_and_time_it_should_return_the_correct_date_time_value()
  158. {
  159. //-----------------------------------------------------------------------------------------------------------
  160. // Act
  161. //-----------------------------------------------------------------------------------------------------------
  162. DateTime dateTime = 10.December(2011).At(09, 30, 45);
  163. //-----------------------------------------------------------------------------------------------------------
  164. // Assert
  165. //-----------------------------------------------------------------------------------------------------------
  166. Assert.AreEqual(new DateTime(2011, 12, 10, 9, 30, 45), dateTime);
  167. }
  168. [TestMethod]
  169. public void When_fluently_specifying_a_date_and_timespan_it_should_return_the_correct_date_time_value()
  170. {
  171. //-----------------------------------------------------------------------------------------------------------
  172. // Act
  173. //-----------------------------------------------------------------------------------------------------------
  174. var time = 9.Hours().And(30.Minutes()).And(45.Seconds());
  175. DateTime dateTime = 10.December(2011).At(time);
  176. //-----------------------------------------------------------------------------------------------------------
  177. // Assert
  178. //-----------------------------------------------------------------------------------------------------------
  179. Assert.AreEqual(new DateTime(2011, 12, 10, 9, 30, 45), dateTime);
  180. }
  181. }
  182. }