Exemplo n.º 1
0
        public void BLSightReadEmptyTable()
        {
            Tourist.BusinessLogic.BusinessLogic bl = new Tourist.BusinessLogic.BusinessLogic();
            TouristDataSet ds = new TouristDataSet();

            //Чтение в датасет и удаление оттуда всех записей
            ds = bl.ReadSight();

            for (int i = 0; i < ds.Tour.Count; i++)
            {
                ds.Tour[i].Delete();
            }
            for (int i = 0; i < ds.Sight.Count; i++)
            {
                ds.Sight[i].Delete();
            }

            //Сохранение в БД
            ds = bl.WriteSight(ds);

            //Очистка таблиц
            ds.Tour.Clear();
            ds.Sight.Clear();

            //Чтение в датасет из пустой таблицы
            ds = bl.ReadSight();
            int countElement = ds.Sight.Count;

            Assert.AreEqual(0, countElement);
        }
        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);
        }
Exemplo n.º 3
0
        public void BLSightDelete()
        {
            Tourist.BusinessLogic.BusinessLogic bl = new Tourist.BusinessLogic.BusinessLogic();
            TouristDataSet ds = new TouristDataSet();

            //Читаем данные с БД в датасет и смотрим число строк
            ds = bl.ReadSight();
            int countElements = ds.Sight.Count;

            ds.Sight.Clear();

            //Добавляем строку в датасет и записываем в БД
            ds.Sight.AddSightRow("String", "ToDelete");
            ds = bl.WriteSight(ds);

            //Чистим датасет, записываем в него ещё раз и удаляем из него последнюю запись
            ds.Sight.Clear();
            ds = bl.ReadSight();
            ds.Sight[countElements].Delete();

            //Пишем в БД и снова читаем из неё в датасет
            ds = bl.WriteSight(ds);
            ds.Sight.Clear();
            ds = bl.ReadSight();

            //Смотрим число строк до всех манипуляций и после
            Assert.AreEqual(ds.Sight.Count, countElements);
        }
Exemplo n.º 4
0
        public void BLSightUpdate()
        {
            Tourist.BusinessLogic.BusinessLogic bl = new Tourist.BusinessLogic.BusinessLogic();
            TouristDataSet ds = new TouristDataSet();

            //Читаем и проверяем, что в таблице хоть что-то есть
            ds = bl.ReadSight();
            int countElement = ds.Sight.Count;

            if (countElement == 0)
            {
                //Если ничего нет, добавляем 1 строку
                ds.Sight.AddSightRow("Insert", "Str.");
                ds = bl.WriteSight(ds);
            }
            //Читаем снова, пересчитываем число строк
            ds.Sight.Clear();
            ds           = bl.ReadSight();
            countElement = ds.Sight.Count;

            //Проверяем, что число строк >= 1
            Assert.GreaterOrEqual(countElement, 1);

            //Меняем поле и пишем в БД
            ds.Sight[countElement - 1].sight_descr = "Hello from Update";
            ds = bl.WriteSight(ds);
            ds.Sight.Clear();

            //Читаем снова и сравниваем
            ds = bl.ReadSight();

            Assert.AreEqual("Hello from Update", ds.Sight[countElement - 1].sight_descr);
        }
        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 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);
        }
Exemplo n.º 7
0
        public void BLSightInsert()
        {
            Tourist.BusinessLogic.BusinessLogic bl = new Tourist.BusinessLogic.BusinessLogic();
            TouristDataSet ds = new TouristDataSet();

            //Читаем данные с БД, считаем число записей в датасете
            ds = bl.ReadSight();
            int countElement = ds.Sight.Count;

            //Добавляем строку в датасет, сохраняем в БД, снова читаем в датасет
            ds.Sight.AddSightRow("Insert", "Str.");
            ds = bl.WriteSight(ds);
            ds.Sight.Clear();
            ds = bl.ReadSight();

            Assert.AreEqual("Insert", ds.Sight[countElement].sight_name);
            Assert.AreEqual("Str.", ds.Sight[countElement].sight_descr);
        }
Exemplo n.º 8
0
        public void BLSightReadNotEmptyTable()
        {
            Tourist.BusinessLogic.BusinessLogic bl = new Tourist.BusinessLogic.BusinessLogic();
            TouristDataSet ds = new TouristDataSet();

            //Читаем строки с БД и смотрим их число
            ds = bl.ReadSight();

            int countElements = ds.Sight.Count;

            //Добавляем строку и пишем в базу
            ds.Sight.AddSightRow("Памятник Ленину", "Обычный памятник в городе");
            ds = bl.WriteSight(ds);
            ds.Sight.Clear();

            //Читаем снова и смотрим на последнюю строку
            ds = bl.ReadSight();

            Assert.AreEqual("Памятник Ленину", ds.Sight[countElements].sight_name);
            Assert.AreEqual("Обычный памятник в городе", ds.Sight[countElements].sight_descr);
        }
        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);
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
        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);
        }