Add tests
This commit is contained in:
parent
3fd6b1e6eb
commit
c5b95332b5
@ -7,6 +7,7 @@ using RouteGuideContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -58,6 +59,26 @@ namespace RouteGuideBusinessLogics.BusinessLogics
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение списка из заданного количества элементов
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
/// <returns></returns>
|
||||
public List<DriverViewModel>? ReadList(int count)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Count: {Count}", count);
|
||||
|
||||
var list = _driverStorage.GetList(count);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList. Returned null list");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. Count: {Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение отдельной записи
|
||||
/// </summary>
|
||||
@ -138,6 +159,33 @@ namespace RouteGuideBusinessLogics.BusinessLogics
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удаление записи
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool Delete()
|
||||
{
|
||||
_logger.LogInformation("Delete. Driver");
|
||||
|
||||
if (_driverStorage.Delete() == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удаление всех записей
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int Clear()
|
||||
{
|
||||
int count = _driverStorage.Clear();
|
||||
_logger.LogInformation("Clear. Delete {Count} Drivers", count);
|
||||
return count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Проверка модели
|
||||
/// </summary>
|
||||
|
@ -58,6 +58,26 @@ namespace RouteGuideBusinessLogics.BusinessLogics
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение списка из заданного количества элементов
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
/// <returns></returns>
|
||||
public List<RouteViewModel>? ReadList(int count)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Count: {Count}", count);
|
||||
|
||||
var list = _routeStorage.GetList(count);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList. Returned null list");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. Count: {Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение отдельной записи
|
||||
/// </summary>
|
||||
@ -138,6 +158,33 @@ namespace RouteGuideBusinessLogics.BusinessLogics
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удаление записи
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool Delete()
|
||||
{
|
||||
_logger.LogInformation("Delete. Route");
|
||||
|
||||
if (_routeStorage.Delete() == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удаление всех записей
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int Clear()
|
||||
{
|
||||
int count = _routeStorage.Clear();
|
||||
_logger.LogInformation("Clear. Delete {Count} Routes", count);
|
||||
return count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Проверка модели
|
||||
/// </summary>
|
||||
|
@ -58,6 +58,26 @@ namespace RouteGuideBusinessLogics.BusinessLogics
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение списка из заданного количества элементов
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
/// <returns></returns>
|
||||
public List<ScheduleViewModel>? ReadList(int count)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Count: {Count}", count);
|
||||
|
||||
var list = _scheduleStorage.GetList(count);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList. Returned null list");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. Count: {Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение отдельной записи
|
||||
/// </summary>
|
||||
@ -138,6 +158,33 @@ namespace RouteGuideBusinessLogics.BusinessLogics
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удаление записи
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool Delete()
|
||||
{
|
||||
_logger.LogInformation("Delete. Schedule");
|
||||
|
||||
if (_scheduleStorage.Delete() == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удаление всех записей
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int Clear()
|
||||
{
|
||||
int count = _scheduleStorage.Clear();
|
||||
_logger.LogInformation("Clear. Delete {Count} Schedules", count);
|
||||
return count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Проверка модели
|
||||
/// </summary>
|
||||
|
@ -58,6 +58,26 @@ namespace RouteGuideBusinessLogics.BusinessLogics
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение списка из заданного количества элементов
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
/// <returns></returns>
|
||||
public List<StopViewModel>? ReadList(int count)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Count: {Count}", count);
|
||||
|
||||
var list = _stopStorage.GetList(count);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList. Returned null list");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. Count: {Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение отдельной записи
|
||||
/// </summary>
|
||||
@ -138,6 +158,33 @@ namespace RouteGuideBusinessLogics.BusinessLogics
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удаление записи
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool Delete()
|
||||
{
|
||||
_logger.LogInformation("Delete. Stop");
|
||||
|
||||
if (_stopStorage.Delete() == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удаление всех записей
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int Clear()
|
||||
{
|
||||
int count = _stopStorage.Clear();
|
||||
_logger.LogInformation("Clear. Delete {Count} Stops", count);
|
||||
return count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Проверка модели
|
||||
/// </summary>
|
||||
|
@ -58,6 +58,26 @@ namespace RouteGuideBusinessLogics.BusinessLogics
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение списка из заданного количества элементов
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
/// <returns></returns>
|
||||
public List<TransportViewModel>? ReadList(int count)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Count: {Count}", count);
|
||||
|
||||
var list = _transportStorage.GetList(count);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList. Returned null list");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. Count: {Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение отдельной записи
|
||||
/// </summary>
|
||||
@ -138,6 +158,33 @@ namespace RouteGuideBusinessLogics.BusinessLogics
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удаление записи
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool Delete()
|
||||
{
|
||||
_logger.LogInformation("Delete. Transport");
|
||||
|
||||
if (_transportStorage.Delete() == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удаление всех записей
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int Clear()
|
||||
{
|
||||
int count = _transportStorage.Clear();
|
||||
_logger.LogInformation("Clear. Delete {Count} Transports", count);
|
||||
return count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Проверка модели
|
||||
/// </summary>
|
||||
|
@ -21,6 +21,13 @@ namespace RouteGuideContracts.BusinessLogicsContracts
|
||||
/// <returns></returns>
|
||||
List<DriverViewModel>? ReadList(DriverSearchModel? model);
|
||||
|
||||
/// <summary>
|
||||
/// Получение списка из заданного количества элементов
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
/// <returns></returns>
|
||||
List<DriverViewModel>? ReadList(int count);
|
||||
|
||||
/// <summary>
|
||||
/// Получение отдельной записи
|
||||
/// </summary>
|
||||
@ -48,5 +55,17 @@ namespace RouteGuideContracts.BusinessLogicsContracts
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
bool Delete(DriverBindingModel model);
|
||||
|
||||
/// <summary>
|
||||
/// Удаление записи
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool Delete();
|
||||
|
||||
/// <summary>
|
||||
/// Удаление всех записей
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
int Clear();
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,13 @@ namespace RouteGuideContracts.BusinessLogicsContracts
|
||||
/// <returns></returns>
|
||||
List<RouteViewModel>? ReadList(RouteSearchModel? model);
|
||||
|
||||
/// <summary>
|
||||
/// Получение списка из заданного количества элементов
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
/// <returns></returns>
|
||||
List<RouteViewModel>? ReadList(int count);
|
||||
|
||||
/// <summary>
|
||||
/// Получение отдельной записи
|
||||
/// </summary>
|
||||
@ -48,5 +55,17 @@ namespace RouteGuideContracts.BusinessLogicsContracts
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
bool Delete(RouteBindingModel model);
|
||||
|
||||
/// <summary>
|
||||
/// Удаление записи
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool Delete();
|
||||
|
||||
/// <summary>
|
||||
/// Удаление всех записей
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
int Clear();
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,13 @@ namespace RouteGuideContracts.BusinessLogicsContracts
|
||||
/// <returns></returns>
|
||||
List<ScheduleViewModel>? ReadList(ScheduleSearchModel? model);
|
||||
|
||||
/// <summary>
|
||||
/// Получение списка из заданного количества элементов
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
/// <returns></returns>
|
||||
List<ScheduleViewModel>? ReadList(int count);
|
||||
|
||||
/// <summary>
|
||||
/// Получение отдельной записи
|
||||
/// </summary>
|
||||
@ -48,5 +55,17 @@ namespace RouteGuideContracts.BusinessLogicsContracts
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
bool Delete(ScheduleBindingModel model);
|
||||
|
||||
/// <summary>
|
||||
/// Удаление записи
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool Delete();
|
||||
|
||||
/// <summary>
|
||||
/// Удаление всех записей
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
int Clear();
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,13 @@ namespace RouteGuideContracts.BusinessLogicsContracts
|
||||
/// <returns></returns>
|
||||
List<StopViewModel>? ReadList(StopSearchModel? model);
|
||||
|
||||
/// <summary>
|
||||
/// Получение списка из заданного количества элементов
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
/// <returns></returns>
|
||||
List<StopViewModel>? ReadList(int count);
|
||||
|
||||
/// <summary>
|
||||
/// Получение отдельной записи
|
||||
/// </summary>
|
||||
@ -48,5 +55,17 @@ namespace RouteGuideContracts.BusinessLogicsContracts
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
bool Delete(StopBindingModel model);
|
||||
|
||||
/// <summary>
|
||||
/// Удаление записи
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool Delete();
|
||||
|
||||
/// <summary>
|
||||
/// Удаление всех записей
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
int Clear();
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,13 @@ namespace RouteGuideContracts.BusinessLogicsContracts
|
||||
/// <returns></returns>
|
||||
List<TransportViewModel>? ReadList(TransportSearchModel? model);
|
||||
|
||||
/// <summary>
|
||||
/// Получение списка из заданного количества элементов
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
/// <returns></returns>
|
||||
List<TransportViewModel>? ReadList(int count);
|
||||
|
||||
/// <summary>
|
||||
/// Получение отдельной записи
|
||||
/// </summary>
|
||||
@ -48,5 +55,17 @@ namespace RouteGuideContracts.BusinessLogicsContracts
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
bool Delete(TransportBindingModel model);
|
||||
|
||||
/// <summary>
|
||||
/// Удаление записи
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool Delete();
|
||||
|
||||
/// <summary>
|
||||
/// Удаление всех записей
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
int Clear();
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,13 @@ namespace RouteGuideContracts.StoragesContracts
|
||||
/// <returns></returns>
|
||||
List<DriverViewModel> GetFilteredList(DriverSearchModel model);
|
||||
|
||||
/// <summary>
|
||||
/// Получить список из заданного количества элементов
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
/// <returns></returns>
|
||||
List<DriverViewModel> GetList(int count);
|
||||
|
||||
/// <summary>
|
||||
/// Получение элемента
|
||||
/// </summary>
|
||||
@ -54,5 +61,17 @@ namespace RouteGuideContracts.StoragesContracts
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
DriverViewModel? Delete(DriverBindingModel model);
|
||||
|
||||
/// <summary>
|
||||
/// Удаление элемента
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
DriverViewModel? Delete();
|
||||
|
||||
/// <summary>
|
||||
/// Удаление всех элементов
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
int Clear();
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,13 @@ namespace RouteGuideContracts.StoragesContracts
|
||||
/// <returns></returns>
|
||||
List<RouteViewModel> GetFilteredList(RouteSearchModel model);
|
||||
|
||||
/// <summary>
|
||||
/// Получить список из заданного количества элементов
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
/// <returns></returns>
|
||||
List<RouteViewModel> GetList(int count);
|
||||
|
||||
/// <summary>
|
||||
/// Получение элемента
|
||||
/// </summary>
|
||||
@ -54,5 +61,17 @@ namespace RouteGuideContracts.StoragesContracts
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
RouteViewModel? Delete(RouteBindingModel model);
|
||||
|
||||
/// <summary>
|
||||
/// Удаление элемента
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
RouteViewModel? Delete();
|
||||
|
||||
/// <summary>
|
||||
/// Удаление всех элементов
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
int Clear();
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,13 @@ namespace RouteGuideContracts.StoragesContracts
|
||||
/// <returns></returns>
|
||||
List<ScheduleViewModel> GetFilteredList(ScheduleSearchModel model);
|
||||
|
||||
/// <summary>
|
||||
/// Получить список из заданного количества элементов
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
/// <returns></returns>
|
||||
List<ScheduleViewModel> GetList(int count);
|
||||
|
||||
/// <summary>
|
||||
/// Получение элемента
|
||||
/// </summary>
|
||||
@ -54,5 +61,17 @@ namespace RouteGuideContracts.StoragesContracts
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
ScheduleViewModel? Delete(ScheduleBindingModel model);
|
||||
|
||||
/// <summary>
|
||||
/// Удаление элемента
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
ScheduleViewModel? Delete();
|
||||
|
||||
/// <summary>
|
||||
/// Удаление всех элементов
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
int Clear();
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,13 @@ namespace RouteGuideContracts.StoragesContracts
|
||||
/// <returns></returns>
|
||||
List<StopViewModel> GetFilteredList(StopSearchModel model);
|
||||
|
||||
/// <summary>
|
||||
/// Получить список из заданного количества элементов
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
/// <returns></returns>
|
||||
List<StopViewModel> GetList(int count);
|
||||
|
||||
/// <summary>
|
||||
/// Получение элемента
|
||||
/// </summary>
|
||||
@ -54,5 +61,17 @@ namespace RouteGuideContracts.StoragesContracts
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
StopViewModel? Delete(StopBindingModel model);
|
||||
|
||||
/// <summary>
|
||||
/// Удаление элемента
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
StopViewModel? Delete();
|
||||
|
||||
/// <summary>
|
||||
/// Удаление всех элементов
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
int Clear();
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,13 @@ namespace RouteGuideContracts.StoragesContracts
|
||||
/// <returns></returns>
|
||||
List<TransportViewModel> GetFilteredList(TransportSearchModel model);
|
||||
|
||||
/// <summary>
|
||||
/// Получить список из заданного количества элементов
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
/// <returns></returns>
|
||||
List<TransportViewModel> GetList(int count);
|
||||
|
||||
/// <summary>
|
||||
/// Получение элемента
|
||||
/// </summary>
|
||||
@ -54,5 +61,17 @@ namespace RouteGuideContracts.StoragesContracts
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
TransportViewModel? Delete(TransportBindingModel model);
|
||||
|
||||
/// <summary>
|
||||
/// Удаление элемента
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
TransportViewModel? Delete();
|
||||
|
||||
/// <summary>
|
||||
/// Удаление всех элементов
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
int Clear();
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ using RouteGuideContracts.ViewModels;
|
||||
using RouteGuideDatabaseImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -47,6 +48,25 @@ namespace RouteGuideDatabaseImplement.Implements
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получить список из заданного количества элементов
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
/// <returns></returns>
|
||||
public List<DriverViewModel> GetList(int count)
|
||||
{
|
||||
if (count <= 0)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
using var context = new RouteGuideDatabase();
|
||||
return context.Drivers
|
||||
.Take(count)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение элемента
|
||||
/// </summary>
|
||||
@ -121,5 +141,41 @@ namespace RouteGuideDatabaseImplement.Implements
|
||||
context.SaveChanges();
|
||||
return driver.GetViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удаление записи
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public DriverViewModel? Delete()
|
||||
{
|
||||
using var context = new RouteGuideDatabase();
|
||||
if (!context.Drivers.Any())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var element = context.Drivers.First();
|
||||
context.Drivers.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удаление всех элементов
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int Clear()
|
||||
{
|
||||
using var context = new RouteGuideDatabase();
|
||||
int count = context.Drivers.Count();
|
||||
if (count <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
context.Drivers.RemoveRange(context.Drivers);
|
||||
context.SaveChanges();
|
||||
return count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -56,6 +56,29 @@ namespace RouteGuideDatabaseImplement.Implements
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получить список из заданного количества элементов
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
/// <returns></returns>
|
||||
public List<RouteViewModel> GetList(int count)
|
||||
{
|
||||
if (count <= 0)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
using var context = new RouteGuideDatabase();
|
||||
return context.Routes
|
||||
.Include(x => x.Transport)
|
||||
.Include(x => x.Stops)
|
||||
.ThenInclude(x => x.Stop)
|
||||
.ToList()
|
||||
.Take(count)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение элемента
|
||||
/// </summary>
|
||||
@ -146,5 +169,41 @@ namespace RouteGuideDatabaseImplement.Implements
|
||||
context.SaveChanges();
|
||||
return route.GetViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удаление записи
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public RouteViewModel? Delete()
|
||||
{
|
||||
using var context = new RouteGuideDatabase();
|
||||
if (!context.Routes.Any())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var element = context.Routes.First();
|
||||
context.Routes.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удаление всех элементов
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int Clear()
|
||||
{
|
||||
using var context = new RouteGuideDatabase();
|
||||
int count = context.Routes.Count();
|
||||
if (count <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
context.Routes.RemoveRange(context.Routes);
|
||||
context.SaveChanges();
|
||||
return count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,26 @@ namespace RouteGuideDatabaseImplement.Implements
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получить список из заданного количества элементов
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
/// <returns></returns>
|
||||
public List<ScheduleViewModel> GetList(int count)
|
||||
{
|
||||
if (count <= 0)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
using var context = new RouteGuideDatabase();
|
||||
return context.Schedules
|
||||
.Include(x => x.Route)
|
||||
.Take(count)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение элемента
|
||||
/// </summary>
|
||||
@ -125,5 +145,41 @@ namespace RouteGuideDatabaseImplement.Implements
|
||||
context.SaveChanges();
|
||||
return schedule.GetViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удаление записи
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public ScheduleViewModel? Delete()
|
||||
{
|
||||
using var context = new RouteGuideDatabase();
|
||||
if (!context.Schedules.Any())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var element = context.Schedules.First();
|
||||
context.Schedules.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удаление всех элементов
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int Clear()
|
||||
{
|
||||
using var context = new RouteGuideDatabase();
|
||||
int count = context.Schedules.Count();
|
||||
if (count <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
context.Schedules.RemoveRange(context.Schedules);
|
||||
context.SaveChanges();
|
||||
return count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +47,25 @@ namespace RouteGuideDatabaseImplement.Implements
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получить список из заданного количества элементов
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
/// <returns></returns>
|
||||
public List<StopViewModel> GetList(int count)
|
||||
{
|
||||
if (count <= 0)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
using var context = new RouteGuideDatabase();
|
||||
return context.Stops
|
||||
.Take(count)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение элемента
|
||||
/// </summary>
|
||||
@ -121,5 +140,41 @@ namespace RouteGuideDatabaseImplement.Implements
|
||||
context.SaveChanges();
|
||||
return stop.GetViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удаление записи
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public StopViewModel? Delete()
|
||||
{
|
||||
using var context = new RouteGuideDatabase();
|
||||
if (!context.Stops.Any())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var element = context.Stops.First();
|
||||
context.Stops.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удаление всех элементов
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int Clear()
|
||||
{
|
||||
using var context = new RouteGuideDatabase();
|
||||
int count = context.Stops.Count();
|
||||
if (count <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
context.Stops.RemoveRange(context.Stops);
|
||||
context.SaveChanges();
|
||||
return count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,26 @@ namespace RouteGuideDatabaseImplement.Implements
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получить список из заданного количества элементов
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
/// <returns></returns>
|
||||
public List<TransportViewModel> GetList(int count)
|
||||
{
|
||||
if (count <= 0)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
using var context = new RouteGuideDatabase();
|
||||
return context.Transport
|
||||
.Include(x => x.Driver)
|
||||
.Take(count)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение элемента
|
||||
/// </summary>
|
||||
@ -125,5 +145,41 @@ namespace RouteGuideDatabaseImplement.Implements
|
||||
context.SaveChanges();
|
||||
return transport.GetViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удаление записи
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public TransportViewModel? Delete()
|
||||
{
|
||||
using var context = new RouteGuideDatabase();
|
||||
if (!context.Transport.Any())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var element = context.Transport.First();
|
||||
context.Transport.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удаление всех элементов
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int Clear()
|
||||
{
|
||||
using var context = new RouteGuideDatabase();
|
||||
int count = context.Transport.Count();
|
||||
if (count <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
context.Transport.RemoveRange(context.Transport);
|
||||
context.SaveChanges();
|
||||
return count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
230
RouteGuide/RouteGuideView/FormDriversTests.Designer.cs
generated
Normal file
230
RouteGuide/RouteGuideView/FormDriversTests.Designer.cs
generated
Normal file
@ -0,0 +1,230 @@
|
||||
namespace RouteGuideView
|
||||
{
|
||||
partial class FormDriversTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
numericUpDownInsert = new NumericUpDown();
|
||||
numericUpDownRead = new NumericUpDown();
|
||||
numericUpDownDelete = new NumericUpDown();
|
||||
labelInsert = new Label();
|
||||
labelRead = new Label();
|
||||
labelDelete = new Label();
|
||||
labelEntities1 = new Label();
|
||||
labelEntities2 = new Label();
|
||||
labelEntities3 = new Label();
|
||||
buttonInsert = new Button();
|
||||
buttonRead = new Button();
|
||||
buttonDelete = new Button();
|
||||
labelInsertTime = new Label();
|
||||
labelReadTime = new Label();
|
||||
labelDeleteTime = new Label();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownInsert).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownRead).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownDelete).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// numericUpDownInsert
|
||||
//
|
||||
numericUpDownInsert.Location = new Point(79, 12);
|
||||
numericUpDownInsert.Name = "numericUpDownInsert";
|
||||
numericUpDownInsert.Size = new Size(70, 23);
|
||||
numericUpDownInsert.TabIndex = 0;
|
||||
//
|
||||
// numericUpDownRead
|
||||
//
|
||||
numericUpDownRead.Location = new Point(79, 41);
|
||||
numericUpDownRead.Name = "numericUpDownRead";
|
||||
numericUpDownRead.Size = new Size(70, 23);
|
||||
numericUpDownRead.TabIndex = 1;
|
||||
//
|
||||
// numericUpDownDelete
|
||||
//
|
||||
numericUpDownDelete.Location = new Point(79, 70);
|
||||
numericUpDownDelete.Name = "numericUpDownDelete";
|
||||
numericUpDownDelete.Size = new Size(70, 23);
|
||||
numericUpDownDelete.TabIndex = 2;
|
||||
//
|
||||
// labelInsert
|
||||
//
|
||||
labelInsert.AutoSize = true;
|
||||
labelInsert.Location = new Point(12, 14);
|
||||
labelInsert.Name = "labelInsert";
|
||||
labelInsert.Size = new Size(50, 15);
|
||||
labelInsert.TabIndex = 3;
|
||||
labelInsert.Text = "Создать";
|
||||
//
|
||||
// labelRead
|
||||
//
|
||||
labelRead.AutoSize = true;
|
||||
labelRead.Location = new Point(12, 43);
|
||||
labelRead.Name = "labelRead";
|
||||
labelRead.Size = new Size(61, 15);
|
||||
labelRead.TabIndex = 4;
|
||||
labelRead.Text = "Получить";
|
||||
//
|
||||
// labelDelete
|
||||
//
|
||||
labelDelete.AutoSize = true;
|
||||
labelDelete.Location = new Point(12, 72);
|
||||
labelDelete.Name = "labelDelete";
|
||||
labelDelete.Size = new Size(51, 15);
|
||||
labelDelete.TabIndex = 5;
|
||||
labelDelete.Text = "Удалить";
|
||||
//
|
||||
// labelEntities1
|
||||
//
|
||||
labelEntities1.AutoSize = true;
|
||||
labelEntities1.Location = new Point(155, 14);
|
||||
labelEntities1.Name = "labelEntities1";
|
||||
labelEntities1.Size = new Size(68, 15);
|
||||
labelEntities1.TabIndex = 6;
|
||||
labelEntities1.Text = "сущностей";
|
||||
//
|
||||
// labelEntities2
|
||||
//
|
||||
labelEntities2.AutoSize = true;
|
||||
labelEntities2.Location = new Point(155, 43);
|
||||
labelEntities2.Name = "labelEntities2";
|
||||
labelEntities2.Size = new Size(68, 15);
|
||||
labelEntities2.TabIndex = 7;
|
||||
labelEntities2.Text = "сущностей";
|
||||
//
|
||||
// labelEntities3
|
||||
//
|
||||
labelEntities3.AutoSize = true;
|
||||
labelEntities3.Location = new Point(155, 72);
|
||||
labelEntities3.Name = "labelEntities3";
|
||||
labelEntities3.Size = new Size(68, 15);
|
||||
labelEntities3.TabIndex = 8;
|
||||
labelEntities3.Text = "сущностей";
|
||||
//
|
||||
// buttonInsert
|
||||
//
|
||||
buttonInsert.Location = new Point(260, 12);
|
||||
buttonInsert.Name = "buttonInsert";
|
||||
buttonInsert.Size = new Size(75, 23);
|
||||
buttonInsert.TabIndex = 9;
|
||||
buttonInsert.Text = "Создать";
|
||||
buttonInsert.UseVisualStyleBackColor = true;
|
||||
buttonInsert.Click += buttonInsert_Click;
|
||||
//
|
||||
// buttonRead
|
||||
//
|
||||
buttonRead.Location = new Point(260, 41);
|
||||
buttonRead.Name = "buttonRead";
|
||||
buttonRead.Size = new Size(75, 23);
|
||||
buttonRead.TabIndex = 10;
|
||||
buttonRead.Text = "Получить";
|
||||
buttonRead.UseVisualStyleBackColor = true;
|
||||
buttonRead.Click += buttonRead_Click;
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
buttonDelete.Location = new Point(260, 70);
|
||||
buttonDelete.Name = "buttonDelete";
|
||||
buttonDelete.Size = new Size(75, 23);
|
||||
buttonDelete.TabIndex = 11;
|
||||
buttonDelete.Text = "Удалить";
|
||||
buttonDelete.UseVisualStyleBackColor = true;
|
||||
buttonDelete.Click += buttonDelete_Click;
|
||||
//
|
||||
// labelInsertTime
|
||||
//
|
||||
labelInsertTime.AutoSize = true;
|
||||
labelInsertTime.Location = new Point(372, 16);
|
||||
labelInsertTime.Name = "labelInsertTime";
|
||||
labelInsertTime.Size = new Size(32, 15);
|
||||
labelInsertTime.TabIndex = 12;
|
||||
labelInsertTime.Text = "0 ms";
|
||||
//
|
||||
// labelReadTime
|
||||
//
|
||||
labelReadTime.AutoSize = true;
|
||||
labelReadTime.Location = new Point(372, 45);
|
||||
labelReadTime.Name = "labelReadTime";
|
||||
labelReadTime.Size = new Size(32, 15);
|
||||
labelReadTime.TabIndex = 13;
|
||||
labelReadTime.Text = "0 ms";
|
||||
//
|
||||
// labelDeleteTime
|
||||
//
|
||||
labelDeleteTime.AutoSize = true;
|
||||
labelDeleteTime.Location = new Point(372, 74);
|
||||
labelDeleteTime.Name = "labelDeleteTime";
|
||||
labelDeleteTime.Size = new Size(32, 15);
|
||||
labelDeleteTime.TabIndex = 14;
|
||||
labelDeleteTime.Text = "0 ms";
|
||||
//
|
||||
// FormDriversTests
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(424, 101);
|
||||
Controls.Add(labelDeleteTime);
|
||||
Controls.Add(labelReadTime);
|
||||
Controls.Add(labelInsertTime);
|
||||
Controls.Add(buttonDelete);
|
||||
Controls.Add(buttonRead);
|
||||
Controls.Add(buttonInsert);
|
||||
Controls.Add(labelEntities3);
|
||||
Controls.Add(labelEntities2);
|
||||
Controls.Add(labelEntities1);
|
||||
Controls.Add(labelDelete);
|
||||
Controls.Add(labelRead);
|
||||
Controls.Add(labelInsert);
|
||||
Controls.Add(numericUpDownDelete);
|
||||
Controls.Add(numericUpDownRead);
|
||||
Controls.Add(numericUpDownInsert);
|
||||
Name = "FormDriversTests";
|
||||
Text = "Тесты для сущности \"Водитель\"";
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownInsert).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownRead).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownDelete).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private NumericUpDown numericUpDownInsert;
|
||||
private NumericUpDown numericUpDownRead;
|
||||
private NumericUpDown numericUpDownDelete;
|
||||
private Label labelInsert;
|
||||
private Label labelRead;
|
||||
private Label labelDelete;
|
||||
private Label labelEntities1;
|
||||
private Label labelEntities2;
|
||||
private Label labelEntities3;
|
||||
private Button buttonInsert;
|
||||
private Button buttonRead;
|
||||
private Button buttonDelete;
|
||||
private Label labelInsertTime;
|
||||
private Label labelReadTime;
|
||||
private Label labelDeleteTime;
|
||||
}
|
||||
}
|
143
RouteGuide/RouteGuideView/FormDriversTests.cs
Normal file
143
RouteGuide/RouteGuideView/FormDriversTests.cs
Normal file
@ -0,0 +1,143 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using RouteGuideContracts.BindingModels;
|
||||
using RouteGuideContracts.BusinessLogicsContracts;
|
||||
using RouteGuideContracts.SearchModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace RouteGuideView
|
||||
{
|
||||
/// <summary>
|
||||
/// Форма с тестами для сущности "Водитель"
|
||||
/// </summary>
|
||||
public partial class FormDriversTests : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Логгер
|
||||
/// </summary>
|
||||
private readonly ILogger _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Бизнес-логика
|
||||
/// </summary>
|
||||
private readonly IDriverLogic _driverLogic;
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="driverLogic"></param>
|
||||
public FormDriversTests(ILogger<FormDriversTests> logger, IDriverLogic driverLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_driverLogic = driverLogic;
|
||||
|
||||
numericUpDownInsert.Maximum = 1000;
|
||||
numericUpDownRead.Maximum = 1000;
|
||||
numericUpDownDelete.Maximum = 1000;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Кнопка "Создать"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonInsert_Click(object sender, EventArgs e)
|
||||
{
|
||||
int entitiesCount = Convert.ToInt32(numericUpDownInsert.Value);
|
||||
_logger.LogInformation("DriverInsertTest. Count: {Count}", entitiesCount);
|
||||
try
|
||||
{
|
||||
double time = 0;
|
||||
var stopwatch = new Stopwatch();
|
||||
for (int i = 1; i <= entitiesCount; i++)
|
||||
{
|
||||
var model = new DriverBindingModel
|
||||
{
|
||||
Id = 0,
|
||||
FullName = $"Водитель {i}",
|
||||
Phone = $"Номер {i}",
|
||||
Experience = 1
|
||||
};
|
||||
|
||||
stopwatch.Start();
|
||||
var operationResult = _driverLogic.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении сущности 'Водитель'. Дополнительная информация в логах.");
|
||||
}
|
||||
stopwatch.Stop();
|
||||
time += stopwatch.ElapsedMilliseconds;
|
||||
}
|
||||
labelInsertTime.Text = $"{Convert.ToInt32(time / entitiesCount)} ms";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "DriverInsertTest. Test failed");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Кнопка "Получить"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonRead_Click(object sender, EventArgs e)
|
||||
{
|
||||
int entitiesCount = Convert.ToInt32(numericUpDownRead.Value);
|
||||
_logger.LogInformation("DriverReadTest. Count: {Count}", entitiesCount);
|
||||
try
|
||||
{
|
||||
var stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
_driverLogic.ReadList(entitiesCount);
|
||||
stopwatch.Stop();
|
||||
labelReadTime.Text = $"{stopwatch.ElapsedMilliseconds} ms";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "DriverReadTest. Test failed");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Кнопка "Удалить"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonDelete_Click(object sender, EventArgs e)
|
||||
{
|
||||
int entitiesCount = Convert.ToInt32(numericUpDownDelete.Value);
|
||||
_logger.LogInformation("DriverDeleteTest. Count: {Count}", entitiesCount);
|
||||
try
|
||||
{
|
||||
double time = 0;
|
||||
var stopwatch = new Stopwatch();
|
||||
for (int i = 1; i <= entitiesCount; i++)
|
||||
{
|
||||
stopwatch.Start();
|
||||
_driverLogic.Delete();
|
||||
stopwatch.Stop();
|
||||
time += stopwatch.ElapsedMilliseconds;
|
||||
}
|
||||
labelDeleteTime.Text = $"{Convert.ToInt32(time / entitiesCount)} ms";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "DriverDeleteTest. Test failed");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
RouteGuide/RouteGuideView/FormDriversTests.resx
Normal file
120
RouteGuide/RouteGuideView/FormDriversTests.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
64
RouteGuide/RouteGuideView/FormMain.Designer.cs
generated
64
RouteGuide/RouteGuideView/FormMain.Designer.cs
generated
@ -34,6 +34,12 @@
|
||||
TransportToolStripMenuItem = new ToolStripMenuItem();
|
||||
RoutesToolStripMenuItem = new ToolStripMenuItem();
|
||||
StopsToolStripMenuItem = new ToolStripMenuItem();
|
||||
тестыToolStripMenuItem = new ToolStripMenuItem();
|
||||
DriversTestsToolStripMenuItem = new ToolStripMenuItem();
|
||||
TransportTestsToolStripMenuItem = new ToolStripMenuItem();
|
||||
RoutesTestsToolStripMenuItem = new ToolStripMenuItem();
|
||||
StopsTestsToolStripMenuItem = new ToolStripMenuItem();
|
||||
SchedulesTestsToolStripMenuItem = new ToolStripMenuItem();
|
||||
buttonCreate = new Button();
|
||||
buttonUpdate = new Button();
|
||||
buttonDelete = new Button();
|
||||
@ -45,7 +51,7 @@
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem });
|
||||
menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, тестыToolStripMenuItem });
|
||||
menuStrip1.Location = new Point(0, 0);
|
||||
menuStrip1.Name = "menuStrip1";
|
||||
menuStrip1.Size = new Size(984, 24);
|
||||
@ -62,31 +68,73 @@
|
||||
// DrviversToolStripMenuItem
|
||||
//
|
||||
DrviversToolStripMenuItem.Name = "DrviversToolStripMenuItem";
|
||||
DrviversToolStripMenuItem.Size = new Size(180, 22);
|
||||
DrviversToolStripMenuItem.Size = new Size(136, 22);
|
||||
DrviversToolStripMenuItem.Text = "Водители";
|
||||
DrviversToolStripMenuItem.Click += DrviversToolStripMenuItem_Click;
|
||||
//
|
||||
// TransportToolStripMenuItem
|
||||
//
|
||||
TransportToolStripMenuItem.Name = "TransportToolStripMenuItem";
|
||||
TransportToolStripMenuItem.Size = new Size(180, 22);
|
||||
TransportToolStripMenuItem.Size = new Size(136, 22);
|
||||
TransportToolStripMenuItem.Text = "Транспорт";
|
||||
TransportToolStripMenuItem.Click += TransportToolStripMenuItem_Click;
|
||||
//
|
||||
// RoutesToolStripMenuItem
|
||||
//
|
||||
RoutesToolStripMenuItem.Name = "RoutesToolStripMenuItem";
|
||||
RoutesToolStripMenuItem.Size = new Size(180, 22);
|
||||
RoutesToolStripMenuItem.Size = new Size(136, 22);
|
||||
RoutesToolStripMenuItem.Text = "Маршруты";
|
||||
RoutesToolStripMenuItem.Click += RoutesToolStripMenuItem_Click;
|
||||
//
|
||||
// StopsToolStripMenuItem
|
||||
//
|
||||
StopsToolStripMenuItem.Name = "StopsToolStripMenuItem";
|
||||
StopsToolStripMenuItem.Size = new Size(180, 22);
|
||||
StopsToolStripMenuItem.Size = new Size(136, 22);
|
||||
StopsToolStripMenuItem.Text = "Остановки";
|
||||
StopsToolStripMenuItem.Click += StopsToolStripMenuItem_Click;
|
||||
//
|
||||
// тестыToolStripMenuItem
|
||||
//
|
||||
тестыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { DriversTestsToolStripMenuItem, TransportTestsToolStripMenuItem, RoutesTestsToolStripMenuItem, StopsTestsToolStripMenuItem, SchedulesTestsToolStripMenuItem });
|
||||
тестыToolStripMenuItem.Name = "тестыToolStripMenuItem";
|
||||
тестыToolStripMenuItem.Size = new Size(51, 20);
|
||||
тестыToolStripMenuItem.Text = "Тесты";
|
||||
//
|
||||
// DriversTestsToolStripMenuItem
|
||||
//
|
||||
DriversTestsToolStripMenuItem.Name = "DriversTestsToolStripMenuItem";
|
||||
DriversTestsToolStripMenuItem.Size = new Size(180, 22);
|
||||
DriversTestsToolStripMenuItem.Text = "Водители";
|
||||
DriversTestsToolStripMenuItem.Click += DriversTestsToolStripMenuItem_Click;
|
||||
//
|
||||
// TransportTestsToolStripMenuItem
|
||||
//
|
||||
TransportTestsToolStripMenuItem.Name = "TransportTestsToolStripMenuItem";
|
||||
TransportTestsToolStripMenuItem.Size = new Size(180, 22);
|
||||
TransportTestsToolStripMenuItem.Text = "Транспорт";
|
||||
TransportTestsToolStripMenuItem.Click += TransportTestsToolStripMenuItem_Click;
|
||||
//
|
||||
// RoutesTestsToolStripMenuItem
|
||||
//
|
||||
RoutesTestsToolStripMenuItem.Name = "RoutesTestsToolStripMenuItem";
|
||||
RoutesTestsToolStripMenuItem.Size = new Size(180, 22);
|
||||
RoutesTestsToolStripMenuItem.Text = "Маршруты";
|
||||
RoutesTestsToolStripMenuItem.Click += RoutesTestsToolStripMenuItem_Click;
|
||||
//
|
||||
// StopsTestsToolStripMenuItem
|
||||
//
|
||||
StopsTestsToolStripMenuItem.Name = "StopsTestsToolStripMenuItem";
|
||||
StopsTestsToolStripMenuItem.Size = new Size(180, 22);
|
||||
StopsTestsToolStripMenuItem.Text = "Остановки";
|
||||
StopsTestsToolStripMenuItem.Click += StopsTestsToolStripMenuItem_Click;
|
||||
//
|
||||
// SchedulesTestsToolStripMenuItem
|
||||
//
|
||||
SchedulesTestsToolStripMenuItem.Name = "SchedulesTestsToolStripMenuItem";
|
||||
SchedulesTestsToolStripMenuItem.Size = new Size(180, 22);
|
||||
SchedulesTestsToolStripMenuItem.Text = "Расписания";
|
||||
SchedulesTestsToolStripMenuItem.Click += SchedulesTestsToolStripMenuItem_Click;
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.Location = new Point(885, 37);
|
||||
@ -179,5 +227,11 @@
|
||||
private Button buttonDelete;
|
||||
private Button buttonRefresh;
|
||||
private DataGridView dataGridView;
|
||||
private ToolStripMenuItem тестыToolStripMenuItem;
|
||||
private ToolStripMenuItem DriversTestsToolStripMenuItem;
|
||||
private ToolStripMenuItem TransportTestsToolStripMenuItem;
|
||||
private ToolStripMenuItem RoutesTestsToolStripMenuItem;
|
||||
private ToolStripMenuItem StopsTestsToolStripMenuItem;
|
||||
private ToolStripMenuItem SchedulesTestsToolStripMenuItem;
|
||||
}
|
||||
}
|
||||
|
@ -98,6 +98,76 @@ namespace RouteGuideView
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ôîðìà äëÿ òåñòîâ ñóùíîñòè "Âîäèòåëü"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void DriversTestsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormDriversTests));
|
||||
if (service is FormDriversTests form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ôîðìà äëÿ òåñòîâ ñóùíîñòè "Òðàíñïîðò"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void TransportTestsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormTransportTests));
|
||||
if (service is FormTransportTests form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ôîðìà äëÿ òåñòîâ ñóùíîñòè "Ìàðøðóò"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void RoutesTestsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormRoutesTests));
|
||||
if (service is FormRoutesTests form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ôîðìà äëÿ òåñòîâ ñóùíîñòè "Îñòàíîâêà"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void StopsTestsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormStopsTests));
|
||||
if (service is FormStopsTests form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ôîðìà äëÿ òåñòîâ ñóùíîñòè "Ðàñïèñàíèå"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void SchedulesTestsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormSchedulesTests));
|
||||
if (service is FormSchedulesTests form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Кнопка "Создать"
|
||||
/// </summary>
|
||||
|
@ -141,6 +141,7 @@ namespace RouteGuideView
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["RouteStops"].Visible = false;
|
||||
dataGridView.Columns["TransportId"].Visible = false;
|
||||
dataGridView.Columns["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка списка маршрутов");
|
||||
|
230
RouteGuide/RouteGuideView/FormRoutesTests.Designer.cs
generated
Normal file
230
RouteGuide/RouteGuideView/FormRoutesTests.Designer.cs
generated
Normal file
@ -0,0 +1,230 @@
|
||||
namespace RouteGuideView
|
||||
{
|
||||
partial class FormRoutesTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
labelDeleteTime = new Label();
|
||||
labelReadTime = new Label();
|
||||
labelInsertTime = new Label();
|
||||
buttonDelete = new Button();
|
||||
buttonRead = new Button();
|
||||
buttonInsert = new Button();
|
||||
labelEntities3 = new Label();
|
||||
labelEntities2 = new Label();
|
||||
labelEntities1 = new Label();
|
||||
labelDelete = new Label();
|
||||
labelRead = new Label();
|
||||
labelInsert = new Label();
|
||||
numericUpDownDelete = new NumericUpDown();
|
||||
numericUpDownRead = new NumericUpDown();
|
||||
numericUpDownInsert = new NumericUpDown();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownDelete).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownRead).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownInsert).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelDeleteTime
|
||||
//
|
||||
labelDeleteTime.AutoSize = true;
|
||||
labelDeleteTime.Location = new Point(376, 72);
|
||||
labelDeleteTime.Name = "labelDeleteTime";
|
||||
labelDeleteTime.Size = new Size(32, 15);
|
||||
labelDeleteTime.TabIndex = 44;
|
||||
labelDeleteTime.Text = "0 ms";
|
||||
//
|
||||
// labelReadTime
|
||||
//
|
||||
labelReadTime.AutoSize = true;
|
||||
labelReadTime.Location = new Point(376, 43);
|
||||
labelReadTime.Name = "labelReadTime";
|
||||
labelReadTime.Size = new Size(32, 15);
|
||||
labelReadTime.TabIndex = 43;
|
||||
labelReadTime.Text = "0 ms";
|
||||
//
|
||||
// labelInsertTime
|
||||
//
|
||||
labelInsertTime.AutoSize = true;
|
||||
labelInsertTime.Location = new Point(376, 14);
|
||||
labelInsertTime.Name = "labelInsertTime";
|
||||
labelInsertTime.Size = new Size(32, 15);
|
||||
labelInsertTime.TabIndex = 42;
|
||||
labelInsertTime.Text = "0 ms";
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
buttonDelete.Location = new Point(264, 68);
|
||||
buttonDelete.Name = "buttonDelete";
|
||||
buttonDelete.Size = new Size(75, 23);
|
||||
buttonDelete.TabIndex = 41;
|
||||
buttonDelete.Text = "Удалить";
|
||||
buttonDelete.UseVisualStyleBackColor = true;
|
||||
buttonDelete.Click += buttonDelete_Click;
|
||||
//
|
||||
// buttonRead
|
||||
//
|
||||
buttonRead.Location = new Point(264, 39);
|
||||
buttonRead.Name = "buttonRead";
|
||||
buttonRead.Size = new Size(75, 23);
|
||||
buttonRead.TabIndex = 40;
|
||||
buttonRead.Text = "Получить";
|
||||
buttonRead.UseVisualStyleBackColor = true;
|
||||
buttonRead.Click += buttonRead_Click;
|
||||
//
|
||||
// buttonInsert
|
||||
//
|
||||
buttonInsert.Location = new Point(264, 10);
|
||||
buttonInsert.Name = "buttonInsert";
|
||||
buttonInsert.Size = new Size(75, 23);
|
||||
buttonInsert.TabIndex = 39;
|
||||
buttonInsert.Text = "Создать";
|
||||
buttonInsert.UseVisualStyleBackColor = true;
|
||||
buttonInsert.Click += buttonInsert_Click;
|
||||
//
|
||||
// labelEntities3
|
||||
//
|
||||
labelEntities3.AutoSize = true;
|
||||
labelEntities3.Location = new Point(159, 70);
|
||||
labelEntities3.Name = "labelEntities3";
|
||||
labelEntities3.Size = new Size(68, 15);
|
||||
labelEntities3.TabIndex = 38;
|
||||
labelEntities3.Text = "сущностей";
|
||||
//
|
||||
// labelEntities2
|
||||
//
|
||||
labelEntities2.AutoSize = true;
|
||||
labelEntities2.Location = new Point(159, 41);
|
||||
labelEntities2.Name = "labelEntities2";
|
||||
labelEntities2.Size = new Size(68, 15);
|
||||
labelEntities2.TabIndex = 37;
|
||||
labelEntities2.Text = "сущностей";
|
||||
//
|
||||
// labelEntities1
|
||||
//
|
||||
labelEntities1.AutoSize = true;
|
||||
labelEntities1.Location = new Point(159, 12);
|
||||
labelEntities1.Name = "labelEntities1";
|
||||
labelEntities1.Size = new Size(68, 15);
|
||||
labelEntities1.TabIndex = 36;
|
||||
labelEntities1.Text = "сущностей";
|
||||
//
|
||||
// labelDelete
|
||||
//
|
||||
labelDelete.AutoSize = true;
|
||||
labelDelete.Location = new Point(16, 70);
|
||||
labelDelete.Name = "labelDelete";
|
||||
labelDelete.Size = new Size(51, 15);
|
||||
labelDelete.TabIndex = 35;
|
||||
labelDelete.Text = "Удалить";
|
||||
//
|
||||
// labelRead
|
||||
//
|
||||
labelRead.AutoSize = true;
|
||||
labelRead.Location = new Point(16, 41);
|
||||
labelRead.Name = "labelRead";
|
||||
labelRead.Size = new Size(61, 15);
|
||||
labelRead.TabIndex = 34;
|
||||
labelRead.Text = "Получить";
|
||||
//
|
||||
// labelInsert
|
||||
//
|
||||
labelInsert.AutoSize = true;
|
||||
labelInsert.Location = new Point(16, 12);
|
||||
labelInsert.Name = "labelInsert";
|
||||
labelInsert.Size = new Size(50, 15);
|
||||
labelInsert.TabIndex = 33;
|
||||
labelInsert.Text = "Создать";
|
||||
//
|
||||
// numericUpDownDelete
|
||||
//
|
||||
numericUpDownDelete.Location = new Point(83, 68);
|
||||
numericUpDownDelete.Name = "numericUpDownDelete";
|
||||
numericUpDownDelete.Size = new Size(70, 23);
|
||||
numericUpDownDelete.TabIndex = 32;
|
||||
//
|
||||
// numericUpDownRead
|
||||
//
|
||||
numericUpDownRead.Location = new Point(83, 39);
|
||||
numericUpDownRead.Name = "numericUpDownRead";
|
||||
numericUpDownRead.Size = new Size(70, 23);
|
||||
numericUpDownRead.TabIndex = 31;
|
||||
//
|
||||
// numericUpDownInsert
|
||||
//
|
||||
numericUpDownInsert.Location = new Point(83, 10);
|
||||
numericUpDownInsert.Name = "numericUpDownInsert";
|
||||
numericUpDownInsert.Size = new Size(70, 23);
|
||||
numericUpDownInsert.TabIndex = 30;
|
||||
//
|
||||
// FormRoutesTests
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(424, 101);
|
||||
Controls.Add(labelDeleteTime);
|
||||
Controls.Add(labelReadTime);
|
||||
Controls.Add(labelInsertTime);
|
||||
Controls.Add(buttonDelete);
|
||||
Controls.Add(buttonRead);
|
||||
Controls.Add(buttonInsert);
|
||||
Controls.Add(labelEntities3);
|
||||
Controls.Add(labelEntities2);
|
||||
Controls.Add(labelEntities1);
|
||||
Controls.Add(labelDelete);
|
||||
Controls.Add(labelRead);
|
||||
Controls.Add(labelInsert);
|
||||
Controls.Add(numericUpDownDelete);
|
||||
Controls.Add(numericUpDownRead);
|
||||
Controls.Add(numericUpDownInsert);
|
||||
Name = "FormRoutesTests";
|
||||
Text = "Тесты для сущности \"Маршрут\"";
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownDelete).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownRead).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownInsert).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelDeleteTime;
|
||||
private Label labelReadTime;
|
||||
private Label labelInsertTime;
|
||||
private Button buttonDelete;
|
||||
private Button buttonRead;
|
||||
private Button buttonInsert;
|
||||
private Label labelEntities3;
|
||||
private Label labelEntities2;
|
||||
private Label labelEntities1;
|
||||
private Label labelDelete;
|
||||
private Label labelRead;
|
||||
private Label labelInsert;
|
||||
private NumericUpDown numericUpDownDelete;
|
||||
private NumericUpDown numericUpDownRead;
|
||||
private NumericUpDown numericUpDownInsert;
|
||||
}
|
||||
}
|
150
RouteGuide/RouteGuideView/FormRoutesTests.cs
Normal file
150
RouteGuide/RouteGuideView/FormRoutesTests.cs
Normal file
@ -0,0 +1,150 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using RouteGuideBusinessLogics.BusinessLogics;
|
||||
using RouteGuideContracts.BindingModels;
|
||||
using RouteGuideContracts.BusinessLogicsContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace RouteGuideView
|
||||
{
|
||||
/// <summary>
|
||||
/// Форма с тестами для сущности "Маршрут"
|
||||
/// </summary>
|
||||
public partial class FormRoutesTests : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Логгер
|
||||
/// </summary>
|
||||
private readonly ILogger _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Бизнес-логика для маршрутов
|
||||
/// </summary>
|
||||
private readonly IRouteLogic _routeLogic;
|
||||
|
||||
/// <summary>
|
||||
/// Бизнес-логика для транспорта
|
||||
/// </summary>
|
||||
private readonly ITransportLogic _transportLogic;
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="routeLogic"></param>
|
||||
/// <param name="transportLogic"></param>
|
||||
public FormRoutesTests(ILogger<FormRoutesTests> logger, IRouteLogic routeLogic, ITransportLogic transportLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_routeLogic = routeLogic;
|
||||
_transportLogic = transportLogic;
|
||||
|
||||
numericUpDownInsert.Maximum = 1000;
|
||||
numericUpDownRead.Maximum = 1000;
|
||||
numericUpDownDelete.Maximum = 1000;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Кнопка "Создать"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonInsert_Click(object sender, EventArgs e)
|
||||
{
|
||||
int entitiesCount = Convert.ToInt32(numericUpDownInsert.Value);
|
||||
_logger.LogInformation("RouteInsertTest. Count: {Count}", entitiesCount);
|
||||
try
|
||||
{
|
||||
double time = 0;
|
||||
var stopwatch = new Stopwatch();
|
||||
int transportId = _transportLogic.ReadList(1)![0].Id;
|
||||
for (int i = 1; i <= entitiesCount; i++)
|
||||
{
|
||||
var model = new RouteBindingModel
|
||||
{
|
||||
Id = 0,
|
||||
Name = $"Маршрут {i}",
|
||||
TransportId = transportId
|
||||
};
|
||||
|
||||
stopwatch.Start();
|
||||
var operationResult = _routeLogic.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении сущности 'Маршрут'. Дополнительная информация в логах.");
|
||||
}
|
||||
stopwatch.Stop();
|
||||
time += stopwatch.ElapsedMilliseconds;
|
||||
}
|
||||
labelInsertTime.Text = $"{Convert.ToInt32(time / entitiesCount)} ms";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "RouteInsertTest. Test failed");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Кнопка "Получить"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonRead_Click(object sender, EventArgs e)
|
||||
{
|
||||
int entitiesCount = Convert.ToInt32(numericUpDownRead.Value);
|
||||
_logger.LogInformation("RouteReadTest. Count: {Count}", entitiesCount);
|
||||
try
|
||||
{
|
||||
var stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
_routeLogic.ReadList(entitiesCount);
|
||||
stopwatch.Stop();
|
||||
labelReadTime.Text = $"{stopwatch.ElapsedMilliseconds} ms";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "RouteReadTest. Test failed");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Кнопка "Удалить"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonDelete_Click(object sender, EventArgs e)
|
||||
{
|
||||
int entitiesCount = Convert.ToInt32(numericUpDownDelete.Value);
|
||||
_logger.LogInformation("RouteDeleteTest. Count: {Count}", entitiesCount);
|
||||
try
|
||||
{
|
||||
double time = 0;
|
||||
var stopwatch = new Stopwatch();
|
||||
for (int i = 1; i <= entitiesCount; i++)
|
||||
{
|
||||
stopwatch.Start();
|
||||
_routeLogic.Delete();
|
||||
stopwatch.Stop();
|
||||
time += stopwatch.ElapsedMilliseconds;
|
||||
}
|
||||
labelDeleteTime.Text = $"{Convert.ToInt32(time / entitiesCount)} ms";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "RouteDeleteTest. Test failed");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
RouteGuide/RouteGuideView/FormRoutesTests.resx
Normal file
120
RouteGuide/RouteGuideView/FormRoutesTests.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
20
RouteGuide/RouteGuideView/FormSchedule.Designer.cs
generated
20
RouteGuide/RouteGuideView/FormSchedule.Designer.cs
generated
@ -44,42 +44,42 @@
|
||||
//
|
||||
// dateTimePickerDate
|
||||
//
|
||||
dateTimePickerDate.Location = new Point(101, 41);
|
||||
dateTimePickerDate.Location = new Point(113, 41);
|
||||
dateTimePickerDate.Name = "dateTimePickerDate";
|
||||
dateTimePickerDate.Size = new Size(271, 23);
|
||||
dateTimePickerDate.Size = new Size(259, 23);
|
||||
dateTimePickerDate.TabIndex = 0;
|
||||
//
|
||||
// dateTimePickerDepartureTime
|
||||
//
|
||||
dateTimePickerDepartureTime.Format = DateTimePickerFormat.Time;
|
||||
dateTimePickerDepartureTime.Location = new Point(101, 70);
|
||||
dateTimePickerDepartureTime.Location = new Point(113, 70);
|
||||
dateTimePickerDepartureTime.Name = "dateTimePickerDepartureTime";
|
||||
dateTimePickerDepartureTime.Size = new Size(271, 23);
|
||||
dateTimePickerDepartureTime.Size = new Size(259, 23);
|
||||
dateTimePickerDepartureTime.TabIndex = 1;
|
||||
//
|
||||
// dateTimePickerArrivalTime
|
||||
//
|
||||
dateTimePickerArrivalTime.Format = DateTimePickerFormat.Time;
|
||||
dateTimePickerArrivalTime.Location = new Point(101, 99);
|
||||
dateTimePickerArrivalTime.Location = new Point(113, 99);
|
||||
dateTimePickerArrivalTime.Name = "dateTimePickerArrivalTime";
|
||||
dateTimePickerArrivalTime.Size = new Size(271, 23);
|
||||
dateTimePickerArrivalTime.Size = new Size(259, 23);
|
||||
dateTimePickerArrivalTime.TabIndex = 2;
|
||||
//
|
||||
// dateTimePickerFrequency
|
||||
//
|
||||
dateTimePickerFrequency.Format = DateTimePickerFormat.Time;
|
||||
dateTimePickerFrequency.Location = new Point(101, 128);
|
||||
dateTimePickerFrequency.Location = new Point(113, 128);
|
||||
dateTimePickerFrequency.Name = "dateTimePickerFrequency";
|
||||
dateTimePickerFrequency.Size = new Size(271, 23);
|
||||
dateTimePickerFrequency.Size = new Size(259, 23);
|
||||
dateTimePickerFrequency.TabIndex = 3;
|
||||
//
|
||||
// comboBoxRoute
|
||||
//
|
||||
comboBoxRoute.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxRoute.FormattingEnabled = true;
|
||||
comboBoxRoute.Location = new Point(101, 12);
|
||||
comboBoxRoute.Location = new Point(113, 12);
|
||||
comboBoxRoute.Name = "comboBoxRoute";
|
||||
comboBoxRoute.Size = new Size(271, 23);
|
||||
comboBoxRoute.Size = new Size(259, 23);
|
||||
comboBoxRoute.TabIndex = 4;
|
||||
//
|
||||
// buttonSave
|
||||
|
230
RouteGuide/RouteGuideView/FormSchedulesTests.Designer.cs
generated
Normal file
230
RouteGuide/RouteGuideView/FormSchedulesTests.Designer.cs
generated
Normal file
@ -0,0 +1,230 @@
|
||||
namespace RouteGuideView
|
||||
{
|
||||
partial class FormSchedulesTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
labelDeleteTime = new Label();
|
||||
labelReadTime = new Label();
|
||||
labelInsertTime = new Label();
|
||||
buttonDelete = new Button();
|
||||
buttonRead = new Button();
|
||||
buttonInsert = new Button();
|
||||
labelEntities3 = new Label();
|
||||
labelEntities2 = new Label();
|
||||
labelEntities1 = new Label();
|
||||
labelDelete = new Label();
|
||||
labelRead = new Label();
|
||||
labelInsert = new Label();
|
||||
numericUpDownDelete = new NumericUpDown();
|
||||
numericUpDownRead = new NumericUpDown();
|
||||
numericUpDownInsert = new NumericUpDown();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownDelete).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownRead).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownInsert).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelDeleteTime
|
||||
//
|
||||
labelDeleteTime.AutoSize = true;
|
||||
labelDeleteTime.Location = new Point(376, 72);
|
||||
labelDeleteTime.Name = "labelDeleteTime";
|
||||
labelDeleteTime.Size = new Size(32, 15);
|
||||
labelDeleteTime.TabIndex = 59;
|
||||
labelDeleteTime.Text = "0 ms";
|
||||
//
|
||||
// labelReadTime
|
||||
//
|
||||
labelReadTime.AutoSize = true;
|
||||
labelReadTime.Location = new Point(376, 43);
|
||||
labelReadTime.Name = "labelReadTime";
|
||||
labelReadTime.Size = new Size(32, 15);
|
||||
labelReadTime.TabIndex = 58;
|
||||
labelReadTime.Text = "0 ms";
|
||||
//
|
||||
// labelInsertTime
|
||||
//
|
||||
labelInsertTime.AutoSize = true;
|
||||
labelInsertTime.Location = new Point(376, 14);
|
||||
labelInsertTime.Name = "labelInsertTime";
|
||||
labelInsertTime.Size = new Size(32, 15);
|
||||
labelInsertTime.TabIndex = 57;
|
||||
labelInsertTime.Text = "0 ms";
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
buttonDelete.Location = new Point(264, 68);
|
||||
buttonDelete.Name = "buttonDelete";
|
||||
buttonDelete.Size = new Size(75, 23);
|
||||
buttonDelete.TabIndex = 56;
|
||||
buttonDelete.Text = "Удалить";
|
||||
buttonDelete.UseVisualStyleBackColor = true;
|
||||
buttonDelete.Click += buttonDelete_Click;
|
||||
//
|
||||
// buttonRead
|
||||
//
|
||||
buttonRead.Location = new Point(264, 39);
|
||||
buttonRead.Name = "buttonRead";
|
||||
buttonRead.Size = new Size(75, 23);
|
||||
buttonRead.TabIndex = 55;
|
||||
buttonRead.Text = "Получить";
|
||||
buttonRead.UseVisualStyleBackColor = true;
|
||||
buttonRead.Click += buttonRead_Click;
|
||||
//
|
||||
// buttonInsert
|
||||
//
|
||||
buttonInsert.Location = new Point(264, 10);
|
||||
buttonInsert.Name = "buttonInsert";
|
||||
buttonInsert.Size = new Size(75, 23);
|
||||
buttonInsert.TabIndex = 54;
|
||||
buttonInsert.Text = "Создать";
|
||||
buttonInsert.UseVisualStyleBackColor = true;
|
||||
buttonInsert.Click += buttonInsert_Click;
|
||||
//
|
||||
// labelEntities3
|
||||
//
|
||||
labelEntities3.AutoSize = true;
|
||||
labelEntities3.Location = new Point(159, 70);
|
||||
labelEntities3.Name = "labelEntities3";
|
||||
labelEntities3.Size = new Size(68, 15);
|
||||
labelEntities3.TabIndex = 53;
|
||||
labelEntities3.Text = "сущностей";
|
||||
//
|
||||
// labelEntities2
|
||||
//
|
||||
labelEntities2.AutoSize = true;
|
||||
labelEntities2.Location = new Point(159, 41);
|
||||
labelEntities2.Name = "labelEntities2";
|
||||
labelEntities2.Size = new Size(68, 15);
|
||||
labelEntities2.TabIndex = 52;
|
||||
labelEntities2.Text = "сущностей";
|
||||
//
|
||||
// labelEntities1
|
||||
//
|
||||
labelEntities1.AutoSize = true;
|
||||
labelEntities1.Location = new Point(159, 12);
|
||||
labelEntities1.Name = "labelEntities1";
|
||||
labelEntities1.Size = new Size(68, 15);
|
||||
labelEntities1.TabIndex = 51;
|
||||
labelEntities1.Text = "сущностей";
|
||||
//
|
||||
// labelDelete
|
||||
//
|
||||
labelDelete.AutoSize = true;
|
||||
labelDelete.Location = new Point(16, 70);
|
||||
labelDelete.Name = "labelDelete";
|
||||
labelDelete.Size = new Size(51, 15);
|
||||
labelDelete.TabIndex = 50;
|
||||
labelDelete.Text = "Удалить";
|
||||
//
|
||||
// labelRead
|
||||
//
|
||||
labelRead.AutoSize = true;
|
||||
labelRead.Location = new Point(16, 41);
|
||||
labelRead.Name = "labelRead";
|
||||
labelRead.Size = new Size(61, 15);
|
||||
labelRead.TabIndex = 49;
|
||||
labelRead.Text = "Получить";
|
||||
//
|
||||
// labelInsert
|
||||
//
|
||||
labelInsert.AutoSize = true;
|
||||
labelInsert.Location = new Point(16, 12);
|
||||
labelInsert.Name = "labelInsert";
|
||||
labelInsert.Size = new Size(50, 15);
|
||||
labelInsert.TabIndex = 48;
|
||||
labelInsert.Text = "Создать";
|
||||
//
|
||||
// numericUpDownDelete
|
||||
//
|
||||
numericUpDownDelete.Location = new Point(83, 68);
|
||||
numericUpDownDelete.Name = "numericUpDownDelete";
|
||||
numericUpDownDelete.Size = new Size(70, 23);
|
||||
numericUpDownDelete.TabIndex = 47;
|
||||
//
|
||||
// numericUpDownRead
|
||||
//
|
||||
numericUpDownRead.Location = new Point(83, 39);
|
||||
numericUpDownRead.Name = "numericUpDownRead";
|
||||
numericUpDownRead.Size = new Size(70, 23);
|
||||
numericUpDownRead.TabIndex = 46;
|
||||
//
|
||||
// numericUpDownInsert
|
||||
//
|
||||
numericUpDownInsert.Location = new Point(83, 10);
|
||||
numericUpDownInsert.Name = "numericUpDownInsert";
|
||||
numericUpDownInsert.Size = new Size(70, 23);
|
||||
numericUpDownInsert.TabIndex = 45;
|
||||
//
|
||||
// FormSchedulesTests
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(424, 101);
|
||||
Controls.Add(labelDeleteTime);
|
||||
Controls.Add(labelReadTime);
|
||||
Controls.Add(labelInsertTime);
|
||||
Controls.Add(buttonDelete);
|
||||
Controls.Add(buttonRead);
|
||||
Controls.Add(buttonInsert);
|
||||
Controls.Add(labelEntities3);
|
||||
Controls.Add(labelEntities2);
|
||||
Controls.Add(labelEntities1);
|
||||
Controls.Add(labelDelete);
|
||||
Controls.Add(labelRead);
|
||||
Controls.Add(labelInsert);
|
||||
Controls.Add(numericUpDownDelete);
|
||||
Controls.Add(numericUpDownRead);
|
||||
Controls.Add(numericUpDownInsert);
|
||||
Name = "FormSchedulesTests";
|
||||
Text = "Тесты для сущности \"Расписание\"";
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownDelete).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownRead).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownInsert).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelDeleteTime;
|
||||
private Label labelReadTime;
|
||||
private Label labelInsertTime;
|
||||
private Button buttonDelete;
|
||||
private Button buttonRead;
|
||||
private Button buttonInsert;
|
||||
private Label labelEntities3;
|
||||
private Label labelEntities2;
|
||||
private Label labelEntities1;
|
||||
private Label labelDelete;
|
||||
private Label labelRead;
|
||||
private Label labelInsert;
|
||||
private NumericUpDown numericUpDownDelete;
|
||||
private NumericUpDown numericUpDownRead;
|
||||
private NumericUpDown numericUpDownInsert;
|
||||
}
|
||||
}
|
153
RouteGuide/RouteGuideView/FormSchedulesTests.cs
Normal file
153
RouteGuide/RouteGuideView/FormSchedulesTests.cs
Normal file
@ -0,0 +1,153 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using RouteGuideBusinessLogics.BusinessLogics;
|
||||
using RouteGuideContracts.BindingModels;
|
||||
using RouteGuideContracts.BusinessLogicsContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace RouteGuideView
|
||||
{
|
||||
/// <summary>
|
||||
/// Форма с тестами для сущности "Расписание"
|
||||
/// </summary>
|
||||
public partial class FormSchedulesTests : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Логгер
|
||||
/// </summary>
|
||||
private readonly ILogger _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Бизнес-логика для расписания
|
||||
/// </summary>
|
||||
private readonly IScheduleLogic _scheduleLogic;
|
||||
|
||||
/// <summary>
|
||||
/// Бизнес-логика для маршрутов
|
||||
/// </summary>
|
||||
private readonly IRouteLogic _routeLogic;
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="scheduleLogic"></param>
|
||||
/// <param name="routeLogic"></param>
|
||||
public FormSchedulesTests(ILogger<FormSchedulesTests> logger, IScheduleLogic scheduleLogic, IRouteLogic routeLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_scheduleLogic = scheduleLogic;
|
||||
_routeLogic = routeLogic;
|
||||
|
||||
numericUpDownInsert.Maximum = 1000;
|
||||
numericUpDownRead.Maximum = 1000;
|
||||
numericUpDownDelete.Maximum = 1000;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Кнопка "Создать"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonInsert_Click(object sender, EventArgs e)
|
||||
{
|
||||
int entitiesCount = Convert.ToInt32(numericUpDownInsert.Value);
|
||||
_logger.LogInformation("ScheduleInsertTest. Count: {Count}", entitiesCount);
|
||||
try
|
||||
{
|
||||
double time = 0;
|
||||
var stopwatch = new Stopwatch();
|
||||
int routeId = _routeLogic.ReadList(1)![0].Id;
|
||||
for (int i = 1; i <= entitiesCount; i++)
|
||||
{
|
||||
var model = new ScheduleBindingModel
|
||||
{
|
||||
Id = 0,
|
||||
Date = DateTime.Now,
|
||||
DepartureTime = DateTime.MinValue,
|
||||
ArrivalTime = DateTime.MaxValue,
|
||||
Frequency = DateTime.MinValue,
|
||||
RouteId = routeId
|
||||
};
|
||||
|
||||
stopwatch.Start();
|
||||
var operationResult = _scheduleLogic.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении сущности 'Расписание'. Дополнительная информация в логах.");
|
||||
}
|
||||
stopwatch.Stop();
|
||||
time += stopwatch.ElapsedMilliseconds;
|
||||
}
|
||||
labelInsertTime.Text = $"{Convert.ToInt32(time / entitiesCount)} ms";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "ScheduleInsertTest. Test failed");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Кнопка "Получить"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonRead_Click(object sender, EventArgs e)
|
||||
{
|
||||
int entitiesCount = Convert.ToInt32(numericUpDownRead.Value);
|
||||
_logger.LogInformation("ScheduleReadTest. Count: {Count}", entitiesCount);
|
||||
try
|
||||
{
|
||||
var stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
_scheduleLogic.ReadList(entitiesCount);
|
||||
stopwatch.Stop();
|
||||
labelReadTime.Text = $"{stopwatch.ElapsedMilliseconds} ms";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "ScheduleReadTest. Test failed");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Кнопка "Удалить"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonDelete_Click(object sender, EventArgs e)
|
||||
{
|
||||
int entitiesCount = Convert.ToInt32(numericUpDownDelete.Value);
|
||||
_logger.LogInformation("ScheduleDeleteTest. Count: {Count}", entitiesCount);
|
||||
try
|
||||
{
|
||||
double time = 0;
|
||||
var stopwatch = new Stopwatch();
|
||||
for (int i = 1; i <= entitiesCount; i++)
|
||||
{
|
||||
stopwatch.Start();
|
||||
_scheduleLogic.Delete();
|
||||
stopwatch.Stop();
|
||||
time += stopwatch.ElapsedMilliseconds;
|
||||
}
|
||||
labelDeleteTime.Text = $"{Convert.ToInt32(time / entitiesCount)} ms";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "ScheduleDeleteTest. Test failed");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
RouteGuide/RouteGuideView/FormSchedulesTests.resx
Normal file
120
RouteGuide/RouteGuideView/FormSchedulesTests.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
230
RouteGuide/RouteGuideView/FormStopsTests.Designer.cs
generated
Normal file
230
RouteGuide/RouteGuideView/FormStopsTests.Designer.cs
generated
Normal file
@ -0,0 +1,230 @@
|
||||
namespace RouteGuideView
|
||||
{
|
||||
partial class FormStopsTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
labelDeleteTime = new Label();
|
||||
labelReadTime = new Label();
|
||||
labelInsertTime = new Label();
|
||||
buttonDelete = new Button();
|
||||
buttonRead = new Button();
|
||||
buttonInsert = new Button();
|
||||
labelEntities3 = new Label();
|
||||
labelEntities2 = new Label();
|
||||
labelEntities1 = new Label();
|
||||
labelDelete = new Label();
|
||||
labelRead = new Label();
|
||||
labelInsert = new Label();
|
||||
numericUpDownDelete = new NumericUpDown();
|
||||
numericUpDownRead = new NumericUpDown();
|
||||
numericUpDownInsert = new NumericUpDown();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownDelete).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownRead).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownInsert).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelDeleteTime
|
||||
//
|
||||
labelDeleteTime.AutoSize = true;
|
||||
labelDeleteTime.Location = new Point(376, 72);
|
||||
labelDeleteTime.Name = "labelDeleteTime";
|
||||
labelDeleteTime.Size = new Size(32, 15);
|
||||
labelDeleteTime.TabIndex = 29;
|
||||
labelDeleteTime.Text = "0 ms";
|
||||
//
|
||||
// labelReadTime
|
||||
//
|
||||
labelReadTime.AutoSize = true;
|
||||
labelReadTime.Location = new Point(376, 43);
|
||||
labelReadTime.Name = "labelReadTime";
|
||||
labelReadTime.Size = new Size(32, 15);
|
||||
labelReadTime.TabIndex = 28;
|
||||
labelReadTime.Text = "0 ms";
|
||||
//
|
||||
// labelInsertTime
|
||||
//
|
||||
labelInsertTime.AutoSize = true;
|
||||
labelInsertTime.Location = new Point(376, 14);
|
||||
labelInsertTime.Name = "labelInsertTime";
|
||||
labelInsertTime.Size = new Size(32, 15);
|
||||
labelInsertTime.TabIndex = 27;
|
||||
labelInsertTime.Text = "0 ms";
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
buttonDelete.Location = new Point(264, 68);
|
||||
buttonDelete.Name = "buttonDelete";
|
||||
buttonDelete.Size = new Size(75, 23);
|
||||
buttonDelete.TabIndex = 26;
|
||||
buttonDelete.Text = "Удалить";
|
||||
buttonDelete.UseVisualStyleBackColor = true;
|
||||
buttonDelete.Click += buttonDelete_Click;
|
||||
//
|
||||
// buttonRead
|
||||
//
|
||||
buttonRead.Location = new Point(264, 39);
|
||||
buttonRead.Name = "buttonRead";
|
||||
buttonRead.Size = new Size(75, 23);
|
||||
buttonRead.TabIndex = 25;
|
||||
buttonRead.Text = "Получить";
|
||||
buttonRead.UseVisualStyleBackColor = true;
|
||||
buttonRead.Click += buttonRead_Click;
|
||||
//
|
||||
// buttonInsert
|
||||
//
|
||||
buttonInsert.Location = new Point(264, 10);
|
||||
buttonInsert.Name = "buttonInsert";
|
||||
buttonInsert.Size = new Size(75, 23);
|
||||
buttonInsert.TabIndex = 24;
|
||||
buttonInsert.Text = "Создать";
|
||||
buttonInsert.UseVisualStyleBackColor = true;
|
||||
buttonInsert.Click += buttonInsert_Click;
|
||||
//
|
||||
// labelEntities3
|
||||
//
|
||||
labelEntities3.AutoSize = true;
|
||||
labelEntities3.Location = new Point(159, 70);
|
||||
labelEntities3.Name = "labelEntities3";
|
||||
labelEntities3.Size = new Size(68, 15);
|
||||
labelEntities3.TabIndex = 23;
|
||||
labelEntities3.Text = "сущностей";
|
||||
//
|
||||
// labelEntities2
|
||||
//
|
||||
labelEntities2.AutoSize = true;
|
||||
labelEntities2.Location = new Point(159, 41);
|
||||
labelEntities2.Name = "labelEntities2";
|
||||
labelEntities2.Size = new Size(68, 15);
|
||||
labelEntities2.TabIndex = 22;
|
||||
labelEntities2.Text = "сущностей";
|
||||
//
|
||||
// labelEntities1
|
||||
//
|
||||
labelEntities1.AutoSize = true;
|
||||
labelEntities1.Location = new Point(159, 12);
|
||||
labelEntities1.Name = "labelEntities1";
|
||||
labelEntities1.Size = new Size(68, 15);
|
||||
labelEntities1.TabIndex = 21;
|
||||
labelEntities1.Text = "сущностей";
|
||||
//
|
||||
// labelDelete
|
||||
//
|
||||
labelDelete.AutoSize = true;
|
||||
labelDelete.Location = new Point(16, 70);
|
||||
labelDelete.Name = "labelDelete";
|
||||
labelDelete.Size = new Size(51, 15);
|
||||
labelDelete.TabIndex = 20;
|
||||
labelDelete.Text = "Удалить";
|
||||
//
|
||||
// labelRead
|
||||
//
|
||||
labelRead.AutoSize = true;
|
||||
labelRead.Location = new Point(16, 41);
|
||||
labelRead.Name = "labelRead";
|
||||
labelRead.Size = new Size(61, 15);
|
||||
labelRead.TabIndex = 19;
|
||||
labelRead.Text = "Получить";
|
||||
//
|
||||
// labelInsert
|
||||
//
|
||||
labelInsert.AutoSize = true;
|
||||
labelInsert.Location = new Point(16, 12);
|
||||
labelInsert.Name = "labelInsert";
|
||||
labelInsert.Size = new Size(50, 15);
|
||||
labelInsert.TabIndex = 18;
|
||||
labelInsert.Text = "Создать";
|
||||
//
|
||||
// numericUpDownDelete
|
||||
//
|
||||
numericUpDownDelete.Location = new Point(83, 68);
|
||||
numericUpDownDelete.Name = "numericUpDownDelete";
|
||||
numericUpDownDelete.Size = new Size(70, 23);
|
||||
numericUpDownDelete.TabIndex = 17;
|
||||
//
|
||||
// numericUpDownRead
|
||||
//
|
||||
numericUpDownRead.Location = new Point(83, 39);
|
||||
numericUpDownRead.Name = "numericUpDownRead";
|
||||
numericUpDownRead.Size = new Size(70, 23);
|
||||
numericUpDownRead.TabIndex = 16;
|
||||
//
|
||||
// numericUpDownInsert
|
||||
//
|
||||
numericUpDownInsert.Location = new Point(83, 10);
|
||||
numericUpDownInsert.Name = "numericUpDownInsert";
|
||||
numericUpDownInsert.Size = new Size(70, 23);
|
||||
numericUpDownInsert.TabIndex = 15;
|
||||
//
|
||||
// FormStopsTests
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(424, 101);
|
||||
Controls.Add(labelDeleteTime);
|
||||
Controls.Add(labelReadTime);
|
||||
Controls.Add(labelInsertTime);
|
||||
Controls.Add(buttonDelete);
|
||||
Controls.Add(buttonRead);
|
||||
Controls.Add(buttonInsert);
|
||||
Controls.Add(labelEntities3);
|
||||
Controls.Add(labelEntities2);
|
||||
Controls.Add(labelEntities1);
|
||||
Controls.Add(labelDelete);
|
||||
Controls.Add(labelRead);
|
||||
Controls.Add(labelInsert);
|
||||
Controls.Add(numericUpDownDelete);
|
||||
Controls.Add(numericUpDownRead);
|
||||
Controls.Add(numericUpDownInsert);
|
||||
Name = "FormStopsTests";
|
||||
Text = "Тесты для сущности \"Остановка\"";
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownDelete).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownRead).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownInsert).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelDeleteTime;
|
||||
private Label labelReadTime;
|
||||
private Label labelInsertTime;
|
||||
private Button buttonDelete;
|
||||
private Button buttonRead;
|
||||
private Button buttonInsert;
|
||||
private Label labelEntities3;
|
||||
private Label labelEntities2;
|
||||
private Label labelEntities1;
|
||||
private Label labelDelete;
|
||||
private Label labelRead;
|
||||
private Label labelInsert;
|
||||
private NumericUpDown numericUpDownDelete;
|
||||
private NumericUpDown numericUpDownRead;
|
||||
private NumericUpDown numericUpDownInsert;
|
||||
}
|
||||
}
|
143
RouteGuide/RouteGuideView/FormStopsTests.cs
Normal file
143
RouteGuide/RouteGuideView/FormStopsTests.cs
Normal file
@ -0,0 +1,143 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using RouteGuideBusinessLogics.BusinessLogics;
|
||||
using RouteGuideContracts.BindingModels;
|
||||
using RouteGuideContracts.BusinessLogicsContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace RouteGuideView
|
||||
{
|
||||
/// <summary>
|
||||
/// Форма с тестами для сущности "Остановка"
|
||||
/// </summary>
|
||||
public partial class FormStopsTests : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Логгер
|
||||
/// </summary>
|
||||
private readonly ILogger _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Бизнес-логика
|
||||
/// </summary>
|
||||
private readonly IStopLogic _stopLogic;
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="stopLogic"></param>
|
||||
public FormStopsTests(ILogger<FormStopsTests> logger, IStopLogic stopLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_stopLogic = stopLogic;
|
||||
|
||||
numericUpDownInsert.Maximum = 1000;
|
||||
numericUpDownRead.Maximum = 1000;
|
||||
numericUpDownDelete.Maximum = 1000;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Кнопка "Создать"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonInsert_Click(object sender, EventArgs e)
|
||||
{
|
||||
int entitiesCount = Convert.ToInt32(numericUpDownInsert.Value);
|
||||
_logger.LogInformation("StopInsertTest. Count: {Count}", entitiesCount);
|
||||
try
|
||||
{
|
||||
double time = 0;
|
||||
var stopwatch = new Stopwatch();
|
||||
for (int i = 1; i <= entitiesCount; i++)
|
||||
{
|
||||
var model = new StopBindingModel
|
||||
{
|
||||
Id = 0,
|
||||
Name = $"Остановка {i}",
|
||||
Street = $"Улица {i}",
|
||||
Number = i
|
||||
};
|
||||
|
||||
stopwatch.Start();
|
||||
var operationResult = _stopLogic.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении сущности 'Остановка'. Дополнительная информация в логах.");
|
||||
}
|
||||
stopwatch.Stop();
|
||||
time += stopwatch.ElapsedMilliseconds;
|
||||
}
|
||||
labelInsertTime.Text = $"{Convert.ToInt32(time / entitiesCount)} ms";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "StopInsertTest. Test failed");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Кнопка "Получить"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonRead_Click(object sender, EventArgs e)
|
||||
{
|
||||
int entitiesCount = Convert.ToInt32(numericUpDownRead.Value);
|
||||
_logger.LogInformation("StopReadTest. Count: {Count}", entitiesCount);
|
||||
try
|
||||
{
|
||||
var stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
_stopLogic.ReadList(entitiesCount);
|
||||
stopwatch.Stop();
|
||||
labelReadTime.Text = $"{stopwatch.ElapsedMilliseconds} ms";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "StopReadTest. Test failed");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Кнопка "Удалить"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonDelete_Click(object sender, EventArgs e)
|
||||
{
|
||||
int entitiesCount = Convert.ToInt32(numericUpDownDelete.Value);
|
||||
_logger.LogInformation("StopDeleteTest. Count: {Count}", entitiesCount);
|
||||
try
|
||||
{
|
||||
double time = 0;
|
||||
var stopwatch = new Stopwatch();
|
||||
for (int i = 1; i <= entitiesCount; i++)
|
||||
{
|
||||
stopwatch.Start();
|
||||
_stopLogic.Delete();
|
||||
stopwatch.Stop();
|
||||
time += stopwatch.ElapsedMilliseconds;
|
||||
}
|
||||
labelDeleteTime.Text = $"{Convert.ToInt32(time / entitiesCount)} ms";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "StopDeleteTest. Test failed");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
RouteGuide/RouteGuideView/FormStopsTests.resx
Normal file
120
RouteGuide/RouteGuideView/FormStopsTests.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
230
RouteGuide/RouteGuideView/FormTransportTests.Designer.cs
generated
Normal file
230
RouteGuide/RouteGuideView/FormTransportTests.Designer.cs
generated
Normal file
@ -0,0 +1,230 @@
|
||||
namespace RouteGuideView
|
||||
{
|
||||
partial class FormTransportTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
labelDeleteTime = new Label();
|
||||
labelReadTime = new Label();
|
||||
labelInsertTime = new Label();
|
||||
buttonDelete = new Button();
|
||||
buttonRead = new Button();
|
||||
buttonInsert = new Button();
|
||||
labelEntities3 = new Label();
|
||||
labelEntities2 = new Label();
|
||||
labelEntities1 = new Label();
|
||||
labelDelete = new Label();
|
||||
labelRead = new Label();
|
||||
labelInsert = new Label();
|
||||
numericUpDownDelete = new NumericUpDown();
|
||||
numericUpDownRead = new NumericUpDown();
|
||||
numericUpDownInsert = new NumericUpDown();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownDelete).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownRead).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownInsert).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelDeleteTime
|
||||
//
|
||||
labelDeleteTime.AutoSize = true;
|
||||
labelDeleteTime.Location = new Point(376, 72);
|
||||
labelDeleteTime.Name = "labelDeleteTime";
|
||||
labelDeleteTime.Size = new Size(32, 15);
|
||||
labelDeleteTime.TabIndex = 29;
|
||||
labelDeleteTime.Text = "0 ms";
|
||||
//
|
||||
// labelReadTime
|
||||
//
|
||||
labelReadTime.AutoSize = true;
|
||||
labelReadTime.Location = new Point(376, 43);
|
||||
labelReadTime.Name = "labelReadTime";
|
||||
labelReadTime.Size = new Size(32, 15);
|
||||
labelReadTime.TabIndex = 28;
|
||||
labelReadTime.Text = "0 ms";
|
||||
//
|
||||
// labelInsertTime
|
||||
//
|
||||
labelInsertTime.AutoSize = true;
|
||||
labelInsertTime.Location = new Point(376, 14);
|
||||
labelInsertTime.Name = "labelInsertTime";
|
||||
labelInsertTime.Size = new Size(32, 15);
|
||||
labelInsertTime.TabIndex = 27;
|
||||
labelInsertTime.Text = "0 ms";
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
buttonDelete.Location = new Point(264, 68);
|
||||
buttonDelete.Name = "buttonDelete";
|
||||
buttonDelete.Size = new Size(75, 23);
|
||||
buttonDelete.TabIndex = 26;
|
||||
buttonDelete.Text = "Удалить";
|
||||
buttonDelete.UseVisualStyleBackColor = true;
|
||||
buttonDelete.Click += buttonDelete_Click;
|
||||
//
|
||||
// buttonRead
|
||||
//
|
||||
buttonRead.Location = new Point(264, 39);
|
||||
buttonRead.Name = "buttonRead";
|
||||
buttonRead.Size = new Size(75, 23);
|
||||
buttonRead.TabIndex = 25;
|
||||
buttonRead.Text = "Получить";
|
||||
buttonRead.UseVisualStyleBackColor = true;
|
||||
buttonRead.Click += buttonRead_Click;
|
||||
//
|
||||
// buttonInsert
|
||||
//
|
||||
buttonInsert.Location = new Point(264, 10);
|
||||
buttonInsert.Name = "buttonInsert";
|
||||
buttonInsert.Size = new Size(75, 23);
|
||||
buttonInsert.TabIndex = 24;
|
||||
buttonInsert.Text = "Создать";
|
||||
buttonInsert.UseVisualStyleBackColor = true;
|
||||
buttonInsert.Click += buttonInsert_Click;
|
||||
//
|
||||
// labelEntities3
|
||||
//
|
||||
labelEntities3.AutoSize = true;
|
||||
labelEntities3.Location = new Point(159, 70);
|
||||
labelEntities3.Name = "labelEntities3";
|
||||
labelEntities3.Size = new Size(68, 15);
|
||||
labelEntities3.TabIndex = 23;
|
||||
labelEntities3.Text = "сущностей";
|
||||
//
|
||||
// labelEntities2
|
||||
//
|
||||
labelEntities2.AutoSize = true;
|
||||
labelEntities2.Location = new Point(159, 41);
|
||||
labelEntities2.Name = "labelEntities2";
|
||||
labelEntities2.Size = new Size(68, 15);
|
||||
labelEntities2.TabIndex = 22;
|
||||
labelEntities2.Text = "сущностей";
|
||||
//
|
||||
// labelEntities1
|
||||
//
|
||||
labelEntities1.AutoSize = true;
|
||||
labelEntities1.Location = new Point(159, 12);
|
||||
labelEntities1.Name = "labelEntities1";
|
||||
labelEntities1.Size = new Size(68, 15);
|
||||
labelEntities1.TabIndex = 21;
|
||||
labelEntities1.Text = "сущностей";
|
||||
//
|
||||
// labelDelete
|
||||
//
|
||||
labelDelete.AutoSize = true;
|
||||
labelDelete.Location = new Point(16, 70);
|
||||
labelDelete.Name = "labelDelete";
|
||||
labelDelete.Size = new Size(51, 15);
|
||||
labelDelete.TabIndex = 20;
|
||||
labelDelete.Text = "Удалить";
|
||||
//
|
||||
// labelRead
|
||||
//
|
||||
labelRead.AutoSize = true;
|
||||
labelRead.Location = new Point(16, 41);
|
||||
labelRead.Name = "labelRead";
|
||||
labelRead.Size = new Size(61, 15);
|
||||
labelRead.TabIndex = 19;
|
||||
labelRead.Text = "Получить";
|
||||
//
|
||||
// labelInsert
|
||||
//
|
||||
labelInsert.AutoSize = true;
|
||||
labelInsert.Location = new Point(16, 12);
|
||||
labelInsert.Name = "labelInsert";
|
||||
labelInsert.Size = new Size(50, 15);
|
||||
labelInsert.TabIndex = 18;
|
||||
labelInsert.Text = "Создать";
|
||||
//
|
||||
// numericUpDownDelete
|
||||
//
|
||||
numericUpDownDelete.Location = new Point(83, 68);
|
||||
numericUpDownDelete.Name = "numericUpDownDelete";
|
||||
numericUpDownDelete.Size = new Size(70, 23);
|
||||
numericUpDownDelete.TabIndex = 17;
|
||||
//
|
||||
// numericUpDownRead
|
||||
//
|
||||
numericUpDownRead.Location = new Point(83, 39);
|
||||
numericUpDownRead.Name = "numericUpDownRead";
|
||||
numericUpDownRead.Size = new Size(70, 23);
|
||||
numericUpDownRead.TabIndex = 16;
|
||||
//
|
||||
// numericUpDownInsert
|
||||
//
|
||||
numericUpDownInsert.Location = new Point(83, 10);
|
||||
numericUpDownInsert.Name = "numericUpDownInsert";
|
||||
numericUpDownInsert.Size = new Size(70, 23);
|
||||
numericUpDownInsert.TabIndex = 15;
|
||||
//
|
||||
// FormTransportTests
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(424, 101);
|
||||
Controls.Add(labelDeleteTime);
|
||||
Controls.Add(labelReadTime);
|
||||
Controls.Add(labelInsertTime);
|
||||
Controls.Add(buttonDelete);
|
||||
Controls.Add(buttonRead);
|
||||
Controls.Add(buttonInsert);
|
||||
Controls.Add(labelEntities3);
|
||||
Controls.Add(labelEntities2);
|
||||
Controls.Add(labelEntities1);
|
||||
Controls.Add(labelDelete);
|
||||
Controls.Add(labelRead);
|
||||
Controls.Add(labelInsert);
|
||||
Controls.Add(numericUpDownDelete);
|
||||
Controls.Add(numericUpDownRead);
|
||||
Controls.Add(numericUpDownInsert);
|
||||
Name = "FormTransportTests";
|
||||
Text = "Тесты для сущности \"Транспорт\"";
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownDelete).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownRead).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownInsert).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelDeleteTime;
|
||||
private Label labelReadTime;
|
||||
private Label labelInsertTime;
|
||||
private Button buttonDelete;
|
||||
private Button buttonRead;
|
||||
private Button buttonInsert;
|
||||
private Label labelEntities3;
|
||||
private Label labelEntities2;
|
||||
private Label labelEntities1;
|
||||
private Label labelDelete;
|
||||
private Label labelRead;
|
||||
private Label labelInsert;
|
||||
private NumericUpDown numericUpDownDelete;
|
||||
private NumericUpDown numericUpDownRead;
|
||||
private NumericUpDown numericUpDownInsert;
|
||||
}
|
||||
}
|
152
RouteGuide/RouteGuideView/FormTransportTests.cs
Normal file
152
RouteGuide/RouteGuideView/FormTransportTests.cs
Normal file
@ -0,0 +1,152 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using RouteGuideContracts.BindingModels;
|
||||
using RouteGuideContracts.BusinessLogicsContracts;
|
||||
using RouteGuideDataModels.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace RouteGuideView
|
||||
{
|
||||
/// <summary>
|
||||
/// Форма с тестами для сущности "Транспорт"
|
||||
/// </summary>
|
||||
public partial class FormTransportTests : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Логгер
|
||||
/// </summary>
|
||||
private readonly ILogger _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Бизнес-логика для транспорта
|
||||
/// </summary>
|
||||
private readonly ITransportLogic _transportLogic;
|
||||
|
||||
/// <summary>
|
||||
/// Бизнес-логика для водителей
|
||||
/// </summary>
|
||||
private readonly IDriverLogic _driverLogic;
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="transportLogic"></param>
|
||||
/// <param name="driverLogic"></param>
|
||||
public FormTransportTests(ILogger<FormTransportTests> logger, ITransportLogic transportLogic, IDriverLogic driverLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_transportLogic = transportLogic;
|
||||
_driverLogic = driverLogic;
|
||||
|
||||
numericUpDownInsert.Maximum = 1000;
|
||||
numericUpDownRead.Maximum = 1000;
|
||||
numericUpDownDelete.Maximum = 1000;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Кнопка "Создать"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonInsert_Click(object sender, EventArgs e)
|
||||
{
|
||||
int entitiesCount = Convert.ToInt32(numericUpDownInsert.Value);
|
||||
_logger.LogInformation("TransportInsertTest. Count: {Count}", entitiesCount);
|
||||
try
|
||||
{
|
||||
double time = 0;
|
||||
var stopwatch = new Stopwatch();
|
||||
int driverId = _driverLogic.ReadList(1)![0].Id;
|
||||
for (int i = 1; i <= entitiesCount; i++)
|
||||
{
|
||||
var model = new TransportBindingModel
|
||||
{
|
||||
Id = 0,
|
||||
License = i.ToString(),
|
||||
Type = TransportType.Маршрутка,
|
||||
Capacity = i,
|
||||
DriverId = driverId
|
||||
};
|
||||
|
||||
stopwatch.Start();
|
||||
var operationResult = _transportLogic.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении сущности 'Транспорт'. Дополнительная информация в логах.");
|
||||
}
|
||||
stopwatch.Stop();
|
||||
time += stopwatch.ElapsedMilliseconds;
|
||||
}
|
||||
labelInsertTime.Text = $"{Convert.ToInt32(time / entitiesCount)} ms";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "TransportInsertTest. Test failed");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Кнопка "Получить"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonRead_Click(object sender, EventArgs e)
|
||||
{
|
||||
int entitiesCount = Convert.ToInt32(numericUpDownRead.Value);
|
||||
_logger.LogInformation("TransportReadTest. Count: {Count}", entitiesCount);
|
||||
try
|
||||
{
|
||||
var stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
_transportLogic.ReadList(entitiesCount);
|
||||
stopwatch.Stop();
|
||||
labelReadTime.Text = $"{stopwatch.ElapsedMilliseconds} ms";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "TransportReadTest. Test failed");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Кнопка "Удалить"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonDelete_Click(object sender, EventArgs e)
|
||||
{
|
||||
int entitiesCount = Convert.ToInt32(numericUpDownDelete.Value);
|
||||
_logger.LogInformation("TransportDeleteTest. Count: {Count}", entitiesCount);
|
||||
try
|
||||
{
|
||||
double time = 0;
|
||||
var stopwatch = new Stopwatch();
|
||||
for (int i = 1; i <= entitiesCount; i++)
|
||||
{
|
||||
stopwatch.Start();
|
||||
_transportLogic.Delete();
|
||||
stopwatch.Stop();
|
||||
time += stopwatch.ElapsedMilliseconds;
|
||||
}
|
||||
labelDeleteTime.Text = $"{Convert.ToInt32(time / entitiesCount)} ms";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "TransportDeleteTest. Test failed");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
RouteGuide/RouteGuideView/FormTransportTests.resx
Normal file
120
RouteGuide/RouteGuideView/FormTransportTests.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
@ -60,7 +60,7 @@ namespace RouteGuideView
|
||||
services.AddTransient<IStopLogic, StopLogic>();
|
||||
services.AddTransient<IScheduleLogic, ScheduleLogic>();
|
||||
|
||||
// IoC-يٍَْمىٍمِ, <20>ٌَِ<D990>
|
||||
// IoC-êîíòåéíåð, îñíîâíûå ôîðìû
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormSchedule>();
|
||||
services.AddTransient<FormDriver>();
|
||||
@ -72,6 +72,16 @@ namespace RouteGuideView
|
||||
services.AddTransient<FormRouteStop>();
|
||||
services.AddTransient<FormStop>();
|
||||
services.AddTransient<FormStops>();
|
||||
|
||||
// IoC-êîíòåéíåð, ôîðìû äëÿ òåñòîâ
|
||||
services.AddTransient<FormSchedulesTests>();
|
||||
services.AddTransient<FormDriversTests>();
|
||||
services.AddTransient<FormTransportTests>();
|
||||
services.AddTransient<FormRoutesTests>();
|
||||
services.AddTransient<FormStopsTests>();
|
||||
|
||||
// Çàïèñü DateTime Kind=Local â ÁÄ
|
||||
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user