public void BLScheduleDelete() { Tourist.BusinessLogic.BusinessLogic bl = new Tourist.BusinessLogic.BusinessLogic(); TouristDataSet ds = new TouristDataSet(); //Читаем данные с БД в датасет и смотрим число строк ds = bl.ReadSchedule(); int countElements = ds.Schedule.Count; ds.Schedule.Clear(); //Добавляем строку в датасет и записываем в БД DateTime currentDateTime = DateTime.Now; currentDateTime = new DateTime(currentDateTime.Year, currentDateTime.Month, currentDateTime.Day, currentDateTime.Hour, currentDateTime.Minute, currentDateTime.Second); ds.Schedule.AddScheduleRow(currentDateTime); ds = bl.WriteSchedule(ds); //Чистим датасет, записываем в него ещё раз и удаляем из него последнюю запись ds.Schedule.Clear(); ds = bl.ReadSchedule(); ds.Schedule[countElements].Delete(); //Пишем в БД и снова читаем из неё в датасет ds = bl.WriteSchedule(ds); ds.Schedule.Clear(); ds = bl.ReadSchedule(); //Смотрим число строк до всех манипуляций и после Assert.AreEqual(ds.Schedule.Count, countElements); }
public void BLScheduleReadEmptyTable() { Tourist.BusinessLogic.BusinessLogic bl = new Tourist.BusinessLogic.BusinessLogic(); TouristDataSet ds = new TouristDataSet(); //Чтение в датасет и удаление оттуда всех записей ds = bl.ReadSchedule(); for (int i = 0; i < ds.Instructor.Count; i++) { ds.Instructor[i].Delete(); } for (int i = 0; i < ds.Tour.Count; i++) { ds.Tour[i].Delete(); } for (int i = 0; i < ds.Schedule.Count; i++) { ds.Schedule[i].Delete(); } //Сохранение в БД ds = bl.WriteSchedule(ds); ds.Instructor.Clear(); ds.Tour.Clear(); ds.Schedule.Clear(); //Чтение в датасет из пустой таблицы ds = bl.ReadSchedule(); int countElement = ds.Schedule.Count; Assert.AreEqual(0, countElement); }
public void BLInstructorUpdate() { Tourist.BusinessLogic.BusinessLogic bl = new Tourist.BusinessLogic.BusinessLogic(); TouristDataSet ds = new TouristDataSet(); //Читаем строки с БД и смотрим их число ds = bl.ReadInstructor(); int countElements = ds.Instructor.Count; //Проверка, есть ли значения в таблицах расписания и типа экскурсии. Если значения нет, записываем его и считываем еще раз if (ds.Schedule.Count == 0) { DateTime currentDateTime = DateTime.Now; currentDateTime = new DateTime(currentDateTime.Year, currentDateTime.Month, currentDateTime.Day, currentDateTime.Hour, currentDateTime.Minute, currentDateTime.Second); ds.Schedule.AddScheduleRow(currentDateTime); ds = bl.WriteSchedule(ds); } if (ds.TourType.Count == 0) { ds.TourType.AddTourTypeRow("Первая строка списка туров от апдейта"); ds = bl.WriteTourType(ds); } //Чистим таблицы датасета и читаем заново данные с базы ds.Instructor.Clear(); ds.Schedule.Clear(); ds.TourType.Clear(); ds = bl.ReadInstructor(); //Сохраняем ID первой записи таблиц Int32 savedScheduleId = ds.Schedule[0].id; Int32 savedTourTypeId = ds.TourType[0].id; //Добавляем строку и пишем в базу ds.Instructor.AddInstructorRow("Изменяйло", "Алексей", "Петрович", ds.Schedule[0], ds.TourType[0]); ds = bl.WriteInstructor(ds); ds.Instructor.Clear(); ds = bl.ReadInstructor(); countElements = ds.Instructor.Count; //Проверяем, что число строк >= 1 Assert.GreaterOrEqual(countElements, 1); //Меняем поле и пишем в БД ds.Instructor[countElements - 1].forename = "Hello from Update"; ds = bl.WriteInstructor(ds); ds.Instructor.Clear(); //Читаем снова и сравниваем ds = bl.ReadInstructor(); Assert.AreEqual("Изменяйло", ds.Instructor[countElements - 1].surname); Assert.AreEqual("Hello from Update", ds.Instructor[countElements - 1].forename); Assert.AreEqual("Петрович", ds.Instructor[countElements - 1].patronymic); Assert.AreEqual(savedScheduleId, ds.Instructor[countElements - 1].id_schedule); Assert.AreEqual(savedTourTypeId, ds.Instructor[countElements - 1].id_tour_type); }
public void BLScheduleUpdate() { Tourist.BusinessLogic.BusinessLogic bl = new Tourist.BusinessLogic.BusinessLogic(); TouristDataSet ds = new TouristDataSet(); DateTime currentDateTime = DateTime.Now; currentDateTime = new DateTime(currentDateTime.Year, currentDateTime.Month, currentDateTime.Day, currentDateTime.Hour, currentDateTime.Minute, currentDateTime.Second); //Читаем и проверяем, что в таблице хоть что-то есть ds = bl.ReadSchedule(); int countElement = ds.Sight.Count; if (countElement == 0) { //Если ничего нет, добавляем 1 строку ds.Schedule.AddScheduleRow(currentDateTime); ds = bl.WriteSchedule(ds); } //Читаем снова, пересчитываем число строк ds.Schedule.Clear(); ds = bl.ReadSchedule(); countElement = ds.Schedule.Count; //Проверяем, что число строк >= 1 Assert.GreaterOrEqual(countElement, 1); //Меняем поле и пишем в БД ds.Schedule[countElement - 1].tour_date = currentDateTime.AddDays(3); ds = bl.WriteSchedule(ds); ds.Schedule.Clear(); //Читаем снова и сравниваем ds = bl.ReadSchedule(); Assert.AreEqual(currentDateTime.AddDays(3), ds.Schedule[countElement - 1].tour_date); }
public void BLInstructorDelete() { Tourist.BusinessLogic.BusinessLogic bl = new Tourist.BusinessLogic.BusinessLogic(); TouristDataSet ds = new TouristDataSet(); //Читаем строки с БД и смотрим их число ds = bl.ReadInstructor(); int countElements = ds.Instructor.Count; //Проверка, есть ли значения в таблицах расписания и типа экскурсии. Если значения нет, записываем его и считываем еще раз if (ds.Schedule.Count == 0) { DateTime currentDateTime = DateTime.Now; currentDateTime = new DateTime(currentDateTime.Year, currentDateTime.Month, currentDateTime.Day, currentDateTime.Hour, currentDateTime.Minute, currentDateTime.Second); ds.Schedule.AddScheduleRow(currentDateTime); ds = bl.WriteSchedule(ds); } if (ds.TourType.Count == 0) { ds.TourType.AddTourTypeRow("Первая строка списка туров от делита"); ds = bl.WriteTourType(ds); } //Чистим таблицы датасета и читаем заново данные с базы ds.Instructor.Clear(); ds.Schedule.Clear(); ds.TourType.Clear(); ds = bl.ReadInstructor(); //Добавляем строку и пишем в базу ds.Instructor.AddInstructorRow("Делитов", "Алексей", "Петрович", ds.Schedule[0], ds.TourType[0]); ds = bl.WriteInstructor(ds); //Чистим датасет, записываем в него ещё раз и удаляем из него последнюю запись ds.Instructor.Clear(); ds = bl.ReadInstructor(); ds.Instructor[countElements].Delete(); //Пишем в БД и снова читаем из неё в датасет ds = bl.WriteInstructor(ds); ds.Instructor.Clear(); ds = bl.ReadInstructor(); //Смотрим число строк до всех манипуляций и после Assert.AreEqual(ds.Instructor.Count, countElements); }
public void BLScheduleInsert() { Tourist.BusinessLogic.BusinessLogic bl = new Tourist.BusinessLogic.BusinessLogic(); TouristDataSet ds = new TouristDataSet(); //Читаем данные с БД, считаем число записей в датасете ds = bl.ReadSchedule(); int countElement = ds.Schedule.Count; //Добавляем строку в датасет, сохраняем в БД, снова читаем в датасет DateTime currentDateTime = DateTime.Now; currentDateTime = new DateTime(currentDateTime.Year, currentDateTime.Month, currentDateTime.Day, currentDateTime.Hour, currentDateTime.Minute, currentDateTime.Second); ds.Schedule.AddScheduleRow(currentDateTime); ds = bl.WriteSchedule(ds); ds.Schedule.Clear(); ds = bl.ReadSchedule(); Assert.AreEqual(currentDateTime, ds.Schedule[countElement].tour_date); }
public void BLScheduleReadNotEmptyTable() { Tourist.BusinessLogic.BusinessLogic bl = new Tourist.BusinessLogic.BusinessLogic(); TouristDataSet ds = new TouristDataSet(); //Читаем строки с БД и смотрим их число ds = bl.ReadSchedule(); int countElements = ds.Schedule.Count; //Добавляем строку и пишем в базу DateTime currentDateTime = DateTime.Now; currentDateTime = new DateTime(currentDateTime.Year, currentDateTime.Month, currentDateTime.Day, currentDateTime.Hour, currentDateTime.Minute, currentDateTime.Second); ds.Schedule.AddScheduleRow(currentDateTime); ds = bl.WriteSchedule(ds); ds.Schedule.Clear(); //Читаем снова и смотрим на последнюю строку ds = bl.ReadSchedule(); Assert.AreEqual(currentDateTime, ds.Schedule[countElements].tour_date); }