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

/Atlassian.Jira.Test/ComparableStringTest.cs

https://bitbucket.org/yyo/atlassian.net-sdk-v2.0
C# | 91 lines | 78 code | 13 blank | 0 comment | 10 complexity | c47de11b5c93ebdc4fbd14e4b4f1b51c MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Xunit;
  6. namespace Atlassian.Jira.Test
  7. {
  8. public class ComparableStringTest
  9. {
  10. [Fact]
  11. public void RefereceIsNull_EqualsOperators()
  12. {
  13. ComparableString field = null;
  14. Assert.True(field == null);
  15. Assert.False(field != null);
  16. }
  17. public class WithDate
  18. {
  19. [Fact]
  20. public void StringEqualsOperator()
  21. {
  22. Assert.False(new ComparableString("2012/05/01") == new DateTime(2012, 4,1));
  23. Assert.True(new ComparableString("2012/04/01") == new DateTime(2012, 4, 1));
  24. }
  25. [Fact]
  26. public void StringNotEqualsOperator()
  27. {
  28. Assert.True(new ComparableString("2012/05/01") != new DateTime(2012, 4, 1));
  29. Assert.False(new ComparableString("2012/04/01") != new DateTime(2012, 4, 1));
  30. }
  31. [Fact]
  32. public void StringGreaterThanOperator()
  33. {
  34. Assert.True(new ComparableString("2012/01/10") > new DateTime(2012, 1, 1));
  35. }
  36. [Fact]
  37. public void StringLessThanOperator()
  38. {
  39. Assert.True(new ComparableString("2012/01/10") < new DateTime(2012, 1, 11));
  40. }
  41. [Fact]
  42. public void StringLessThanOrEqualsOperator()
  43. {
  44. Assert.True(new ComparableString("2012/01/10") <= new DateTime(2012, 1, 10));
  45. }
  46. }
  47. public class WithString
  48. {
  49. [Fact]
  50. public void StringEqualsOperator()
  51. {
  52. Assert.False(new ComparableString("bar") == "foo");
  53. Assert.True(new ComparableString("foo") == "foo");
  54. }
  55. [Fact]
  56. public void StringNotEqualsOperator()
  57. {
  58. Assert.True(new ComparableString("bar") != "foo");
  59. Assert.False(new ComparableString("foo") != "foo");
  60. }
  61. [Fact]
  62. public void StringGreaterThanOperator()
  63. {
  64. Assert.True(new ComparableString("TST-23") > "TST-1");
  65. }
  66. [Fact]
  67. public void StringLessThanOperator()
  68. {
  69. Assert.True(new ComparableString("TST-1") < "TST-2");
  70. }
  71. [Fact]
  72. public void StringLessThanOrEqualsOperator()
  73. {
  74. Assert.True(new ComparableString("TST-1") <= "TST-2");
  75. }
  76. }
  77. }
  78. }