123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- using Supabase;
- using Supabase.Postgrest.Attributes;
- using Supabase.Postgrest.Models;
- using Supabase.Postgrest.Responses;
- using Supabase.Realtime;
- using System.ComponentModel;
- using System.Reflection;
- namespace TestProject1
- {
- [TestClass]
- public class UnitTest1
- {
- static string url = "https://vkxcxcimqqswxqxncmof.supabase.co";
- static string key = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InZreGN4Y2ltcXFzd3hxeG5jbW9mIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MjkxNjE0NDcsImV4cCI6MjA0NDczNzQ0N30.UZK8UzVHu47SZV4RtWRHVcOfTL3333_Kb_BbHDeqOCo";
- static Supabase.SupabaseOptions options = new Supabase.SupabaseOptions
- {
- AutoConnectRealtime = true
- };
- Supabase.Client supabase = new Supabase.Client(url, key, options);
- public async void Initialize()
- {
- await supabase.InitializeAsync();
- }
- public async Task<ModeledResponse<Season>> Get()
- {
- return await supabase.From<Season>().Get();
- }
- public async Task<ModeledResponse<Style>> Get1()
- {
- return await supabase.From<Style>().Get();
- }
- public async Task<ModeledResponse<Type>> Get2()
- {
- return await supabase.From<Type>().Get();
- }
- public async Task<ModeledResponse<Users>> Get3()
- {
- return await supabase.From<Users>().Get();
- }
- public async Task<ModeledResponse<type_subtype>> Get4()
- {
- return await supabase.From<type_subtype>().Get();
- }
- [TestMethod]
- public void TestSeasonReturn()//òåñò äëÿ ïðîâåðêè òîãî, ÷òî òàáëèöà ñåçîíîâ âîçâðàùàåò íå íóëåâûå çíà÷åíèÿ
- {
-
- Initialize();
- Task<ModeledResponse<Season>> result = Get();
- result.Wait();
- var seson = result.Result.Models;
- Assert.IsNotNull(seson);
- }
- [TestMethod]
- public void TestTypeReturn()//òåñò äëÿ ïðîâåðêè òîãî, ÷òî òàáëèöà ñåçîíîâ âîçâðàùàåò íå íóëåâûå çíà÷åíèÿ
- {
- Initialize();
- Task<ModeledResponse<Type>> result = Get2();
- result.Wait();
- var type = result.Result.Models;
- Assert.IsNotNull(type);
- }
- [TestMethod]
-
- public void TestStyleReturn()//òåñò äëÿ ïðîâåðêè òîãî, ÷òî òàáëèöà ññòèëåé âîçâðàùàåò íå íóëåâûå çíà÷åíèÿ
- {
- Initialize();
- Task<ModeledResponse<Style>> result = Get1();
- result.Wait();
- var styles = result.Result.Models;
- Assert.IsNotNull(styles);
- }
- [TestMethod]
- public void TestUsersReturn()//òåñò äëÿ ïðîâåðêè òîãî, ÷òî òàáëèöà ññòèëåé âîçâðàùàåò íå íóëåâûå çíà÷åíèÿ
- {
- Initialize();
- Task<ModeledResponse<Users>> result = Get3();
- result.Wait();
- var users = result.Result.Models;
- Assert.IsNotNull(users);
- }
- [TestMethod]
- public void TestSubtypereturn()//òåñò äëÿ ïðîâåðêè òîãî, ÷òî òàáëèöà ññòèëåé âîçâðàùàåò íå íóëåâûå çíà÷åíèÿ
- {
- Initialize();
- Task<ModeledResponse<type_subtype>> result = Get4();
- result.Wait();
- var subs = result.Result.Models;
- Assert.IsNotNull(subs);
- }
- [TestMethod]
- public void TestStyle()//òåñò äëÿ ïðîâåðêè òîãî, ÷òî òàáëèöà ñòèëåé âîçâðàùàåò êîððåêòíûå çíà÷åíèÿ ñòîëáöîâ
- {
- Initialize();
- Task<ModeledResponse<Style>> result = Get1();
- result.Wait();
- var styles = result.Result.Models;
- // Ïðîâåðÿåì, ÷òî â òàáëèöå åñòü çàïèñü ñ id = 5
- var style = styles.FirstOrDefault(s => s.Id == 5);
- Assert.IsNotNull(styles);
- // Ïðîâåðÿåì, ÷òî çíà÷åíèå title ðàâíî "Áîõî"
- Assert.AreEqual("áîõî", style.title);
- }
- [TestMethod]
- public void TestType()//òåñò äëÿ ïðîâåðêè òîãî, ÷òî òàáëèöà òèïîâ îäåæäû ñîäåðæèò 7 çàïèñåé
- {
- Initialize();
- Task<ModeledResponse<Type>> result = Get2();
- result.Wait();
- var types = result.Result.Models;
-
- Assert.AreEqual(7, types.Count, "Êîëè÷åñòâî òèïîâ îäåæäû â òàáëèöå íå ðàâíî 7.");
- }
- [TestMethod]
- public void TestSubtype()//òåñò äëÿ ïðîâåðêè òîãî, ÷òî òàáëèöà ñîäåðæèò 26 çàïèñåé
- {
- Initialize();
- Task<ModeledResponse<type_subtype>> result = Get4();
- result.Wait();
- var subs = result.Result.Models;
- Assert.AreEqual(26, subs.Count, "Êîëè÷åñòâî òèïîâ îäåæäû â òàáëèöå íå ðàâíî 7.");
- }
- [TestMethod]
- public void TestTypeNegative()//ïðåäûäóùèé òåñò, íî íåãàòèâíûé
- {
- Initialize();
- Task<ModeledResponse<Type>> result = Get2();
- result.Wait();
- var types = result.Result.Models;
- Assert.AreNotEqual(8, types.Count, "Êîëè÷åñòâî òèïîâ îäåæäû â òàáëèöå íå ðàâíî 7.");
- }
- [TestMethod]
- public void TestUser() // òåñò äëÿ ïðîâåðêè, ÷òî ïîëüçîâàòåëü ñ ID 2 èìååò èìÿ "àäìèí"
- {
- Initialize();
- Task<ModeledResponse<Users>> result = Get3();
- result.Wait();
- var users = result.Result.Models;
- // Ïðîâåðÿåì, ÷òî â òàáëèöå åñòü çàïèñü ñ id = 2
- var user = users.FirstOrDefault(u => u.Id == 2);
-
- // Ïðîâåðÿåì, ÷òî çíà÷åíèå name ðàâíî "àäìèí"
- Assert.AreEqual("Admin", user.name, "Èìÿ ïîëüçîâàòåëÿ ñ ID 2 íå ðàâíî 'àäìèí'.");
- }
- }
- }
|