public static void MyClassInitialize(TestContext testContext) { var countries = new Dictionary<int,Country> {{1, new Country {Name = "New Zealand", Code = "NZ", ID = 1}}}; state = new CurrentState(); state.InitialiseCountries(countries); state.InitialiseRouteNodes(new Dictionary<int, RouteNode>()); service = new CountryService(state); new Database("test.db"); }
public CountryViewModel(Country country, CountryService countryService) { if (country == null) throw new ArgumentNullException("country"); if (countryService == null) throw new ArgumentNullException("countryService"); _country = country; _countryService = countryService; // _customerType = Strings.CustomerViewModel_CustomerTypeOption_NotSpecified; }
public Controller(CountryService countryService, CompanyService companyService, DeliveryService deliveryService, PriceService priceService, RouteService routeService, LocationService locationService, StatisticsService statisticsService, EventService eventService) { this.countryService = countryService; this.companyService = companyService; this.deliveryService = deliveryService; this.priceService = priceService; this.routeService = routeService; this.locationService = locationService; this.statisticsService = statisticsService; this.eventService = eventService; Network.Instance.MessageReceived += new Network.MessageReceivedDelegate(OnReceived); }
public JsonResult GetReportByCountryID(Guid cid) { Country country = CountryService.GetCountriesRecord(cid); if (country.ID == cid) { //string recordLangName = country.Records.Select(r => r.Record_Languages.Where(rl => rl.LanguageID == TSM.Model.TSMContext.CurrentSiteLanguageID).FirstOrDefault().Name).FirstOrDefault().ToString(); return(this.Json(new { Id = country.Records.Select(z => z.ID), Value = country.Records.Select(z => z.Record_Languages[0].Name) }, JsonRequestBehavior.AllowGet)); //return this.Json(new { Id = country.Records.Select(z => z.ID), Value = country.Records.Select(z => z.Record_Languages[0].Name) }, JsonRequestBehavior.AllowGet); } return(this.Json(new { Id = "", Value = "" }, JsonRequestBehavior.AllowGet)); }
public override void TestsInitialize() { base.TestsInitialize(); this.UserService = ClientServiceLocator.Instance().ContractLocator.UserServices; this.BankService = ClientServiceLocator.Instance().ContractLocator.BankServices; this.BankBranchService = ClientServiceLocator.Instance().ContractLocator.BankBranchServices; this.AddressService = ClientServiceLocator.Instance().ContractLocator.AddressServices; this.CountryService = ClientServiceLocator.Instance().ContractLocator.CountryServices; this.WeeklyHalfDayService = ClientServiceLocator.Instance().ContractLocator.WeeklyHalfDayServices; this.WeeklyOffDaysService = ClientServiceLocator.Instance().ContractLocator.WeeklyOffDaysServices; CurrentUserInstance = UserService.GetById(SuperAdminId); CountryInstance = CountryService.GetById(CountryId); }
public ProductsAreInStock( IStockStatusCalculator stockStatusCalculator, SecurityContextService securityContextService, CountryService countryService, VariantService variantService, CartContextAccessor cartContextAccessor) { _stockStatusCalculator = stockStatusCalculator; _securityContextService = securityContextService; _countryService = countryService; _variantService = variantService; _cartContextAccessor = cartContextAccessor; }
public async Task Return_False_ifContryDoesntExist() { string countryName = "countryTest"; var options = TestUtilities.GetOptions(nameof(Return_False_ifContryDoesntExist)); using (var assertContext = new CocktailDatabaseContext(options)) { var sut = new CountryService(assertContext); var result = await sut.CheckIfCountryExistsAsync(countryName); Assert.AreEqual(false, result); } }
/// <summary> /// Populate Country By regions /// </summary> /// <param name="languageID"></param> /// <param name="regionIds"></param> public void PopulateCountryByRegions(Guid languageID, string regionIds) { var countries = CountryService.GetCountries(languageID, regionIds); this.Countries = new List <KeyValue>(); foreach (var country in countries) { this.Countries.Add(new KeyValue { Key = country.ID.ToString(), Value = country.Name }); } }
private void LoadFilterCountryDropDownList() { ddlFilterCountry.Items.Clear(); ddlFilterCountry.Items.Add(new ListItem(" -- View all -- ", "")); var dt = new DataTable(); dt = CountryService.Country_GetByAll(); for (int i = 0; i < dt.Rows.Count; i++) { ddlFilterCountry.Items.Add(new ListItem(Common.StringClass.ShowNameLevel(dt.Rows[i]["NameCo"].ToString(), "0"), dt.Rows[i]["CouId"].ToString())); } ddlFilterCountry.DataBind(); }
/// <summary> /// /// </summary> protected void BindCountries() { CountryService countryServ = new CountryService(); TList<ZNode.Libraries.DataAccess.Entities.Country> countries = countryServ.GetByPortalIDActiveInd(ZNodeConfigManager.SiteConfig.PortalID, true); countries.Sort("DisplayOrder,Name"); //Billing Drop Down List lstBillingCountryCode.DataSource = countries; lstBillingCountryCode.DataTextField = "Name"; lstBillingCountryCode.DataValueField = "Code"; lstBillingCountryCode.DataBind(); lstBillingCountryCode.SelectedValue = "US"; }
public async Task GetPurchasersForCountryReturnsPurchaserIfItExists() { // arrange PurchaserService purchaserService = new PurchaserService(_client); CountryService countryService = new CountryService(_client); Purchaser purchaser = new Purchaser() { Id = 0, ProfileId = 0, CountryId = 1, Profile = new Profile() { Id = 0, Username = "******", Password = "******", Usertype = 2 } }; Country country = new Country() { Id = 0, ProfileId = 0, CountryName = "Name", CountryCode = "Code", Profile = new Profile() { Id = 0, Username = "******", Password = "******", Usertype = 0 } }; Country toDeleteCountry = await countryService.CreateCountry(country); Purchaser toDeletePurchaser = await purchaserService.CreatePurchaser(purchaser); int expected = 1; // act List <Purchaser> actual = await purchaserService.GetPurchasersForCountry(1); // assert Assert.IsTrue(actual.Count == expected); await purchaserService.DeletePurchaserForProfile(toDeletePurchaser.ProfileId); await countryService.DeleteCountry(toDeleteCountry.Id); }
public async Task GetCountryGetsExistingCountry() { // arrange CountryService countryService = new CountryService(_client); Country country = new Country() { Id = 0, ProfileId = 0, CountryCode = "Code", CountryName = "Name", Profile = new Profile() { Id = 0, Username = "******", Password = "******", Usertype = 0 } }; Country expected = await countryService.CreateCountry(country); // act Country actual = await countryService.GetCountry(expected.Id); // assert Assert.IsTrue(expected.CountryCode == actual.CountryCode); Assert.IsTrue(expected.CountryName == actual.CountryName); CollectionAssert.AreEquivalent(expected.Articles, actual.Articles); Assert.IsTrue(expected.Id == actual.Id); Assert.IsTrue(expected.Profile.Id == actual.Profile.Id); Assert.IsTrue(expected.Profile.Password == actual.Profile.Password); CollectionAssert.AreEquivalent(expected.Profile.Purchasers, actual.Profile.Purchasers); Assert.IsTrue(expected.Profile.Username == actual.Profile.Username); CollectionAssert.AreEquivalent(expected.Profile.Suppliers, actual.Profile.Suppliers); Assert.IsTrue(expected.Profile.Usertype == actual.Profile.Usertype); CollectionAssert.AreEquivalent(expected.Profile.Countries, actual.Profile.Countries); Assert.IsTrue(expected.ProfileId == actual.ProfileId); CollectionAssert.AreEquivalent(expected.CompanyCodes, actual.CompanyCodes); CollectionAssert.AreEquivalent(expected.Iloscategories, actual.Iloscategories); CollectionAssert.AreEquivalent(expected.Ilosorderpickgroups, actual.Ilosorderpickgroups); CollectionAssert.AreEquivalent(expected.InformCostTypes, actual.InformCostTypes); CollectionAssert.AreEquivalent(expected.PrimaryDciloscodes, actual.PrimaryDciloscodes); CollectionAssert.AreEquivalent(expected.Purchasers, actual.Purchasers); CollectionAssert.AreEquivalent(expected.SupplierDeliveryUnits, actual.SupplierDeliveryUnits); CollectionAssert.AreEquivalent(expected.VailedForCustomers, actual.VailedForCustomers); CollectionAssert.AreEquivalent(expected.VatTaxCodes, actual.VatTaxCodes); await countryService.DeleteCountry(expected.Id); }
public void Create_CountryNull_ThrowsArgumentNullException() { //Arrange Country invalidCountry = null; Mock <ICountryRepository> countryRepository = new Mock <ICountryRepository>(); ICountryService countryService = new CountryService(countryRepository.Object); //Act Action actual = () => countryService.Create(invalidCountry); //Assert Assert.Throws <ArgumentNullException>(actual); }
public async void TestGetAll() { using (var client = server.CreateClient().AcceptJson()) { var response = await client.GetAsync("/api/Countrys"); var result = await response.Content.ReadAsJsonAsync <List <Country> >(); var service = new CountryService(); var count = service.GetAll().Count(); Assert.Equal(result.Count, count); } }
public void GetCountryById_ValueReturned() { mock.Setup(m => m.Countries.GetAll()).Returns(countries); mock.Setup(m => m.Countries.Get(1)).Returns(countries.ElementAt(0)); var mapper = new MapperConfiguration(cfg => cfg.CreateMap <Country, CountryDTO>()).CreateMapper(); CountryService service = new CountryService(mock.Object); //ISerialize<CountryDTO> serialize = new CountrySerialize(); //CountryDTO example = serialize.serializeVary(mapper.Map<Country, CountryDTO>(countries.ElementAt(0))); CountryDTO data = service.GetCountry(1); Assert.IsNotNull(data); }
public void getRow(int row) { DataTable tbl = new DataTable(); tbl = CountryService.getAllData(); icountry.ID = Convert.ToInt32(tbl.Rows[row][0]); icountry.CountryName = Convert.ToString(tbl.Rows[row][1]); icountry.btnSave = true; icountry.btnDelete = true; icountry.btnDeleteAll = true; icountry.btnAdd = false; }
private static void AddCountry(BancoContext context, CountryService service) { string name = ""; Console.Write("Write the name: "); name = Console.ReadLine(); Country country = new Country() { Name = name }; service.Create(country); Paused(); }
private static void UpdateCountry(BancoContext context, CountryService service) { Country country = FindCountry(context, service); Console.WriteLine($"Id: {country.Id} Name: {country.Name}"); Console.WriteLine(""); Console.Write("Write the new name: "); string name = Console.ReadLine(); country.Name = name; service.Update(country); Paused(); }
public void TestAddingCountryWithNameNull() { var mockSet = new Mock <DbSet <Country> >(); var mockContext = new Mock <TravelSimulatorContext>(); mockContext.Setup(m => m.Countries).Returns(mockSet.Object); var countryService = new CountryService(mockContext.Object); string countryName = null; Assert.Throws <ArgumentException>(() => countryService.AddCountry(countryName)); }
protected override async Task OnInitializedAsync() { Countries = await CountryService.GetAllCountries(); JobCategories = await JobCategoryService.GetAllJobCategories(); if (EmployeeId != 0) { Employee = await EmployeeService.GetEmployeeDetails(EmployeeId); SelectedCountryId = Employee.CountryId.ToString(); SelectedJobCategoryId = Employee.JobCategoryId.ToString(); } }
public void TestIsInUse() { Mock <ICountryDao> countryDaoMock = new Mock <ICountryDao>(); countryDaoMock.Setup(x => x.IsInUse(It.IsAny <Country>())).Returns(true); Country country = new Country(); ICountryService countryService = new CountryService(countryDaoMock.Object); bool isInUse = countryService.IsInUse(country); Assert.IsTrue(isInUse); countryDaoMock.Verify(x => x.IsInUse(country), Times.Once); }
public void CallRepositoryMethodGetByIdOnce() { // Arrange var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedRepository = new Mock <IEfGenericRepository <Country> >(); Country country = new Country(); var service = new CountryService(mockedRepository.Object, mockedUnitOfWork.Object); // Act service.GetCountryById(It.IsAny <int>()); // Arrange mockedRepository.Verify(x => x.GetById(It.IsAny <int>()), Times.Once); }
protected void btnAddNewContact_Click(object sender, EventArgs e) { ViewState["AddOrEdit"] = "Add"; btnAddChangeContact.Text = Resource.Admin_ViewCustomer_Add; txtContactName.Text = ""; txtContactCity.Text = ""; txtContactZone.Text = ""; txtContactAddress.Text = ""; txtContactZip.Text = ""; cboCountry.DataSource = CountryService.GetAllCountryIdAndName(); cboCountry.DataBind(); mvAdressBook.SetActiveView(vAddEditContact); }
public void NotThrow_WhenPassedCountryToAddIsValid() { // arrange var repository = new Mock <IEfRepository <Country> >(); var countryService = new CountryService(repository.Object); var countryModel = new Country() { Name = "SomeName" }; // act & assert Assert.DoesNotThrow(() => countryService.Add(countryModel)); }
protected void Page_PreRender(object sender, EventArgs e) { ICollection <Country> countries = CountryService.GetAllCountries(); List <int> ipList = CountryService.GetCountryIdByIp(Request.UserHostAddress); string countryId = ipList.Count == 1 ? ipList[0].ToString() : SettingsMain.SalerCountryId.ToString();//CountryService.GetCountryIdByIso3(Resource.Admin_Default_CountryISO3).ToString(); cboCountry.DataSource = countries; cboCountry.DataBind(); if (cboCountry.Items.FindByValue(countryId) != null) { cboCountry.SelectedValue = countryId; } }
public ActorDirectorForm() { InitializeComponent(); _actorService = new ActorService(); _countryService = new CountryService(); _directorService = new DirectorService(); cbxOyuncuUlke.DisplayMember = "CountryName"; cbxOyuncuUlke.ValueMember = "CountryID"; cbxOyuncuUlke.DataSource = _countryService.GetAllCountriesService(); cbxYonetmenUlke.DisplayMember = "CountryName"; cbxYonetmenUlke.ValueMember = "CountryID"; cbxYonetmenUlke.DataSource = _countryService.GetAllCountriesService(); }
public void TestCreate() { Mock <ICountryDao> countryDaoMock = new Mock <ICountryDao>(); countryDaoMock.Setup(x => x.Create(It.IsAny <Country>())); string countryName = "D"; ICountryService countryService = new CountryService(countryDaoMock.Object); countryService.Create(countryName); countryDaoMock.Verify(x => x.Create(It.Is <Country>(y => y.Name == countryName))); }
public List <KeyValue> GetCountry(Guid languageID) { var countries = CountryService.GetCountries(languageID); Countries = new List <KeyValue>(); foreach (var country in countries) { Countries.Add(new KeyValue { Key = country.ID.ToString(), Value = country.Name }); } return(Countries); }
public void TestSave() { Mock <ICountryDao> countryDaoMock = new Mock <ICountryDao>(); countryDaoMock.Setup(x => x.Save(It.IsAny <Country>())); Country country = new Country(); ICountryService countryService = new CountryService(countryDaoMock.Object); countryService.Save(country); countryDaoMock.Verify(x => x.Save(country), Times.Once); }
public override void TestsInitialize() { base.TestsInitialize(); this.ZoneService = ClientServiceLocator.Instance().ContractLocator.ZoneServices; this.UserService = ClientServiceLocator.Instance().ContractLocator.UserServices; this.DistrictService = ClientServiceLocator.Instance().ContractLocator.DistrictServices; this.CityVillageService = ClientServiceLocator.Instance().ContractLocator.CityVillageServices; this.CountryService = ClientServiceLocator.Instance().ContractLocator.CountryServices; this.ApmcService = ClientServiceLocator.Instance().ContractLocator.APMCServices; CurrentUserInstance = UserService.GetById(SuperAdminId); CountryInstance = CountryService.GetById(CountryId); }
// GET: Customer/Details/5 public JsonResult Details(int id) { CustomerModel customerModel = CustomerServices.GetCustomer(id); CityModel customerCity = new CityService().GetCity(customerModel.CityId); StateModel customerState = new StateService().GetState(customerCity.StateId ?? 1); CountryModel customerCountry = new CountryService().GetCountry(customerState.CountryId ?? 1); customerModel.CityName = customerCity.Name; customerModel.StateName = customerState.Name; customerModel.CountryName = customerCountry.Name; customerModel._CreatedDate = customerModel.CreatedDate.ToString(); customerModel._UpdatedDate = customerModel.UpdatedDate.ToString(); return(Json(customerModel, JsonRequestBehavior.AllowGet)); }
private void CountryComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { id_Country = CountryService.GetCountry() .Where(x => (x.Name == CountryComboBox.SelectedItem.ToString())) .Select(x => x.Id).FirstOrDefault(); CountrySetNameCountry.Text = CountryService.GetCountry() .Where(x => (x.Name == CountryComboBox.SelectedItem.ToString())) .Select(x => x.Name).FirstOrDefault().ToString(); CountrySetContinent.Text = CountryService.GetCountry() .Where(x => (x.Name == CountryComboBox.SelectedItem.ToString())) .Select(x => x.Continent).FirstOrDefault().ToString(); }
protected void SetUp() { _countryRepository = new Mock <ICountryRepository>(); var countryMapper = new CountryMapper(); var countryService = new CountryService(_countryRepository.Object, countryMapper); _countriesController = new CountriesController(countryService) { Request = new HttpRequestMessage(), Configuration = new HttpConfiguration() }; }
public void CallRepositoryMethodGetAllOnce() { // Arrange var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedRepository = new Mock <IEfGenericRepository <Country> >(); var service = new CountryService(mockedRepository.Object, mockedUnitOfWork.Object); // Act service.GetAllCountries(); // Assert mockedRepository.Verify(x => x.GetAll(), Times.Once); }
public List<Country> GetAllCountries() { var countryService = new CountryService(_dataContext); return countryService.GetCountries(); }
using System;
private void Main_Load(object sender, EventArgs e) { _resortService = new ResortService(_resortRepository); _countryService = new CountryService(_countryRepository); var countries = _countryService.GetAllWithResorts(); foreach (var country in countries) coCountries.Items.Add(country.CountryName); int index = coCountries.FindString("France"); coCountries.SelectedIndex = index; PopResortsCombo(coCountries.SelectedItem.ToString()); lblStatus.Text = string.Empty; }
private void BenDBTests(CountryService countryService, RouteService routeService) { try { CountryDataHelper cdh = new CountryDataHelper(); // create country if doesn't exist Country country = new Country { ID = 1, Name = "Wellington", Code = "WLG" }; if (!countryService.Exists(country)) { country = countryService.Create("Wellington", "WLG"); } country = countryService.Update(country.ID, "WLN"); country = countryService.Update(country.ID, "BEN"); // get latest version Country loadedCountry = countryService.Get(country.ID); cdh.LoadAll(DateTime.Now); // create new zealand country = new Country { Name = "New Zealand", Code = "NZ" }; if (!countryService.Exists(country)) { country = countryService.Create(country.Name, country.Code); } // create australia country = new Country { Name = "Australia", Code = "AUS" }; if (!countryService.Exists(country)) { country = countryService.Create(country.Name, country.Code); } // load all countries var allCountries = countryService.GetAll(); // create christchurch depot RouteNode routeNode = new DistributionCentre("Christchurch"); if (!locationService.Exists(routeNode)) { routeNode = locationService.CreateDistributionCentre("Christchurch"); } // wellington depot routeNode = new DistributionCentre("Wellington"); if (!locationService.Exists(routeNode)) { routeNode = locationService.CreateDistributionCentre("Wellington"); } // australia port country = countryService.GetAll().AsQueryable().First(t => t.Name == "Australia"); var destination = new InternationalPort(country); if (!locationService.Exists(destination)) { destination = locationService.CreateInternationalPort(country.ID); } // get a company var company = new Company() { Name = "NZ Post" }; if (!companyService.Exists(company)) { company = companyService.Create(company.Name); } // create a new route Route route = new Route() { Origin = routeNode, Destination = destination, Company = company, Duration = 300, MaxVolume = 5000, MaxWeight = 5000, CostPerCm3 = 3, CostPerGram = 5, TransportType = TransportType.Air, DepartureTimes = new List<WeeklyTime> { new WeeklyTime(DayOfWeek.Monday, 5, 30) } }; var routeDataHelper = new RouteDataHelper(); int id = routeDataHelper.GetId(route); Logger.WriteLine("Route id is: " + id); if (id == 0) { routeDataHelper.Create(route); } //route = routeDataHelper.Load(1); // edit departure times route.DepartureTimes.Add(new WeeklyTime(DayOfWeek.Wednesday, 14, 35)); // update //routeDataHelper.Update(route); // delete routeDataHelper.Delete(route.ID); var routes = routeDataHelper.LoadAll(); var delivery = new Delivery { Origin = routeNode, Destination = destination, Priority = Priority.Air, WeightInGrams = 200, VolumeInCm3 = 2000, TotalPrice = 2500, TotalCost = 1000, TimeOfRequest = DateTime.UtcNow, TimeOfDelivery = DateTime.UtcNow.AddHours(5.5), Routes = new List<RouteInstance> { new RouteInstance(route, DateTime.UtcNow)} }; var deliveryDataHelper = new DeliveryDataHelper(); deliveryDataHelper.Create(delivery); deliveryDataHelper.Load(delivery.ID); deliveryDataHelper.LoadAll(); var price = new Price { Origin = routeNode, Destination = destination, Priority = Priority.Air, PricePerCm3 = 3, PricePerGram = 5 }; var priceDataHelper = new PriceDataHelper(); //priceDataHelper.Create(price); price.PricePerGram = 10; price.ID = 1; Logger.WriteLine(price.ToString()); } catch (Exception e) { Logger.WriteLine(e.Message); Logger.Write(e.StackTrace); } }
private void MainForm_Load(object sender, EventArgs e) { // initialise logger Logger.Instance.SetOutput(logBox); Logger.WriteLine("Server starting.."); // initialise database Database.Instance.Connect(); // initialise the state object currentState = new CurrentState(); // initialise all the services (they set up the state themselves) and pathfinder countryService = new CountryService(currentState); companyService = new CompanyService(currentState); routeService = new RouteService(currentState); var pathFinder = new PathFinder(routeService); // pathfinder needs the RouteService and state deliveryService = new DeliveryService(currentState, pathFinder); // DeliveryService needs the PathFinder priceService = new PriceService(currentState); locationService = new LocationService(currentState); eventService = new EventService(currentState); statisticsService = new StatisticsService(); // initialise network Network.Network network = Network.Network.Instance; network.Start(); network.Open(); // create controller var controller = new Controller(countryService, companyService, deliveryService, priceService, routeService, locationService, statisticsService, eventService); //BenDBTests(countryService, routeService); //SetUpDatabaseWithData(); /*try { var priceDH = new PriceDataHelper(); var standardPrice = new DomesticPrice(Priority.Standard) { PricePerGram = 3, PricePerCm3 = 5 }; //standardPrice = priceService.CreateDomesticPrice(standardPrice.Priority, standardPrice.PricePerGram, standardPrice.PricePerCm3); standardPrice.PricePerCm3 = 8; //standardPrice = priceService.UpdateDomesticPrice(standardPrice.ID, standardPrice.Priority, standardPrice.PricePerGram, standardPrice.PricePerCm3); var loadedPrice = priceService.GetDomesticPrice(1); var prices = priceService.GetAllDomesticPrices(); var normalPrices = priceService.GetAll(); } catch (DatabaseException er) { Logger.WriteLine(er.Message); Logger.Write(er.StackTrace); }*/ }