public void AddEmpty() { // Arrange ------------------------------------- Note note = new Note(); // Act ----------------------------------------- DbService.AddNote(note); // Assert----------------------------------------- int count = DbService.LoadAllNotes().Count; Assert.AreEqual(1, count); }
public void AddOne() { // Arrange ------------------------------------- Note note = new Note("заметка", "213", "KSU", false); // Act ----------------------------------------- DbService.AddNote(note); // Assert----------------------------------------- int count = DbService.LoadAllNotes().Count; Assert.AreEqual(count, 1); }
public void AddNull() { DbService.ClearAll(); // Arrange ------------------------------------- Note note = null; // Act ----------------------------------------- DbService.AddNote(note); // Assert----------------------------------------- int count = DbService.LoadAllNotes().Count; Assert.AreEqual(0, count); }
async void OnButtonSaveClicked(object sender, EventArgs args) { if (NoteText.Text == "") { DependencyService.Get <IToast>().Show("Ну и зачем так делать?"); return; } bool connect = await WebData.CheckConnection(); if (connect == false) { return; } // если загружено здание и есть установленное помещение, создаем связь с помещением if (BuildingData.CurrentBuilding != null) { if (BuildingData.CurrentBuilding.Name == SearchBarBuilding.Text && RoomData.isThatRoom(SearchBarRoom.Text) != null) { roomnote = RoomData.isThatRoom(SearchBarRoom.Text); } } NoteService noteService = new NoteService(); // посылаем заметку на сервер Note note = await noteService.Add(new Note(NoteText.Text, SearchBarRoom.Text, roomid : roomnote?.RoomId, building : SearchBarBuilding.Text, clientid : Client.CurrentClient.ClientId, clientname : Client.CurrentClient.Name)); if (note != null) // если сервер вернул данные по заметке - загрузить в пользователя { DbService.AddNote(note); await Navigation.PopAsync(); return; } else { await DisplayAlert("Ошибка", "Сервер не вернул данные", "OK"); return; } }
public async void LoginIn(object sender, EventArgs e) { if (LoginPage.LoginBox.Text == "" || LoginPage.PasswBox.Text == "") { DependencyService.Get <IToast>().Show("Введены не все поля"); return; } if (isLoading) { DependencyService.Get <IToast>().Show("Пользователь уже загружается"); return; } bool connect = await WebData.CheckConnection(); if (connect == false) { return; } isLoading = true; var client = await new ClientService().Authrization(LoginPage.LoginBox.Text, LoginPage.PasswBox.Text); if (client != null) // если сервер вернул данные пользователя - загрузить в пользователя { Client.setClient(Int32.Parse(client["Id"]), client["Name"], client["Login"]); DbService.SaveClient(Client.CurrentClient); // сохранили пользователя List <Note> clientnotes = await new NoteService().GetClient(Client.CurrentClient.ClientId); RemoveDuplicateNote(clientnotes); // если эта заметка уже загружена как публичная - удалить RemoveNonLoadedRoomId(clientnotes); // если заметка связаны с незагруженным помещением - отвязать DbService.AddNote(clientnotes); DbService.AddFavoriteRoom(await new FavRoomService().Get(Client.CurrentClient.ClientId)); isLoading = false; GetClientPage(); return; } else { await DisplayAlert("Ошибка", "Неверный логин или пароль", "OK"); isLoading = false; return; } }
public void NonUpdateWoW() { // Arrange ------------------------------------- Note note = new Note("заметка", "213", "KSU", false); DbService.AddNote(note); // Act ----------------------------------------- note.Text = "текст"; // Assert----------------------------------------- string upstring = DbService.LoadAllNotes().First().Text; Assert.AreEqual("текст", upstring); }
public void FindNull() { // Arrange ------------------------------------- Note note = new Note("заметка", "213", "KSU", false); DbService.AddNote(note); Note test = null; // Act ----------------------------------------- Note result = DbService.FindNote(test); // Assert----------------------------------------- Assert.IsNull(result); }
public void FindOne() { // Arrange ------------------------------------- Note note = new Note("заметка", "213", "KSU", false); DbService.AddNote(note); Note test = new Note("заметка", "213", "KSU", false); // Act ----------------------------------------- Note result = DbService.FindNote(test); // Assert----------------------------------------- Assert.AreEqual(1, result.NoteId); }
public void UpdateEmpty() { // Arrange ------------------------------------- Note note = new Note("заметка", "213", "KSU", false); DbService.AddNote(note); // Act ----------------------------------------- note = null; DbService.UpdateNote(note); // Assert----------------------------------------- string upstring = DbService.LoadAllNotes().First().Text; Assert.AreEqual("заметка", upstring); }
public void AddFiveSame() { // Arrange ------------------------------------- // Act ----------------------------------------- DbService.AddNote(new Note("I'm open note", "213", "KGU", true)); DbService.AddNote(new Note("I'm open okey", "213", "KGU", true)); DbService.AddNote(new Note("I'm open yesi", "522", "KGU", true)); DbService.AddNote(new Note("I'm open noby", "231", "KGU", true)); DbService.AddNote(new Note("I'm open puko", "409", "KGU", true)); // Assert----------------------------------------- int count = DbService.LoadAllNotes().Count; Assert.AreEqual(5, count); }
public void RemoveEmpty() { // Arrange ------------------------------------- Note note = new Note("заметка", "213", "KSU", false); DbService.AddNote(note); // Act ----------------------------------------- Note empnote = null; DbService.RemoveNote(empnote); // Assert----------------------------------------- int count = DbService.LoadAllNotes().Count; Assert.AreEqual(1, count); }
public void AddList() { // Arrange ------------------------------------- List <Note> notes = new List <Note>(); notes.Add(new Note("заметка", "213", "KSU", false)); notes.Add(new Note("заметка1", "213", "KSU", false)); notes.Add(new Note("заметка2", "213", "KSU", false)); // Act ----------------------------------------- DbService.AddNote(notes); // Assert----------------------------------------- int count = DbService.LoadAllNotes().Count; Assert.AreEqual(3, count); }
public void AddListLinks() { // Arrange ------------------------------------- Note note = new Note("заметка", "213", "KSU", false); Note note2 = new Note("заметка1", "213", "KSU", false); Note note1 = new Note("заметка2", "213", "KSU", false); // Act ----------------------------------------- DbService.AddNote(note); DbService.AddNote(note1); DbService.AddNote(note2); // Assert----------------------------------------- int count = DbService.LoadAllNotes().Count; Assert.AreEqual(3, count); }
public void RemoveMany() { // Arrange ------------------------------------- DbService.AddNote(new Note("I'm open note", "213", "KGU", true)); DbService.AddNote(new Note("I'm open okey", "213", "KGU", true)); DbService.AddNote(new Note("I'm open yesi", "522", "KGU", true)); DbService.AddNote(new Note("I'm open noby", "231", "KGU", true)); DbService.AddNote(new Note("I'm open puko", "409", "KGU", true)); var notes = DbService.LoadAllNotes(); // Act ----------------------------------------- DbService.RemoveNote(notes); // Assert----------------------------------------- int count = DbService.LoadAllNotes().Count; Assert.AreEqual(0, count); }
public void LoadMany() { // Arrange ------------------------------------- DbService.LoadSampleUser("12", "21"); DbService.AddNote(new Note("I'm open note", "213", "KGU", true)); DbService.AddNote(new Note("I'm open okey", "213", "KGU", true)); DbService.AddNote(new Note("I'm open yesi", "522", "KGU", true)); DbService.AddNote(new Note("I'm open noby", "231", "KGU", true)); DbService.AddNote(new Note("I'm open puko", "409", "KGU", true)); DbService.AddNote(new Note("I'm user puko", "409", "KGU", true, 1)); DbService.AddNote(new Note("I'm user yesi", "409", "KGU", true, 1)); DbService.AddNote(new Note("I'm user okey", "409", "KGU", true, 1)); // Act ----------------------------------------- var result = DbService.LoadAllPublicNotes(); // Assert----------------------------------------- Assert.AreEqual(5, result.Count); }
public async void Load() { BuildingLoad = true; bool connect = await WebData.CheckConnection(); if (connect == false) { return; } DependencyService.Get <IToast>().Show("Загрузка здания"); FloorData.Floors = new List <Floor>(); RoomData.Rooms = new List <Room>(); WorkerData.Workers = new List <Worker>(); PointData.Points = new List <PointM>(); PointData.RoomPoints = new List <PointM>(); PointData.CurrentFloorRoomPoints = new List <PointM>(); EdgeData.Edges = new List <EdgeM>(); EdgeData.Ways = new List <EdgeM>(); EdgeData.CurrentFloorWalls = new List <EdgeM>(); NoteData.Notes = new List <Note>(); List <Floor> floors = await new FloorService().GetFloors(Current.BuildingId); List <Room> rooms = await new RoomService().GetRooms(Current.BuildingId); List <Worker> workers = await new WorkerService().GetWorkers(Current.BuildingId); List <PointM> points = await new PointService().GetPoints(Current.BuildingId); List <EdgeM> edges = await new EdgeService().GetEdges(Current.BuildingId); List <Note> notes = await new NoteService().GetPublic(Current.BuildingId); List <Note> clientnotes = null; // получить все публичные заметки не текущего пользователя if (Client.CurrentClient?.ClientId != null) { notes = notes.Where(n => n.ClientId != Client.CurrentClient.ClientId).ToList(); clientnotes = await new NoteService().GetClient(Client.CurrentClient.ClientId); } foreach (var n in notes) { n.ClientId = null; } Authorization.RemoveNonLoadedRoomId(clientnotes, rooms); DbService.RemoveCurrentBuilding(); try { DbService.AddFloor(floors); DbService.AddRoom(rooms); DbService.AddWorker(workers); DbService.AddPoing(points); DbService.AddEdge(edges); DbService.SaveDb(); DbService.AddNote(notes); DbService.AddNote(clientnotes); } catch (System.Exception e) { if (e is Microsoft.EntityFrameworkCore.DbUpdateException || e is System.InvalidCastException) { // DbService.RemoveCurrentBuilding(); DependencyService.Get <IToast>().Show("Загруженые здания некорректны"); } BuildingLoad = false; return; } FloorData.Floors = DbService.LoadAllFloors(); RoomData.Rooms = DbService.LoadAllRooms(); WorkerData.Workers = DbService.LoadAllWorkers(); PointData.Points = DbService.LoadAllPoints(); EdgeData.Edges = DbService.LoadAllEdges(); NoteData.Notes = DbService.LoadAllNotes(); BuildingData.CurrentBuilding = Current; PointData.RoomPoints = PointData.Points .Where(p => p.IsWaypoint == true) .Where(c => c.Room != null).ToList(); DependencyService.Get <IToast>().Show("Здание загружено"); DownloadBut.Text = "Обновить"; BuildingLoad = false; BuildingPage.isUpdate = true; RoomGroup.UpdateList(); }