UnitTest1.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. using Supabase;
  2. using Supabase.Postgrest.Attributes;
  3. using Supabase.Postgrest.Models;
  4. using Supabase.Postgrest.Responses;
  5. using Supabase.Realtime;
  6. using System.ComponentModel;
  7. using System.Reflection;
  8. namespace TestProject1
  9. {
  10. [TestClass]
  11. public class UnitTest1
  12. {
  13. static string url = "https://hsaisodnnhmqcusypnar.supabase.co";
  14. static string key = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImhzYWlzb2RubmhtcWN1c3lwbmFyIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MjkxNjE0NzQsImV4cCI6MjA0NDczNzQ3NH0.KfjnJiEouhdAT4isU-QLWT6RKl0zaSFmulZzHu8tDg0";
  15. static Supabase.SupabaseOptions options = new Supabase.SupabaseOptions
  16. {
  17. AutoConnectRealtime = true
  18. };
  19. Supabase.Client supabase = new Supabase.Client(url, key, options);
  20. public async void Initialize()
  21. {
  22. await supabase.InitializeAsync();
  23. }
  24. public async Task<ModeledResponse<Movie>> Get1()
  25. {
  26. return await supabase.From<Movie>().Get();
  27. }
  28. public async Task<ModeledResponse<Exhibition>> Get2()
  29. {
  30. return await supabase.From<Exhibition>().Get();
  31. }
  32. public async Task<ModeledResponse<Restaurants>> Get3()
  33. {
  34. return await supabase.From<Restaurants>().Get();
  35. }
  36. public async Task<ModeledResponse<Benchs>> Get4()
  37. {
  38. return await supabase.From<Benchs>().Get();
  39. }
  40. public async Task<ModeledResponse<Concerts>> Get5()
  41. {
  42. return await supabase.From<Concerts>().Get();
  43. }
  44. [TestMethod]
  45. public void TestMovie()
  46. {
  47. Initialize();
  48. Task<ModeledResponse<Movie>> result = Get1();
  49. result.Wait();
  50. var rez = result.Result.Models;
  51. Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(rez);
  52. }
  53. [TestMethod]
  54. public void TestExhibition()
  55. {
  56. Initialize();
  57. Task<ModeledResponse<Exhibition>> result = Get2();
  58. result.Wait();
  59. var rez = result.Result.Models;
  60. Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(rez);
  61. }
  62. [TestMethod]
  63. public void TestRestaurants()
  64. {
  65. Initialize();
  66. Task<ModeledResponse<Restaurants>> result = Get3();
  67. result.Wait();
  68. var rez = result.Result.Models;
  69. Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(rez);
  70. }
  71. [TestMethod]
  72. public void TestBenchs()
  73. {
  74. Initialize();
  75. Task<ModeledResponse<Benchs>> result = Get4();
  76. result.Wait();
  77. var rez = result.Result.Models;
  78. Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(rez);
  79. }
  80. [TestMethod]
  81. public void TestConcerts()
  82. {
  83. Initialize();
  84. Task<ModeledResponse<Concerts>> result = Get5();
  85. result.Wait();
  86. var rez = result.Result.Models;
  87. Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(rez);
  88. }
  89. [TestMethod]
  90. public async Task TestInsertBenchs()
  91. {
  92. var bench = new Benchs
  93. {
  94. id = 7,
  95. district = "Ìîñêîâñêèé",
  96. coordinates = "óë. Áåðåçîâñêàÿ, 102À.",
  97. state = "îòëè÷íîå",
  98. picture = "test_picture_url"
  99. };
  100. var result = await supabase.From<Benchs>().Insert(bench);
  101. Assert.IsNotNull(result.Models);
  102. Assert.IsTrue(result.Models.Count > 0, "Îøèáêà!");
  103. }
  104. [TestMethod]
  105. public async Task TestInsertMovies()
  106. {
  107. var movie = new Movie
  108. {
  109. id = 5,
  110. name = "Ïðåñòóïëåíèå è íàêàçàíèå",
  111. genre = "òðèëëåð",
  112. price = "îò 400 ðóá.",
  113. date = "ñ 26 îêòÿáðÿ.",
  114. picture = "test_picture_url"
  115. };
  116. var result = await supabase.From<Movie>().Insert(movie);
  117. Assert.IsNotNull(result.Models);
  118. Assert.IsTrue(result.Models.Count > 0, "Îøèáêà!");
  119. }
  120. [TestMethod]
  121. public async Task TestInsertConcerts()
  122. {
  123. var concert = new Concerts
  124. {
  125. id = 9,
  126. singer = "Åãîð Êðèä",
  127. genre = "ïîï",
  128. price = "îò 4500 ðóá.",
  129. date = "2024-11-27 20:00",
  130. picture = "test_picture_url"
  131. };
  132. var result = await supabase.From<Concerts>().Insert(concert);
  133. Assert.IsNotNull(result.Models);
  134. Assert.IsTrue(result.Models.Count > 0, "Îøèáêà!");
  135. }
  136. [TestMethod]
  137. public async Task TestInsertRestaurants()
  138. {
  139. var rest = new Restaurants
  140. {
  141. id = 8,
  142. name = "Êîëõèäà",
  143. location = "óë. Íåñòåðîâà, 23.",
  144. cuisin = "ãðóçèíñêàÿ",
  145. picture = "test_picture_url"
  146. };
  147. var result = await supabase.From<Restaurants>().Insert(rest);
  148. Assert.IsNotNull(result.Models);
  149. Assert.IsTrue(result.Models.Count > 0, "Îøèáêà!");
  150. }
  151. }
  152. }