123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- 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://mkrrkgiaewskfaslstgx.supabase.co";
- static string key = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im1rcnJrZ2lhZXdza2Zhc2xzdGd4Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MjkxNjExMDYsImV4cCI6MjA0NDczNzEwNn0.G6-C-LDzQBTuNAOcE83gZIjWUTiDpYWYa1Rjp4M5Kx0";
- 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<Label>> Get()
- {
- return await supabase.From<Label>().Get();
- }
- public async Task<ModeledResponse<Age_rating>> Get1()
- {
- return await supabase.From<Age_rating>().Get();
- }
- public async Task<ModeledResponse<Company>> Get2()
- {
- return await supabase.From<Company>().Get();
- }
- public async Task<ModeledResponse<Game>> Get3()
- {
- return await supabase.From<Game>().Get();
- }
- [TestMethod] //Ïðîâåðêà íà òî, ÷òî òàáëèöà labels âîçâðàùàåò çíà÷åíèÿ
- public void TestLabels()
- {
- Initialize();
- Task<ModeledResponse<Label>> result = Get();
- result.Wait();
- var labels = result.Result.Models;
- Assert.IsNotNull(labels);
- }
- [TestMethod] //Ïðîâåðêà íà òî, ÷òî òàáëèöà âîçðàñòíûõ ðåéòèíãîâ íå ïóñòà
- public void TestRatingNotEmpty()
- {
- Initialize();
- Task<ModeledResponse<Age_rating>> result = Get1();
- result.Wait();
- var Age_rating = result.Result.Models;
- Assert.IsTrue(Age_rating.Count > 0, "Ðåéòèíã äîëæåí áûòü íå ïóñòûì.");
- }
- [TestMethod] //Ïðîâåðêà óíèêàëüíûõ èäåíòèôèêàòîðîâ â òàáëèöå êîìïàíèé
- public void TestCompanyHaveUniqueIds()
- {
- Initialize();
- Task<ModeledResponse<Company>> result = Get2();
- result.Wait();
- var Company = result.Result.Models;
- var uniqueIds = new HashSet<int>(Company.Select(l => l.Id));
- Assert.AreEqual(uniqueIds.Count, Company.Count, "Êîìïàíèè äîëæíû èìåòü óíèêàëüíûé èäåíòèôèêàòîð");
- }
- [TestMethod]
- public async Task TestInsertGame() //Òåñò âñòàâêè äàííûõ â òàáëèöó èãð
- {
- var game = new Game
- {
- Id = 15,
- Name = "Test Game",
- Desc = "This is a test game description.",
- Company = 1,
- Picture = "test_picture_url",
- Views = 0,
- Fav = 0,
- Age = 1,
- Ofi = "https://official-link.com",
- Tor = "https://torrent-link.com"
- };
- var result = await supabase.From<Game>().Insert(game);
- Assert.IsNotNull(result.Models);
- Assert.IsTrue(result.Models.Count > 0, "Çàïèñü íå âñòàâëåíà");
- }
- [TestMethod]
- public void TestGame() //Òåñò âûáîðà äàííûõ èç òàáëèöû èãð
- {
- Initialize();
- Task<ModeledResponse<Game>> result = Get3();
- result.Wait();
- var Game = result.Result.Models;
- Assert.IsNotNull(Game);
- }
- [TestMethod] //Ïðîâåðÿåò, ÷òî â ìåòêàõ âîçâðàùàåòñÿ 20 ñòðîê
- public void TestGetLabels_ReturnsTwentyRows()
- {
- Initialize();
- Task<ModeledResponse<Label>> result = Get();
- result.Wait();
- var labels = result.Result.Models;
- Assert.IsNotNull(labels);
- Assert.AreEqual(20, labels.Count);
- }
- [TestMethod] //Ïðîâåðÿåò, ÷òî â êîëëåêöèè íåò ïóñòûõ çíà÷åíèé
- public void TestLabelsContainNoNulls()
- {
- Initialize();
- Task<ModeledResponse<Label>> result = Get();
- result.Wait();
- var labels = result.Result.Models;
- Assert.IsFalse(labels.Contains(null), "Ìåòêè íå äîëæíû ñîäåðæàòü ïóñòûõ çíà÷åíèé.");
- }
- [TestMethod]
- public void TestCompany() //Òåñò âûáîðà äàííûõ èç òàáëèöû êîìïàíèè
- {
- Initialize();
- Task<ModeledResponse<Company>> result = Get2();
- result.Wait();
- var Company = result.Result.Models;
- Assert.IsNotNull(Company);
- }
- [TestMethod] //Òåñò ÷òî ñòðîêà ñî 2id â êîìïàíèè ÿâëÿåòñÿ Riot Games
- public void TestCompanyHaveRow()
- {
- Initialize();
- Task<ModeledResponse<Company>> result = Get2();
- result.Wait();
- var company = result.Result.Models;
- var companyy = company.FirstOrDefault(s => s.Id == 2);
- Assert.IsNotNull(company);
- Assert.AreEqual("Riot Games", companyy.name);
- }
- [TestMethod] //Ïðîâåðêà óíèêàëüíûõ èäåíòèôèêàòîðîâ â òàáëèöå ìåòîê
- public void TestLabelHaveUniqueIds()
- {
- Initialize();
- Task<ModeledResponse<Label>> result = Get();
- result.Wait();
- var labels = result.Result.Models;
- var uniqueIds = new HashSet<int>(labels.Select(l => l.ID));
- Assert.AreEqual(uniqueIds.Count, labels.Count, "Ìåòêè äîëæíû èìåòü óíèêàëüíûé èäåíòèôèêàòîð");
- }
- }
- }
|