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

/WebEssentialsTests/Tests/IntellisenseGeneration/TestHelper/IntellisensePropertyAssertions.cs

https://github.com/systembugtj/WebEssentials2013
C# | 78 lines | 69 code | 9 blank | 0 comment | 2 complexity | 3badf85ed35bb99aa22d88d7216f5577 MD5 | raw file
Possible License(s): CC-BY-SA-3.0
  1. using FluentAssertions;
  2. using FluentAssertions.Execution;
  3. using FluentAssertions.Primitives;
  4. using MadsKristensen.EditorExtensions;
  5. namespace WebEssentialsTests.Tests.IntellisenseGeneration.TestHelper
  6. {
  7. public class IntellisensePropertyAssertions :
  8. ReferenceTypeAssertions<IntellisenseProperty, IntellisensePropertyAssertions>
  9. {
  10. protected internal IntellisensePropertyAssertions(IntellisenseProperty @object)
  11. {
  12. Subject = @object;
  13. }
  14. protected override string Context
  15. {
  16. get { return "WebEssentials IntellisenseProperty"; }
  17. }
  18. public AndConstraint<IntellisensePropertyAssertions> IsArray(string reason, params object[] reasonArgs)
  19. {
  20. Execute.Assertion
  21. .ForCondition(Subject.Type.IsArray)
  22. .BecauseOf(reason, reasonArgs)
  23. .FailWith("Expected {0} to be an array{reason}", Subject.Name);
  24. return new AndConstraint<IntellisensePropertyAssertions>(this);
  25. }
  26. public AndConstraint<IntellisensePropertyAssertions> IsNotAnArray(string reason, params object[] reasonArgs)
  27. {
  28. Execute.Assertion
  29. .ForCondition(!Subject.Type.IsArray)
  30. .BecauseOf(reason, reasonArgs)
  31. .FailWith("Expected {0} not to be an array{reason}", Subject.Name);
  32. return new AndConstraint<IntellisensePropertyAssertions>(this);
  33. }
  34. public AndConstraint<IntellisensePropertyAssertions> JavaScriptNameIs(string expected, string reason,
  35. params object[] reasonArgs)
  36. {
  37. Execute.Assertion
  38. .ForCondition(Subject.Type.JavaScriptName == expected)
  39. .BecauseOf(reason, reasonArgs)
  40. .FailWith("Expected {0} to have JavaScriptName {1}{reason}, but found {2}", Subject.Name, expected, Subject.Type.JavaScriptName);
  41. return new AndConstraint<IntellisensePropertyAssertions>(this);
  42. }
  43. public AndConstraint<IntellisensePropertyAssertions> TypeScriptNameIs(string expected, string reason,
  44. params object[] reasonArgs)
  45. {
  46. Execute.Assertion
  47. .ForCondition(Subject.Type.TypeScriptName == expected)
  48. .BecauseOf(reason, reasonArgs)
  49. .FailWith("Expected {0} to have TypeScriptName {1}{reason}, but found {2}", Subject.Name, expected, Subject.Type.TypeScriptName);
  50. return new AndConstraint<IntellisensePropertyAssertions>(this);
  51. }
  52. public AndConstraint<IntellisensePropertyAssertions> IsArray()
  53. {
  54. return IsArray(string.Empty);
  55. }
  56. public AndConstraint<IntellisensePropertyAssertions> IsNotAnArray()
  57. {
  58. return IsNotAnArray(string.Empty);
  59. }
  60. public AndConstraint<IntellisensePropertyAssertions> JavaScriptNameIs(string expected)
  61. {
  62. return JavaScriptNameIs(expected, string.Empty);
  63. }
  64. public AndConstraint<IntellisensePropertyAssertions> TypeScriptNameIs(string expected)
  65. {
  66. return TypeScriptNameIs(expected, string.Empty);
  67. }
  68. }
  69. }