123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- 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://hsaisodnnhmqcusypnar.supabase.co";
- static string key = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImhzYWlzb2RubmhtcWN1c3lwbmFyIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MjkxNjE0NzQsImV4cCI6MjA0NDczNzQ3NH0.KfjnJiEouhdAT4isU-QLWT6RKl0zaSFmulZzHu8tDg0";
- 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<Movie>> Get1()
- {
- return await supabase.From<Movie>().Get();
- }
- public async Task<ModeledResponse<Exhibition>> Get2()
- {
- return await supabase.From<Exhibition>().Get();
- }
- public async Task<ModeledResponse<Restaurants>> Get3()
- {
- return await supabase.From<Restaurants>().Get();
- }
- public async Task<ModeledResponse<Benchs>> Get4()
- {
- return await supabase.From<Benchs>().Get();
- }
- public async Task<ModeledResponse<Concerts>> Get5()
- {
- return await supabase.From<Concerts>().Get();
- }
- [TestMethod]
- public void TestMovie()
- {
- Initialize();
- Task<ModeledResponse<Movie>> result = Get1();
- result.Wait();
- var rez = result.Result.Models;
- Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(rez);
- }
- [TestMethod]
- public void TestExhibition()
- {
- Initialize();
- Task<ModeledResponse<Exhibition>> result = Get2();
- result.Wait();
- var rez = result.Result.Models;
- Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(rez);
- }
- [TestMethod]
- public void TestRestaurants()
- {
- Initialize();
- Task<ModeledResponse<Restaurants>> result = Get3();
- result.Wait();
- var rez = result.Result.Models;
- Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(rez);
- }
- [TestMethod]
- public void TestBenchs()
- {
- Initialize();
- Task<ModeledResponse<Benchs>> result = Get4();
- result.Wait();
- var rez = result.Result.Models;
- Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(rez);
- }
- [TestMethod]
- public void TestConcerts()
- {
- Initialize();
- Task<ModeledResponse<Concerts>> result = Get5();
- result.Wait();
- var rez = result.Result.Models;
- Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(rez);
- }
- [TestMethod]
- public async Task TestInsertBenchs()
- {
- var bench = new Benchs
- {
- id = 7,
- district = "Ìîñêîâñêèé",
- coordinates = "óë. Áåðåçîâñêàÿ, 102À.",
- state = "îòëè÷íîå",
- picture = "test_picture_url"
-
- };
- var result = await supabase.From<Benchs>().Insert(bench);
- Assert.IsNotNull(result.Models);
- Assert.IsTrue(result.Models.Count > 0, "Îøèáêà!");
- }
- [TestMethod]
- public async Task TestInsertMovies()
- {
- var movie = new Movie
- {
- id = 5,
- name = "Ïðåñòóïëåíèå è íàêàçàíèå",
- genre = "òðèëëåð",
- price = "îò 400 ðóá.",
- date = "ñ 26 îêòÿáðÿ.",
- picture = "test_picture_url"
- };
- var result = await supabase.From<Movie>().Insert(movie);
- Assert.IsNotNull(result.Models);
- Assert.IsTrue(result.Models.Count > 0, "Îøèáêà!");
- }
- [TestMethod]
- public async Task TestInsertConcerts()
- {
- var concert = new Concerts
- {
- id = 9,
- singer = "Åãîð Êðèä",
- genre = "ïîï",
- price = "îò 4500 ðóá.",
- date = "2024-11-27 20:00",
- picture = "test_picture_url"
- };
- var result = await supabase.From<Concerts>().Insert(concert);
- Assert.IsNotNull(result.Models);
- Assert.IsTrue(result.Models.Count > 0, "Îøèáêà!");
- }
- [TestMethod]
- public async Task TestInsertRestaurants()
- {
- var rest = new Restaurants
- {
- id = 8,
- name = "Êîëõèäà",
- location = "óë. Íåñòåðîâà, 23.",
- cuisin = "ãðóçèíñêàÿ",
- picture = "test_picture_url"
- };
- var result = await supabase.From<Restaurants>().Insert(rest);
- Assert.IsNotNull(result.Models);
- Assert.IsTrue(result.Models.Count > 0, "Îøèáêà!");
- }
- }
- }
|