protected TestBase() { var config = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build(); var section = config.GetSection("ConnectionStrings").GetSection("huraceTest"); var provider = section["ProviderName"]; var connectionString = section["ConnectionString"]; ConnectionFactory = new ConcreteConnectionFactory(DbUtil.GetProviderFactory(provider), connectionString); RaceDao = new RaceDao(ConnectionFactory, StatementFactory); SeasonDao = new SeasonDao(ConnectionFactory, StatementFactory); LocationDao = new LocationDao(ConnectionFactory, StatementFactory); CountryDao = new CountryDao(ConnectionFactory, StatementFactory); DisciplineDao = new DisciplineDao(ConnectionFactory, StatementFactory); SkierDao = new SkierDao(ConnectionFactory, StatementFactory); StartListDao = new StartListDao(ConnectionFactory, StatementFactory); RaceEventDao = new RaceEventDao(ConnectionFactory, StatementFactory); SkierEventDao = new SkierEventDao(ConnectionFactory, StatementFactory); TimeDataDao = new TimeDataDao(ConnectionFactory, StatementFactory); GenderDao = new GenderDao(ConnectionFactory, StatementFactory); SensorDao = new SensorDao(ConnectionFactory, StatementFactory); RaceDataDao = new RaceDataDao(ConnectionFactory, StatementFactory); RaceStateDao = new RaceStateDao(ConnectionFactory, StatementFactory); StartStateDao = new StartStateDao(ConnectionFactory, StatementFactory); EventTypeDao = new EventTypeDao(ConnectionFactory, StatementFactory); _dataGenerator = new DataGenerator.Core.DataGenerator(provider, connectionString); }
public void TestGetLevelOnVariation() { Country country = new CountryDao(_graphClient).Create(new Country() { Name = "var test" }); Route route = new RouteDao(_graphClient).CreateIn(country, new Route() { Name = "r var test" }); DifficultyLevelScale scale = new DifficultyLevelScaleDao(_graphClient).Create(new DifficultyLevelScale()); DifficultyLevel level = new DifficultyLevelDao(_graphClient).Create(scale, new DifficultyLevel() { Name = "dl var test" }); Variation variation = new VariationDao(_graphClient).Create(new Variation() { Name = "v var test" }, route, level); Variation variationOnRoute = new VariationDao(_graphClient).GetAllOn(route).First(); DifficultyLevel levelOnVariation = new DifficultyLevelDao(_graphClient).GetLevelOnVariation(variationOnRoute); Assert.AreEqual(level.Id, levelOnVariation.Id); }
public override void Initialize() { var connectionString = ConfigurationReader.GetConnectionString(Environment.Production); var databaseName = GetDatabaseName(connectionString); var task = Task.Run(async() => await ApplicationData.Current.LocalFolder.CreateFileAsync(databaseName, CreationCollisionOption.OpenIfExists)).Result; var databasePath = Path.Combine(ApplicationData.Current.LocalFolder.Path, databaseName); var customConnectionString = connectionString.Replace(databaseName, databasePath, StringComparison.CurrentCulture); var connectionFactory = new ConnectionFactory(Environment.Production, customConnectionString); var locationDao = new LocationDao(connectionFactory); var skierDao = new SkierDao(connectionFactory); var countryDao = new CountryDao(connectionFactory); var raceDao = new RaceDao(connectionFactory); var runDao = new RunDao(connectionFactory); var sensorMeasurementDao = new SensorMeasurementDao(connectionFactory); var daoProvider = new DaoProvider(countryDao, locationDao, raceDao, runDao, sensorMeasurementDao, skierDao); var messengerHub = new MvxMessengerHub(); var simulatorRaceClock = new SimulatorRaceClock(); Mvx.IoCProvider.RegisterSingleton <IMvxMessenger>(messengerHub); Mvx.IoCProvider.RegisterSingleton <IDialogService>(new DialogService(messengerHub)); Mvx.IoCProvider.RegisterSingleton <IRaceService>(new RaceService(daoProvider)); Mvx.IoCProvider.RegisterSingleton <ILocationService>(new LocationService(daoProvider)); Mvx.IoCProvider.RegisterSingleton <ISkierService>(new SkierService(daoProvider)); Mvx.IoCProvider.RegisterSingleton <IRunService>(new RunService(daoProvider, simulatorRaceClock)); Mvx.IoCProvider.RegisterSingleton <SimulatorRaceClock>(simulatorRaceClock); RegisterAppStart <ViewModels.NavigationRootViewModel>(); }
public ActionResult Index(int page = 1, int pageSize = 10) { var dao = new CountryDao(); var model = dao.ListPg(page, pageSize); return(View(model)); }
public void TestCreateRouteInSummitGroup() { ICountryDao countryDao = new CountryDao(_graphClient); Country newCountry = new Country { Name = "Deutschland" }; countryDao.Create(newCountry); IAreaDao areaDao = new AreaDao(_graphClient); Area area = new Area(); areaDao.Create(newCountry, area); ISummitGroupDao summitGroupDao = new SummitGroupDao(_graphClient); SummitGroup summitGroup = new SummitGroup { Name = "Gipfelgruppe" }; summitGroupDao.Create(area, summitGroup); IRoutesDao routeDao = new RouteDao(_graphClient); Route newRoute = new Route { Name = "Jakobsweg" }; routeDao.CreateIn(summitGroup, newRoute); IList <Route> allRoutes = _graphClient.Cypher.Match("(route:Route)") .Return(route => route.As <Route>()) .Results.ToList(); Assert.AreEqual(1, allRoutes.Count); }
public void TestGetRoutesInSummitGroup() { ICountryDao countryDao = new CountryDao(_graphClient); Country country = new Country { Name = "Deutschland" }; countryDao.Create(country); IAreaDao areaDao = new AreaDao(_graphClient); Area area = new Area(); areaDao.Create(country, area); ISummitGroupDao summitGroupDao = new SummitGroupDao(_graphClient); SummitGroup summitGroup = new SummitGroup { Name = "Gipfelgruppe" }; summitGroupDao.Create(area, summitGroup); IRoutesDao routeDao = new RouteDao(_graphClient); Route created = routeDao.CreateIn(summitGroup, new Route { Name = "Jakobsweg" }); IList <Route> routesInArea = routeDao.GetRoutesIn(summitGroup); Assert.AreEqual(1, routesInArea.Count); Assert.AreEqual("Jakobsweg", routesInArea.First().Name); Assert.AreEqual(created.Name, routesInArea.First().Name); }
public async Task InsertTest() { var skierId = (await SkierDao.FindAllAsync()).First().Id; var raceId = (await RaceDao.FindAllAsync()).First().Id; var newSkierId = await SkierDao.InsertGetIdAsync(new Skier { Retired = false, CountryId = (await CountryDao.FindAllAsync()).First().Id, FirstName = "ABC", LastName = "DEF", GenderId = 1, DateOfBirth = DateTime.Now }); await StartListDao.InsertAsync(new StartList { SkierId = newSkierId.Value, RaceId = raceId, StartNumber = 99, StartStateId = (int)Domain.Enums.RaceState.Finished }); var startList = await StartListDao.FindByIdAsync(skierId, raceId); Assert.AreEqual(skierId, startList.SkierId); Assert.AreEqual(raceId, startList.RaceId); Assert.AreEqual((int)Domain.Enums.RaceState.Finished, startList.StartStateId); Assert.NotNull(startList.Skier); Assert.NotNull(startList.StartState); Assert.NotNull(startList.Race); }
public async Task FindAvailableSkiersForRaceTest() { var skier = (await SkierDao.FindAllAsync()).First(); var race = (await RaceDao.FindAllAsync()).First(); var availableSkiers = await SkierDao.FindAvailableSkiersForRace(race.Id); Assert.IsTrue(availableSkiers.All(s => s.Id != skier.Id)); var newSkierId = await SkierDao.InsertGetIdAsync(new Skier { Retired = false, FirstName = "xy", LastName = "z", CountryId = (await CountryDao.FindAllAsync()).First().Id, GenderId = race.GenderId, DateOfBirth = DateTime.Today }); availableSkiers = await SkierDao.FindAvailableSkiersForRace(race.Id); Assert.IsTrue(availableSkiers.All(s => s.Id != newSkierId.Value)); var newSkier = await SkierDao.FindByIdAsync(newSkierId.Value); newSkier.GenderId = newSkier.GenderId == 1 ? 2 : 1; await SkierDao.UpdateAsync(newSkier); availableSkiers = await SkierDao.FindAvailableSkiersForRace(race.Id); Assert.IsFalse(availableSkiers.Any(s => s.Id != newSkierId.Value)); }
public UnitOfWork(IDbConnection connection) { _connection = connection; AccountDao = new AccountDao(connection); BusCoordinateDao = new BusCoordinateDao(connection); BusDao = new BusDao(connection); BusDriverDao = new BusDriverDao(connection); CityDao = new CityDao(connection); CountryDao = new CountryDao(connection); DistanceDao = new DistanceDao(connection); DistrictDao = new DistrictDao(connection); DriverDao = new DriverDao(connection); DriverContactDao = new DriverContactDao(connection); LocationDao = new LocationDao(connection); LookupsDao = new LookupsDao(connection); LookupValuesDao = new LookupValuesDao(connection); RepairSpecialistDao = new RepairSpecialistDao(connection); RoleDao = new RoleDao(connection); RouteDao = new RouteDao(connection); RouteLocationDao = new RouteLocationDao(connection); TripDao = new TripDao(connection); TripBusDao = new TripBusDao(connection); TripBusDriverDao = new TripBusDriverDao(connection); UserDao = new UserDao(connection); VehicleDao = new VehicleDao(connection); ScheduleDao = new ScheduleDao(connection); ScheduleLocationDao = new ScheduleLocationDao(connection); StoredProcedureDao = new StoredProcedureDao(connection); }
public async Task FindByIdTest() { var country = (await CountryDao.FindAllAsync()).First(); var countryById = await CountryDao.FindByIdAsync(country.Id); Assert.AreEqual(country.CountryCode, countryById?.CountryCode); Assert.AreEqual(country.CountryName, countryById?.CountryName); }
public async Task DeleteTest() { var countryId = await CountryDao.InsertGetIdAsync(new Country { CountryName = "ABC", CountryCode = "DF" }); await CountryDao.DeleteAsync(countryId.Value); Assert.IsNull(await CountryDao.FindByIdAsync(countryId.Value)); }
public ActionResult Create() { CategoryDao categoryDao = new CategoryDao(); CountryDao countryDao = new CountryDao(); ViewBag.Categories = categoryDao.GetAll(); ViewBag.Countries = countryDao.GetAll(); return(View()); }
public CountryBusiness(MardisContext mardisContext, IMemoryCache memoryCache) { _myCache = memoryCache; _countryDao = new CountryDao(mardisContext); if (_myCache.Get(CacheName) == null) { _myCache.Set(CacheName, _countryDao.GetCountries()); } }
public JsonResult ChangeStatus(int id) { var result = new CountryDao().ChangeStatus(id); return(Json(new { status = result })); }
public void TestIsNotInUse() { Country country = _dataGenerator.CreateCountry(); ICountryDao countryDao = new CountryDao(_graphClient); bool isInUse = countryDao.IsInUse(country); Assert.IsFalse(isInUse); }
public void TestDeleteNotInUse() { Country country = _dataGenerator.CreateCountry(); ICountryDao countryDao = new CountryDao(_graphClient); countryDao.Delete(country); Assert.AreEqual(0, countryDao.GetAll().Count); }
public void TestIsInUseByRoute() { Country country = _dataGenerator.CreateCountry(); Route route = _dataGenerator.CreateRouteInCountry(country: country); ICountryDao countryDao = new CountryDao(_graphClient); bool isInUse = countryDao.IsInUse(country); Assert.IsTrue(isInUse); }
public void TestGetAll() { CountryDao dao = new CountryDao(_graphClient); Country created = _dataGenerator.CreateCountry(); IEnumerable <Country> allCountries = dao.GetAll(); Assert.AreEqual(1, allCountries.Count()); Assert.AreEqual(created.Name, allCountries.First().Name); Assert.AreEqual(created.Id, allCountries.First().Id); }
public void TestIsInUseByArea() { Country country = _dataGenerator.CreateCountry(); Area area = _dataGenerator.CreateArea(country: country); ICountryDao countryDao = new CountryDao(_graphClient); bool isInUse = countryDao.IsInUse(country); Assert.IsTrue(isInUse); }
public void TestDeleteInUse() { Country country = _dataGenerator.CreateCountry(); Route route = _dataGenerator.CreateRouteInCountry(country: country); ICountryDao countryDao = new CountryDao(_graphClient); Action action = () => countryDao.Delete(country); action.ShouldThrow <NodeInUseException>(); }
public Country CreateCountry(string name = "Land") { CountryDao dao = new CountryDao(_graphClient); Country newCountry = new Country() { Name = name }; return(dao.Create(newCountry)); }
public async Task DeleteAllTest() { await DbTeardown(); var countryId = await CountryDao.InsertGetIdAsync(new Country { CountryName = "ABC", CountryCode = "DF" }); await CountryDao.DeleteAllAsync(); Assert.IsEmpty(await CountryDao.FindAllAsync()); }
public ActionResult Add(Product product, HttpPostedFileBase picture, int countryId, int categoryId) { if (ModelState.IsValid) { if (picture != null) { if (picture.ContentType == "image/jpeg" || picture.ContentType == "image/png") { Image image = Image.FromStream(picture.InputStream); Guid guid = Guid.NewGuid(); string imageName = guid.ToString() + ".jpg"; if (image.Height > 200 || image.Width > 200) { Image smallImage = ImageHelper.ScaleImage(image, 200, 200); Bitmap b = new Bitmap(smallImage); b.Save(Server.MapPath("~/uploads/product/" + imageName), System.Drawing.Imaging.ImageFormat.Jpeg); smallImage.Dispose(); b.Dispose(); product.Image = imageName; } else { picture.SaveAs(Server.MapPath("~/uploads/product") + picture.FileName); } } ; } CategoryDao categoryDao = new CategoryDao(); Category category = categoryDao.GetById(categoryId); product.Category = category; CountryDao countryDao = new CountryDao(); Country country = countryDao.GetById(countryId); product.Country = country; ProductDao productDao = new ProductDao(); productDao.Create(product); TempData["message-success"] = "Kniha byla uspesne pridana"; } else { return(View("Create", product)); } return(RedirectToAction("Index", "Home")); }
public async Task UpdateTest() { var country = (await CountryDao.FindAllAsync()).First(); country.CountryName = "TestABC"; await CountryDao.UpdateAsync(country); var updatedCountry = await CountryDao.FindByIdAsync(country.Id); Assert.AreEqual(country.CountryName, updatedCountry?.CountryName); }
public IList <Country> GetUserCountries(long userId) { try { return(GetTypedListFromIList(CountryDao.GetUserCountries(userId))); } catch (Exception ex) { throw new LoadException(ex); } }
public ActionResult CountryPage(long idc, int page = 1) { var movieDao = new MovieDao(); var country = new CountryDao().ViewDetail(idc); ViewBag.country = country; ViewBag.ListMovieNew = movieDao.ListMovieNew(12); var model = movieDao.ListByCountryID(idc); return(View(model.ToPagedList(page, 12))); }
public ActionResult Country(int incon, int page = 1) { var Movie = new MovieDao(); var Country = new CountryDao().ViewDetail(incon); ViewBag.Country = Country; ViewBag.Movie = Movie.ListMovieNew(12); var model = Movie.ListByCountryID(incon); return(View(model.ToPagedList(page, 12))); }
public long[] GetCountryNoWorkingFeastDaysIDList() { try { return(CountryDao.GetCountryNoWorkingFeastDaysIDList()); } catch (Exception ex) { throw new LoadException(ex); } }
public long[] GetInUseIDList(InUseEntity inUseEntity, long countryID) { try { return(CountryDao.GetInUseIDList(inUseEntity, countryID)); } catch (Exception ex) { throw new LoadException(ex); } }
public void TestUpdate() { Country country = _dataGenerator.CreateCountry(); country.Name = "newname"; ICountryDao countryDao = new CountryDao(_graphClient); countryDao.Save(country); Assert.AreEqual("newname", countryDao.GetAll().First().Name); }