123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- using Supabase.Postgrest.Responses;
- using static Supabase.Postgrest.Constants;
- using Supabase;
- using UnitTestTripHelper.Model;
- using UnitTestTripHelper.SupabaseConnect;
- namespace UnitTestTripHelper
- {
- public class UnitTest1
- {
- [Fact] //Òåñò íà ïðîâåðêó ñîçäàíèÿ êëèåíòà
- public async void TestCreateUser()
- {
- Client new_user = await Connect.Domain();
- Assert.NotNull(new_user);
- }
- [Fact] //Òåñò íà âõîä ïîëüçîâàòåëÿ
- public async void TestLoginUser()
- {
- Client new_user = await Connect.Domain();
- string email = "r@r.com";
- string password = "r";
- var user = await new_user.Auth.SignIn(email, password);
- Assert.NotNull(new_user);
- }
- [Fact] //Òåñò íà ðåãèñòðàöèþ íîâîãî ïîëüçîâàòåëÿ
- public async void TestSignUpNewUser()
- {
- Client new_user = await Connect.Domain();
- string email = "mikamakiboom7@gmail.com";
- string password = "test111";
- var user = await new_user.Auth.SignUp(email, password);
- await new_user.Auth.SignOut();
- Assert.NotNull(new_user);
- }
- [Fact] //Òåñò íà ÷òåíèå è ïîëó÷åíèå äàííûõ
- public async void TestReadDataCity()
- {
- Client conect = await Connect.Domain();
- int count = 0;
- int except = 49;
- count = await conect.From<City>().Count(CountType.Exact);
- Assert.True(count == except);
- }
- [Fact] //Òåñò íà äîáàâëåíèå ñòðîêè â òàáëèöó Ñòðàíû
- public async void TestInsertDataCountry()
- {
- Client conect = await Connect.Domain();
- bool check = false;
- Country model = new Country
- {
- Title = "Íîâàÿ ñòðàíà",
- Flag = null
- };
- try
- {
- ModeledResponse<Country> response = await conect.From<Country>().Insert(model);
- check = true;
- }
- catch
- {
- check = false;
- }
- Assert.True(check);
- }
- [Fact] //Òåñò íà óäàëåíèå â òàáëèöå Ñòðàíû
- public async void TestDeleteData()
- {
- Client conect = await Connect.Domain();
- bool check = false;
-
- try
- {
- await conect
- .From<City>()
- .Where(x => x.Id == 2)
- .Delete();
- check = true;
- }
- catch
- {
- check = false;
- }
- Assert.True(check);
- }
- [Fact] //Íåãàòèâíûé Òåñò íà ïðîâåðêó òðèããåðà äëÿ ðåéòèíãà, äèàïîçîí ðåéòèíãà îò 1 äî 5 â Îòåëå
- public async void TestCheckTriggerForRatingInHotels()
- {
- Client conect = await Connect.Domain();
- int rating = 6;
- bool check = false;
- try
- {
- var model = await conect
- .From<Hotels>()
- .Where(x => x.Id == 1)
- .Set(x => x.Rating, rating)
- .Update();
- check = true;
- }
- catch
- {
- check = false;
- }
- Assert.False(check);
- }
- [Fact] //Íåãàòèâíûé Òåñò íà ïðîâåðêó òðèããåðà äëÿ êîëè÷åñòâà êîìíàò â Îòåëå
- public async void TestCheckTriggerForQuantityInHotels()
- {
- Client conect = await Connect.Domain();
- int quantity = -10;
- bool check = false;
- try
- {
- var model = await conect
- .From<Hotels>()
- .Where(x => x.Id == 3)
- .Set(x => x.Quantity_of_rooms, quantity)
- .Update();
- check = true;
- }
- catch
- {
- check = false;
- }
- Assert.False(check);
- }
- [Fact] //Íåãàòèâíûé Òåñò íà ïðîâåðêó òðèããåðà äëÿ êîëè÷åñòâà ýòàæåé â Îòåëå
- public async void TestCheckTriggerForFloorsInHotels()
- {
- Client conect = await Connect.Domain();
- int floors = -100;
- bool check = false;
- try
- {
- var model = await conect
- .From<Hotels>()
- .Where(x => x.Id == 3)
- .Set(x => x.Floors, floors)
- .Update();
- check = true;
- }
- catch
- {
- check = false;
- }
- Assert.False(check);
- }
- [Fact] //Íåãàòèâíûé Òåñò íà ïðîâåðêó òðèããåðà äëÿ ñðåäíåãî ÷åêà â ðåñòîðàíàõ
- public async void TestCheckTriggerForAverageCheckInRestaurants()
- {
- Client conect = await Connect.Domain();
- int average = -15;
- bool check = false;
- try
- {
- var model = await conect
- .From<Restaurants>()
- .Where(x => x.Id == 3)
- .Set(x => x.Average_check, average)
- .Update();
- check = true;
- }
- catch
- {
- check = false;
- }
- Assert.False(check);
- }
- [Fact] //Íåãàòèâíûé Òåñò íà ïðîâåðêó òðèããåðà äëÿ ïîêàçíîé öåíû â Äîñòîïðèìå÷àòåëüíîñòÿõ
- public async void TestCheckTriggerForPriceInAttractions()
- {
- Client conect = await Connect.Domain();
- int price = -3;
- bool check = false;
- try
- {
- var model = await conect
- .From<Attractions>()
- .Where(x => x.Id == 3)
- .Set(x => x.Price_showing, price)
- .Update();
- check = true;
- }
- catch
- {
- check = false;
- }
- Assert.False(check);
- }
- [Fact] //Íåãàòèâíûé Òåñò íà ïðîâåðêó îãðàíè÷åíèé varchar â Äîñòîïðèìå÷àòåëüíîñòÿõ
- public async void TestCheckSizeVarcharTitle()
- {
- Client conect = await Connect.Domain();
- bool check = false;
- string title = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut "; //203 ñèìâîë
- try
- {
- var model = await conect
- .From<Attractions>()
- .Where (x => x.Id == 1)
- .Set(x=> x.Name, title)
- .Update();
- check = true;
- }
- catch
- {
- check = false;
- }
- Assert.False(check);
- }
- }
- }
|