You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LuFieldDboTests.cs 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System.Linq;
  2. using Luticate2.Auth.Utils.Business.Fields;
  3. using Luticate2.Auth.Utils.Dbo.Fields;
  4. using Xunit;
  5. namespace Luticate2.Auth.Tests.Business.Fields
  6. {
  7. public class LuFieldDboTests
  8. {
  9. public class TestDbo1
  10. {
  11. public string MyString { get; set; }
  12. }
  13. [Fact]
  14. public void TestMake1()
  15. {
  16. var field1 = LuFieldDbo.Make<TestDbo1>(x => x.MyString.Length);
  17. Assert.True(field1.Parts.SequenceEqual(new[] {"MyString", "Length"}));
  18. }
  19. [Fact]
  20. public void TestMake2()
  21. {
  22. var field1 = LuFieldDbo.Make(new[] {"MyString", "Length"});
  23. Assert.True(field1.Parts.SequenceEqual(new[] {"MyString", "Length"}));
  24. }
  25. [Fact]
  26. public void TestMake3()
  27. {
  28. var field1 = LuFieldDbo.Make("MyString.Length");
  29. Assert.True(field1.Parts.SequenceEqual(new[] {"MyString", "Length"}));
  30. }
  31. [Fact]
  32. public void TestMake4()
  33. {
  34. var field1 = LuFieldDbo.Make("MyString/Length");
  35. Assert.True(field1.Parts.SequenceEqual(new[] {"MyString", "Length"}));
  36. }
  37. [Fact]
  38. public void TestPop1()
  39. {
  40. var field1 = LuFieldDbo.Make<TestDbo1>(x => x.MyString.Length);
  41. var field2 = field1.Pop();
  42. Assert.True(field1.Parts.SequenceEqual(new[] {"Length"}));
  43. Assert.True(field2.Parts.SequenceEqual(new[] {"Length"}));
  44. }
  45. [Fact]
  46. public void TestPopped1()
  47. {
  48. var field1 = LuFieldDbo.Make<TestDbo1>(x => x.MyString.Length);
  49. var field2 = field1.Popped();
  50. Assert.True(field1.Parts.SequenceEqual(new[] {"MyString", "Length"}));
  51. Assert.True(field2.Parts.SequenceEqual(new[] {"Length"}));
  52. }
  53. }
  54. }