/mono-for-android/3.3.0.1/Pubnub-Messaging/Andr.Unit-master/Android.NUnitLite/AndrRunner/NUnitLite/Constraints/ConstraintFactory.cs

https://github.com/brentbushnell/pubnub-api · C# · 772 lines · 354 code · 150 blank · 268 comment · 0 complexity · d08cc7d584c151a75d832063f0769184 MD5 · raw file

  1. // ***********************************************************************
  2. // Copyright (c) 2009 Charlie Poole
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining
  5. // a copy of this software and associated documentation files (the
  6. // "Software"), to deal in the Software without restriction, including
  7. // without limitation the rights to use, copy, modify, merge, publish,
  8. // distribute, sublicense, and/or sell copies of the Software, and to
  9. // permit persons to whom the Software is furnished to do so, subject to
  10. // the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be
  13. // included in all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  18. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  19. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  20. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  21. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. // ***********************************************************************
  23. // ****************************************************************
  24. // Generated by the NUnit Syntax Generator
  25. //
  26. // Command Line: GenSyntax.exe SyntaxElements.txt
  27. //
  28. // DO NOT MODIFY THIS FILE DIRECTLY
  29. // ****************************************************************
  30. using System;
  31. using System.Collections;
  32. namespace NUnit.Framework.Constraints
  33. {
  34. /// <summary>
  35. /// Helper class with properties and methods that supply
  36. /// a number of constraints used in Asserts.
  37. /// </summary>
  38. public class ConstraintFactory
  39. {
  40. #region Not
  41. /// <summary>
  42. /// Returns a ConstraintExpression that negates any
  43. /// following constraint.
  44. /// </summary>
  45. public ConstraintExpression Not
  46. {
  47. get { return Is.Not; }
  48. }
  49. /// <summary>
  50. /// Returns a ConstraintExpression that negates any
  51. /// following constraint.
  52. /// </summary>
  53. public ConstraintExpression No
  54. {
  55. get { return Has.No; }
  56. }
  57. #endregion
  58. #region All
  59. /// <summary>
  60. /// Returns a ConstraintExpression, which will apply
  61. /// the following constraint to all members of a collection,
  62. /// succeeding if all of them succeed.
  63. /// </summary>
  64. public ConstraintExpression All
  65. {
  66. get { return Is.All; }
  67. }
  68. #endregion
  69. #region Some
  70. /// <summary>
  71. /// Returns a ConstraintExpression, which will apply
  72. /// the following constraint to all members of a collection,
  73. /// succeeding if at least one of them succeeds.
  74. /// </summary>
  75. public ConstraintExpression Some
  76. {
  77. get { return Has.Some; }
  78. }
  79. #endregion
  80. #region None
  81. /// <summary>
  82. /// Returns a ConstraintExpression, which will apply
  83. /// the following constraint to all members of a collection,
  84. /// succeeding if all of them fail.
  85. /// </summary>
  86. public ConstraintExpression None
  87. {
  88. get { return Has.None; }
  89. }
  90. #endregion
  91. #region Property
  92. /// <summary>
  93. /// Returns a new PropertyConstraintExpression, which will either
  94. /// test for the existence of the named property on the object
  95. /// being tested or apply any following constraint to that property.
  96. /// </summary>
  97. public ResolvableConstraintExpression Property(string name)
  98. {
  99. return Has.Property(name);
  100. }
  101. #endregion
  102. #region Length
  103. /// <summary>
  104. /// Returns a new ConstraintExpression, which will apply the following
  105. /// constraint to the Length property of the object being tested.
  106. /// </summary>
  107. public ResolvableConstraintExpression Length
  108. {
  109. get { return Has.Length; }
  110. }
  111. #endregion
  112. #region Count
  113. /// <summary>
  114. /// Returns a new ConstraintExpression, which will apply the following
  115. /// constraint to the Count property of the object being tested.
  116. /// </summary>
  117. public ResolvableConstraintExpression Count
  118. {
  119. get { return Has.Count; }
  120. }
  121. #endregion
  122. #region Message
  123. /// <summary>
  124. /// Returns a new ConstraintExpression, which will apply the following
  125. /// constraint to the Message property of the object being tested.
  126. /// </summary>
  127. public ResolvableConstraintExpression Message
  128. {
  129. get { return Has.Message; }
  130. }
  131. #endregion
  132. #region InnerException
  133. /// <summary>
  134. /// Returns a new ConstraintExpression, which will apply the following
  135. /// constraint to the InnerException property of the object being tested.
  136. /// </summary>
  137. public ResolvableConstraintExpression InnerException
  138. {
  139. get { return Has.InnerException; }
  140. }
  141. #endregion
  142. #region Attribute
  143. /// <summary>
  144. /// Returns a new AttributeConstraint checking for the
  145. /// presence of a particular attribute on an object.
  146. /// </summary>
  147. public ResolvableConstraintExpression Attribute(Type expectedType)
  148. {
  149. return Has.Attribute(expectedType);
  150. }
  151. #if NET_2_0
  152. /// <summary>
  153. /// Returns a new AttributeConstraint checking for the
  154. /// presence of a particular attribute on an object.
  155. /// </summary>
  156. public ResolvableConstraintExpression Attribute<T>()
  157. {
  158. return Attribute(typeof(T));
  159. }
  160. #endif
  161. #endregion
  162. #region Null
  163. /// <summary>
  164. /// Returns a constraint that tests for null
  165. /// </summary>
  166. public NullConstraint Null
  167. {
  168. get { return new NullConstraint(); }
  169. }
  170. #endregion
  171. #region True
  172. /// <summary>
  173. /// Returns a constraint that tests for True
  174. /// </summary>
  175. public TrueConstraint True
  176. {
  177. get { return new TrueConstraint(); }
  178. }
  179. #endregion
  180. #region False
  181. /// <summary>
  182. /// Returns a constraint that tests for False
  183. /// </summary>
  184. public FalseConstraint False
  185. {
  186. get { return new FalseConstraint(); }
  187. }
  188. #endregion
  189. #region NaN
  190. /// <summary>
  191. /// Returns a constraint that tests for NaN
  192. /// </summary>
  193. public NaNConstraint NaN
  194. {
  195. get { return new NaNConstraint(); }
  196. }
  197. #endregion
  198. #region Empty
  199. /// <summary>
  200. /// Returns a constraint that tests for empty
  201. /// </summary>
  202. public EmptyConstraint Empty
  203. {
  204. get { return new EmptyConstraint(); }
  205. }
  206. #endregion
  207. #region Unique
  208. /// <summary>
  209. /// Returns a constraint that tests whether a collection
  210. /// contains all unique items.
  211. /// </summary>
  212. public UniqueItemsConstraint Unique
  213. {
  214. get { return new UniqueItemsConstraint(); }
  215. }
  216. #endregion
  217. #region BinarySerializable
  218. #if !NETCF
  219. /// <summary>
  220. /// Returns a constraint that tests whether an object graph is serializable in binary format.
  221. /// </summary>
  222. public BinarySerializableConstraint BinarySerializable
  223. {
  224. get { return new BinarySerializableConstraint(); }
  225. }
  226. #endif
  227. #endregion
  228. #region XmlSerializable
  229. #if !NETCF_1_0
  230. /// <summary>
  231. /// Returns a constraint that tests whether an object graph is serializable in xml format.
  232. /// </summary>
  233. public XmlSerializableConstraint XmlSerializable
  234. {
  235. get { return new XmlSerializableConstraint(); }
  236. }
  237. #endif
  238. #endregion
  239. #region EqualTo
  240. /// <summary>
  241. /// Returns a constraint that tests two items for equality
  242. /// </summary>
  243. public EqualConstraint EqualTo(object expected)
  244. {
  245. return new EqualConstraint(expected);
  246. }
  247. #endregion
  248. #region SameAs
  249. /// <summary>
  250. /// Returns a constraint that tests that two references are the same object
  251. /// </summary>
  252. public SameAsConstraint SameAs(object expected)
  253. {
  254. return new SameAsConstraint(expected);
  255. }
  256. #endregion
  257. #region GreaterThan
  258. /// <summary>
  259. /// Returns a constraint that tests whether the
  260. /// actual value is greater than the suppled argument
  261. /// </summary>
  262. public GreaterThanConstraint GreaterThan(object expected)
  263. {
  264. return new GreaterThanConstraint(expected);
  265. }
  266. #endregion
  267. #region GreaterThanOrEqualTo
  268. /// <summary>
  269. /// Returns a constraint that tests whether the
  270. /// actual value is greater than or equal to the suppled argument
  271. /// </summary>
  272. public GreaterThanOrEqualConstraint GreaterThanOrEqualTo(object expected)
  273. {
  274. return new GreaterThanOrEqualConstraint(expected);
  275. }
  276. /// <summary>
  277. /// Returns a constraint that tests whether the
  278. /// actual value is greater than or equal to the suppled argument
  279. /// </summary>
  280. public GreaterThanOrEqualConstraint AtLeast(object expected)
  281. {
  282. return new GreaterThanOrEqualConstraint(expected);
  283. }
  284. #endregion
  285. #region LessThan
  286. /// <summary>
  287. /// Returns a constraint that tests whether the
  288. /// actual value is less than the suppled argument
  289. /// </summary>
  290. public LessThanConstraint LessThan(object expected)
  291. {
  292. return new LessThanConstraint(expected);
  293. }
  294. #endregion
  295. #region LessThanOrEqualTo
  296. /// <summary>
  297. /// Returns a constraint that tests whether the
  298. /// actual value is less than or equal to the suppled argument
  299. /// </summary>
  300. public LessThanOrEqualConstraint LessThanOrEqualTo(object expected)
  301. {
  302. return new LessThanOrEqualConstraint(expected);
  303. }
  304. /// <summary>
  305. /// Returns a constraint that tests whether the
  306. /// actual value is less than or equal to the suppled argument
  307. /// </summary>
  308. public LessThanOrEqualConstraint AtMost(object expected)
  309. {
  310. return new LessThanOrEqualConstraint(expected);
  311. }
  312. #endregion
  313. #region TypeOf
  314. /// <summary>
  315. /// Returns a constraint that tests whether the actual
  316. /// value is of the exact type supplied as an argument.
  317. /// </summary>
  318. public ExactTypeConstraint TypeOf(Type expectedType)
  319. {
  320. return new ExactTypeConstraint(expectedType);
  321. }
  322. #if NET_2_0
  323. /// <summary>
  324. /// Returns a constraint that tests whether the actual
  325. /// value is of the exact type supplied as an argument.
  326. /// </summary>
  327. public ExactTypeConstraint TypeOf<T>()
  328. {
  329. return new ExactTypeConstraint(typeof(T));
  330. }
  331. #endif
  332. #endregion
  333. #region InstanceOf
  334. /// <summary>
  335. /// Returns a constraint that tests whether the actual value
  336. /// is of the type supplied as an argument or a derived type.
  337. /// </summary>
  338. public InstanceOfTypeConstraint InstanceOf(Type expectedType)
  339. {
  340. return new InstanceOfTypeConstraint(expectedType);
  341. }
  342. #if NET_2_0
  343. /// <summary>
  344. /// Returns a constraint that tests whether the actual value
  345. /// is of the type supplied as an argument or a derived type.
  346. /// </summary>
  347. public InstanceOfTypeConstraint InstanceOf<T>()
  348. {
  349. return new InstanceOfTypeConstraint(typeof(T));
  350. }
  351. #endif
  352. /// <summary>
  353. /// Returns a constraint that tests whether the actual value
  354. /// is of the type supplied as an argument or a derived type.
  355. /// </summary>
  356. [Obsolete("Use InstanceOf(expectedType)")]
  357. public InstanceOfTypeConstraint InstanceOfType(Type expectedType)
  358. {
  359. return new InstanceOfTypeConstraint(expectedType);
  360. }
  361. #if NET_2_0
  362. /// <summary>
  363. /// Returns a constraint that tests whether the actual value
  364. /// is of the type supplied as an argument or a derived type.
  365. /// </summary>
  366. [Obsolete("Use InstanceOf<T>()")]
  367. public InstanceOfTypeConstraint InstanceOfType<T>()
  368. {
  369. return new InstanceOfTypeConstraint(typeof(T));
  370. }
  371. #endif
  372. #endregion
  373. #region AssignableFrom
  374. /// <summary>
  375. /// Returns a constraint that tests whether the actual value
  376. /// is assignable from the type supplied as an argument.
  377. /// </summary>
  378. public AssignableFromConstraint AssignableFrom(Type expectedType)
  379. {
  380. return new AssignableFromConstraint(expectedType);
  381. }
  382. #if NET_2_0
  383. /// <summary>
  384. /// Returns a constraint that tests whether the actual value
  385. /// is assignable from the type supplied as an argument.
  386. /// </summary>
  387. public AssignableFromConstraint AssignableFrom<T>()
  388. {
  389. return new AssignableFromConstraint(typeof(T));
  390. }
  391. #endif
  392. #endregion
  393. #region AssignableTo
  394. /// <summary>
  395. /// Returns a constraint that tests whether the actual value
  396. /// is assignable from the type supplied as an argument.
  397. /// </summary>
  398. public AssignableToConstraint AssignableTo(Type expectedType)
  399. {
  400. return new AssignableToConstraint(expectedType);
  401. }
  402. #if NET_2_0
  403. /// <summary>
  404. /// Returns a constraint that tests whether the actual value
  405. /// is assignable from the type supplied as an argument.
  406. /// </summary>
  407. public AssignableToConstraint AssignableTo<T>()
  408. {
  409. return new AssignableToConstraint(typeof(T));
  410. }
  411. #endif
  412. #endregion
  413. #region EquivalentTo
  414. /// <summary>
  415. /// Returns a constraint that tests whether the actual value
  416. /// is a collection containing the same elements as the
  417. /// collection supplied as an argument.
  418. /// </summary>
  419. public CollectionEquivalentConstraint EquivalentTo(IEnumerable expected)
  420. {
  421. return new CollectionEquivalentConstraint(expected);
  422. }
  423. #endregion
  424. #region SubsetOf
  425. /// <summary>
  426. /// Returns a constraint that tests whether the actual value
  427. /// is a subset of the collection supplied as an argument.
  428. /// </summary>
  429. public CollectionSubsetConstraint SubsetOf(IEnumerable expected)
  430. {
  431. return new CollectionSubsetConstraint(expected);
  432. }
  433. #endregion
  434. #region Ordered
  435. /// <summary>
  436. /// Returns a constraint that tests whether a collection is ordered
  437. /// </summary>
  438. public CollectionOrderedConstraint Ordered
  439. {
  440. get { return new CollectionOrderedConstraint(); }
  441. }
  442. #endregion
  443. #region Member
  444. /// <summary>
  445. /// Returns a new CollectionContainsConstraint checking for the
  446. /// presence of a particular object in the collection.
  447. /// </summary>
  448. public CollectionContainsConstraint Member(object expected)
  449. {
  450. return new CollectionContainsConstraint(expected);
  451. }
  452. /// <summary>
  453. /// Returns a new CollectionContainsConstraint checking for the
  454. /// presence of a particular object in the collection.
  455. /// </summary>
  456. public CollectionContainsConstraint Contains(object expected)
  457. {
  458. return new CollectionContainsConstraint(expected);
  459. }
  460. #endregion
  461. #region Contains
  462. /// <summary>
  463. /// Returns a new ContainsConstraint. This constraint
  464. /// will, in turn, make use of the appropriate second-level
  465. /// constraint, depending on the type of the actual argument.
  466. /// This overload is only used if the item sought is a string,
  467. /// since any other type implies that we are looking for a
  468. /// collection member.
  469. /// </summary>
  470. public ContainsConstraint Contains(string expected)
  471. {
  472. return new ContainsConstraint(expected);
  473. }
  474. #endregion
  475. #region StringContaining
  476. /// <summary>
  477. /// Returns a constraint that succeeds if the actual
  478. /// value contains the substring supplied as an argument.
  479. /// </summary>
  480. public SubstringConstraint StringContaining(string expected)
  481. {
  482. return new SubstringConstraint(expected);
  483. }
  484. /// <summary>
  485. /// Returns a constraint that succeeds if the actual
  486. /// value contains the substring supplied as an argument.
  487. /// </summary>
  488. public SubstringConstraint ContainsSubstring(string expected)
  489. {
  490. return new SubstringConstraint(expected);
  491. }
  492. #endregion
  493. #region DoesNotContain
  494. /// <summary>
  495. /// Returns a constraint that fails if the actual
  496. /// value contains the substring supplied as an argument.
  497. /// </summary>
  498. public SubstringConstraint DoesNotContain(string expected)
  499. {
  500. return new ConstraintExpression().Not.ContainsSubstring(expected);
  501. }
  502. #endregion
  503. #region StartsWith
  504. /// <summary>
  505. /// Returns a constraint that succeeds if the actual
  506. /// value starts with the substring supplied as an argument.
  507. /// </summary>
  508. public StartsWithConstraint StartsWith(string expected)
  509. {
  510. return new StartsWithConstraint(expected);
  511. }
  512. /// <summary>
  513. /// Returns a constraint that succeeds if the actual
  514. /// value starts with the substring supplied as an argument.
  515. /// </summary>
  516. public StartsWithConstraint StringStarting(string expected)
  517. {
  518. return new StartsWithConstraint(expected);
  519. }
  520. #endregion
  521. #region DoesNotStartWith
  522. /// <summary>
  523. /// Returns a constraint that fails if the actual
  524. /// value starts with the substring supplied as an argument.
  525. /// </summary>
  526. public StartsWithConstraint DoesNotStartWith(string expected)
  527. {
  528. return new ConstraintExpression().Not.StartsWith(expected);
  529. }
  530. #endregion
  531. #region EndsWith
  532. /// <summary>
  533. /// Returns a constraint that succeeds if the actual
  534. /// value ends with the substring supplied as an argument.
  535. /// </summary>
  536. public EndsWithConstraint EndsWith(string expected)
  537. {
  538. return new EndsWithConstraint(expected);
  539. }
  540. /// <summary>
  541. /// Returns a constraint that succeeds if the actual
  542. /// value ends with the substring supplied as an argument.
  543. /// </summary>
  544. public EndsWithConstraint StringEnding(string expected)
  545. {
  546. return new EndsWithConstraint(expected);
  547. }
  548. #endregion
  549. #region DoesNotEndWith
  550. /// <summary>
  551. /// Returns a constraint that fails if the actual
  552. /// value ends with the substring supplied as an argument.
  553. /// </summary>
  554. public EndsWithConstraint DoesNotEndWith(string expected)
  555. {
  556. return new ConstraintExpression().Not.EndsWith(expected);
  557. }
  558. #endregion
  559. #region Matches
  560. #if !NETCF
  561. /// <summary>
  562. /// Returns a constraint that succeeds if the actual
  563. /// value matches the Regex pattern supplied as an argument.
  564. /// </summary>
  565. public RegexConstraint Matches(string pattern)
  566. {
  567. return new RegexConstraint(pattern);
  568. }
  569. /// <summary>
  570. /// Returns a constraint that succeeds if the actual
  571. /// value matches the Regex pattern supplied as an argument.
  572. /// </summary>
  573. public RegexConstraint StringMatching(string pattern)
  574. {
  575. return new RegexConstraint(pattern);
  576. }
  577. #endif
  578. #endregion
  579. #region DoesNotMatch
  580. #if !NETCF
  581. /// <summary>
  582. /// Returns a constraint that fails if the actual
  583. /// value matches the pattern supplied as an argument.
  584. /// </summary>
  585. public RegexConstraint DoesNotMatch(string pattern)
  586. {
  587. return new ConstraintExpression().Not.Matches(pattern);
  588. }
  589. #endif
  590. #endregion
  591. #region SamePath
  592. /// <summary>
  593. /// Returns a constraint that tests whether the path provided
  594. /// is the same as an expected path after canonicalization.
  595. /// </summary>
  596. public SamePathConstraint SamePath(string expected)
  597. {
  598. return new SamePathConstraint(expected);
  599. }
  600. #endregion
  601. #region SamePathOrUnder
  602. /// <summary>
  603. /// Returns a constraint that tests whether the path provided
  604. /// is the same path or under an expected path after canonicalization.
  605. /// </summary>
  606. public SamePathOrUnderConstraint SamePathOrUnder(string expected)
  607. {
  608. return new SamePathOrUnderConstraint(expected);
  609. }
  610. #endregion
  611. #region InRange
  612. /// <summary>
  613. /// Returns a constraint that tests whether the actual value falls
  614. /// within a specified range.
  615. /// </summary>
  616. public RangeConstraint InRange(IComparable from, IComparable to)
  617. {
  618. return new RangeConstraint(from, to);
  619. }
  620. #endregion
  621. }
  622. }