InflectorTests.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using System;
  2. using PetaPoco.Core.Inflection;
  3. using Shouldly;
  4. using Xunit;
  5. namespace PetaPoco.Tests.Unit.Core.Inflection
  6. {
  7. public class InflectorTests : IDisposable
  8. {
  9. public void Dispose()
  10. {
  11. Inflector.Instance = null;
  12. }
  13. [Fact]
  14. public void Instance_Default_ShouldBeEnglish()
  15. {
  16. Inflector.Instance.ShouldNotBeNull();
  17. Inflector.Instance.ShouldBeOfType<EnglishInflector>();
  18. }
  19. [Fact]
  20. public void Instance_CanBeReplaced_ShouldNotFail()
  21. {
  22. Inflector.Instance = new Wookiee();
  23. Inflector.Instance.ShouldNotBeNull();
  24. Inflector.Instance.ShouldBeOfType<Wookiee>();
  25. Inflector.Instance.Humanise("Test").ShouldBe(Wookiee.WookieeReponse);
  26. }
  27. private class Wookiee : IInflector
  28. {
  29. public const string WookieeReponse = "huuguughghg uughghhhgh";
  30. public string Pluralise(string word)
  31. {
  32. return WookieeReponse;
  33. }
  34. public string Singularise(string word)
  35. {
  36. return WookieeReponse;
  37. }
  38. public string Titleise(string word)
  39. {
  40. return WookieeReponse;
  41. }
  42. public string Humanise(string lowercaseAndUnderscoredWord)
  43. {
  44. return WookieeReponse;
  45. }
  46. public string Pascalise(string lowercaseAndUnderscoredWord)
  47. {
  48. return WookieeReponse;
  49. }
  50. public string Camelise(string lowercaseAndUnderscoredWord)
  51. {
  52. return WookieeReponse;
  53. }
  54. public string Underscore(string pascalCasedWord)
  55. {
  56. return WookieeReponse;
  57. }
  58. public string Capitalise(string word)
  59. {
  60. return WookieeReponse;
  61. }
  62. public string Uncapitalise(string word)
  63. {
  64. return WookieeReponse;
  65. }
  66. public string Ordinalise(string number)
  67. {
  68. return WookieeReponse;
  69. }
  70. public string Ordinalise(int number)
  71. {
  72. return WookieeReponse;
  73. }
  74. public string Dasherise(string underscoredWord)
  75. {
  76. return WookieeReponse;
  77. }
  78. }
  79. }
  80. }