/FlyByNightCouriers.Tests/Models/ParcelModelTest.cs

https://github.com/alfamale/Shaver · C# · 247 lines · 115 code · 20 blank · 112 comment · 0 complexity · c6dab4b3fc9968c6aac152446e621645 MD5 · raw file

  1. /* Copyright Andrew Woodcock, 2011
  2. This file is part of Shaver.
  3. Shaver is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Lesser General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. Shaver is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public License
  12. along with Shaver. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. using FlyByNight.Models;
  15. using Microsoft.VisualStudio.TestTools.UnitTesting;
  16. using System;
  17. using Microsoft.VisualStudio.TestTools.UnitTesting.Web;
  18. namespace FlyByNight.Tests.Models
  19. {
  20. /// <summary>
  21. ///This is a test class for ParcelModelTest and is intended
  22. ///to contain all ParcelModelTest Unit Tests
  23. ///</summary>
  24. [TestClass]
  25. public class ParcelModelTest
  26. {
  27. private TestContext testContextInstance;
  28. /// <summary>
  29. ///Gets or sets the test context which provides
  30. ///information about and functionality for the current test run.
  31. ///</summary>
  32. public TestContext TestContext
  33. {
  34. get
  35. {
  36. return testContextInstance;
  37. }
  38. set
  39. {
  40. testContextInstance = value;
  41. }
  42. }
  43. #region Additional test attributes
  44. //
  45. //You can use the following additional attributes as you write your tests:
  46. //
  47. //Use ClassInitialize to run code before running the first test in the class
  48. //[ClassInitialize()]
  49. //public static void MyClassInitialize(TestContext testContext)
  50. //{
  51. //}
  52. //
  53. //Use ClassCleanup to run code after all tests in a class have run
  54. //[ClassCleanup()]
  55. //public static void MyClassCleanup()
  56. //{
  57. //}
  58. //
  59. //Use TestInitialize to run code before running each test
  60. //[TestInitialize()]
  61. //public void MyTestInitialize()
  62. //{
  63. //}
  64. //
  65. //Use TestCleanup to run code after each test has run
  66. //[TestCleanup()]
  67. //public void MyTestCleanup()
  68. //{
  69. //}
  70. //
  71. #endregion
  72. /// <summary>
  73. ///A test for ParcelModel Constructor
  74. ///</summary>
  75. // TODO: Ensure that the UrlToTest attribute specifies a URL to an ASP.NET page (for example,
  76. // http://.../Default.aspx). This is necessary for the unit test to be executed on the web server,
  77. // whether you are testing a page, web service, or a WCF service.
  78. [TestMethod]
  79. public void ParcelModelConstructorTest()
  80. {
  81. var expectedDeliveryDate = DateTime.Now.AddDays(2);
  82. const double expectedCost = 9.95;
  83. var target = new ParcelModel();
  84. Assert.IsNotNull(target.Parcel);
  85. Assert.AreEqual(expectedDeliveryDate, target.DeliveryDate);
  86. Assert.AreEqual(expectedCost, target.Cost);
  87. Assert.IsNull(target.Description);
  88. Assert.IsNull(target.Message);
  89. Assert.IsNull(target.Receiver);
  90. Assert.IsNull(target.ReceiverAddress);
  91. Assert.IsNull(target.Sender);
  92. Assert.IsNull(target.SenderAddress);
  93. }
  94. /// <summary>
  95. ///A test for Cost
  96. ///</summary>
  97. // TODO: Ensure that the UrlToTest attribute specifies a URL to an ASP.NET page (for example,
  98. // http://.../Default.aspx). This is necessary for the unit test to be executed on the web server,
  99. // whether you are testing a page, web service, or a WCF service.
  100. [TestMethod]
  101. public void CostTest()
  102. {
  103. const double expected = 9.95;
  104. var target = new ParcelModel();
  105. var actual = target.Cost;
  106. Assert.AreEqual(expected, actual);
  107. }
  108. /// <summary>
  109. ///A test for DeliveryDate
  110. ///</summary>
  111. // TODO: Ensure that the UrlToTest attribute specifies a URL to an ASP.NET page (for example,
  112. // http://.../Default.aspx). This is necessary for the unit test to be executed on the web server,
  113. // whether you are testing a page, web service, or a WCF service.
  114. [TestMethod]
  115. public void DeliveryDateTest()
  116. {
  117. var expected = DateTime.Now.AddDays(2);
  118. var target = new ParcelModel();
  119. var actual = target.DeliveryDate;
  120. Assert.AreEqual(expected, actual);
  121. }
  122. /// <summary>
  123. ///A test for Description
  124. ///</summary>
  125. // TODO: Ensure that the UrlToTest attribute specifies a URL to an ASP.NET page (for example,
  126. // http://.../Default.aspx). This is necessary for the unit test to be executed on the web server,
  127. // whether you are testing a page, web service, or a WCF service.
  128. [TestMethod]
  129. public void DescriptionTest()
  130. {
  131. const string expected = "Description";
  132. var target = new ParcelModel()
  133. {
  134. Description = expected
  135. };
  136. var actual = target.Description;
  137. Assert.AreEqual(expected, actual);
  138. }
  139. /// <summary>
  140. ///A test for Message
  141. ///</summary>
  142. // TODO: Ensure that the UrlToTest attribute specifies a URL to an ASP.NET page (for example,
  143. // http://.../Default.aspx). This is necessary for the unit test to be executed on the web server,
  144. // whether you are testing a page, web service, or a WCF service.
  145. [TestMethod]
  146. public void MessageTest()
  147. {
  148. const string expected = "Message";
  149. var target = new ParcelModel() { Message = expected };
  150. var actual = target.Message;
  151. Assert.AreEqual(expected, actual);
  152. }
  153. /// <summary>
  154. ///A test for Parcel
  155. ///</summary>
  156. // TODO: Ensure that the UrlToTest attribute specifies a URL to an ASP.NET page (for example,
  157. // http://.../Default.aspx). This is necessary for the unit test to be executed on the web server,
  158. // whether you are testing a page, web service, or a WCF service.
  159. [TestMethod]
  160. public void ParcelTest()
  161. {
  162. var target = new ParcelModel();
  163. var actual = target.Parcel;
  164. Assert.IsNotNull(actual);
  165. }
  166. /// <summary>
  167. ///A test for Receiver
  168. ///</summary>
  169. // TODO: Ensure that the UrlToTest attribute specifies a URL to an ASP.NET page (for example,
  170. // http://.../Default.aspx). This is necessary for the unit test to be executed on the web server,
  171. // whether you are testing a page, web service, or a WCF service.
  172. [TestMethod]
  173. public void ReceiverTest()
  174. {
  175. string expected = "You";
  176. var target = new ParcelModel() { Receiver = expected };
  177. var actual = target.Receiver;
  178. Assert.AreEqual(expected, actual);
  179. }
  180. /// <summary>
  181. ///A test for ReceiverAddress
  182. ///</summary>
  183. // TODO: Ensure that the UrlToTest attribute specifies a URL to an ASP.NET page (for example,
  184. // http://.../Default.aspx). This is necessary for the unit test to be executed on the web server,
  185. // whether you are testing a page, web service, or a WCF service.
  186. [TestMethod]
  187. public void ReceiverAddressTest()
  188. {
  189. const string expected = "Your house";
  190. var target = new ParcelModel() { ReceiverAddress = expected };
  191. var actual = target.ReceiverAddress;
  192. Assert.AreEqual(expected, actual);
  193. }
  194. /// <summary>
  195. ///A test for Sender
  196. ///</summary>
  197. // TODO: Ensure that the UrlToTest attribute specifies a URL to an ASP.NET page (for example,
  198. // http://.../Default.aspx). This is necessary for the unit test to be executed on the web server,
  199. // whether you are testing a page, web service, or a WCF service.
  200. [TestMethod]
  201. public void SenderTest()
  202. {
  203. const string expected = "Me";
  204. var target = new ParcelModel() { Sender = expected };
  205. var actual = target.Sender;
  206. Assert.AreEqual(expected, actual);
  207. }
  208. /// <summary>
  209. ///A test for SenderAddress
  210. ///</summary>
  211. // TODO: Ensure that the UrlToTest attribute specifies a URL to an ASP.NET page (for example,
  212. // http://.../Default.aspx). This is necessary for the unit test to be executed on the web server,
  213. // whether you are testing a page, web service, or a WCF service.
  214. [TestMethod]
  215. public void SenderAddressTest()
  216. {
  217. string expected = "My house";
  218. var target = new ParcelModel() { SenderAddress = expected };
  219. var actual = target.SenderAddress;
  220. Assert.AreEqual(expected, actual);
  221. }
  222. }
  223. }