Exemplo n.º 1
0
        public void Update(Country country)
        {
            var orgCountry = this.countries.GetById(country.Id);

            if (country != null)
            {
                orgCountry.Name = country.Name;
                this.countries.Save();
            }
        }
        public static void MyClassInitialize(TestContext testContext)
        {
            var db = new Database("test.db");
            countryDataHelper = new CountryDataHelper();
            routeNodeDataHelper = new RouteNodeDataHelper();

            nz = new Country { Name = "New Zealand", Code = "NZ" };
            aus = new Country { Name = "Australia", Code = "AUS" };
            db.ClearTable("countries");

            countryDataHelper.Create(nz);
            countryDataHelper.Create(aus);
        }
Exemplo n.º 3
0
        public Country Create(string name)
        {
            var country = new Country()
            {
                Name = name,
                CreatedOn = DateTime.UtcNow
            };

            this.countries.Add(country);
            this.countries.Save();

            return country;
        }
Exemplo n.º 4
0
        public void SeedData()
        {
            var countries = new string[]
              {
                        "Afghanistan",
                        "Albania",
                        "Algeria",
                        "Argentina",
                        "Armenia",
                        "Australia",
                        "Austria",
                        "Azerbaijan",
                        "Bahamas",
                        "Bahrain",
                        "Bangladesh",
                        "Barbados",
                        "Belarus",
                        "Belgium",
                        "Bolivia",
                        "Bosnia and Herzegovina",
                        "Botswana",
                        "Bouvet Island",
                        "Brazil",
                        "Bulgaria",
                        "Cambodia",
                        "Canada",
                        "Chad",
                        "Chile",
                        "China",
                        "Colombia",
                        "Congo",
                        "Costa Rica",
                        "Croatia",
                        "Czech Republic",
                        "Denmark",
                        "Djibouti",
                        "Dominica",
                        "Dominican Republic",
                        "Ecuador",
                        "Egypt",
                        "Estonia",
                        "Ethiopia",
                        "Finland",
                        "France",
                        "Gabon",
                        "Gambia",
                        "Georgia",
                        "Germany",
                        "Ghana",
                        "Gibraltar",
                        "Greece",
                        "Greenland",
                        "Grenada",
                        "Guadeloupe",
                        "Guam",
                        "Guatemala",
                        "Guinea",
                        "Guyana",
                        "Haiti",
                        "Honduras",
                        "Hong Kong",
                        "Hungary",
                        "Iceland",
                        "India",
                        "Indonesia",
                        "Iraq",
                        "Ireland",
                        "Israel",
                        "Italy",
                        "Jamaica",
                        "Japan",
                        "Jordan",
                        "Kazakhstan",
                        "Kenya",
                        "Kyrgyzstan",
                        "Latvia",
                        "Lebanon",
                        "Lithuania",
                        "Luxembourg",
                        "Mexico",
                        "Monaco",
                        "Namibia",
                        "Nauru",
                        "Nepal",
                        "Netherlands",
                        "Netherlands Antilles",
                        "New Caledonia",
                        "New Zealand",
                        "Nicaragua",
                        "Niger",
                        "Nigeria",
                        "Niue",
                        "Norfolk Island",
                        "Northern Mariana Islands",
                        "Norway",
                        "Oman",
                        "Pakistan",
                        "Palau",
                        "Palestinian Territory, Occupied",
                        "Panama",
                        "Papua New Guinea",
                        "Paraguay",
                        "Peru",
                        "Philippines",
                        "Pitcairn",
                        "Poland",
                        "Portugal",
                        "Puerto Rico",
                        "Qatar",
                        "Reunion",
                        "Romania",
                        "Russia",
                        "Saudi Arabia",
                        "Serbia and Montenegro",
                        "Singapore",
                        "Slovenia",
                        "South Africa",
                        "Spain",
                        "Sri Lanka",
                        "Sudan",
                        "Sweden",
                        "Switzerland",
                        "Taiwan, Province of China",
                        "Tajikistan",
                        "Thailand",
                        "Togo",
                        "Trinidad and Tobago",
                        "Turkey",
                        "Turkmenistan",
                        "Uganda",
                        "Ukraine",
                        "United Arab Emirates",
                        "United Kingdom",
                        "United States",
                        "Uruguay",
                        "Uzbekistan",
                        "Vanuatu",
                        "Venezuela",
                        "Viet Nam",
                        "Zambia",
                        "Zimbabwe",
              };

            var industries = new string[]
            {
                    "Agriculture",
                    "Coatings & Adhesives",
                    "Environmental Sciences",
                    "Food Ingredients",
                    "Household & Industrial Cleaning",
                    "Mining",
                    "Oil & Gas",
                    "Personal Care",
                    "Pharma Ingredients",
                    "Water Treatment"
            };

            var hazards = new string[]
            {
                "Not Classified",
                "Explosives",
                "Gases",
                "Flammable Liquids",
                "Flammable Solids",
                "Oxidizing Substances",
                "Toxic & Infectious Substances",
                "Radioactive Material",
                "Corrosives",
                "Miscellaneous Dangerous Goods"
            };

            if (!this.context.Countries.Any())
            {
                foreach (var countryName in countries)
                {
                    var newCountry = new Country()
                    {
                        Name = countryName
                    };

                    this.context.Countries.Add(newCountry);
                }

                this.context.SaveChanges();
            }

            if (!this.context.Industries.Any())
            {
                foreach (var industryName in industries)
                {
                    var newIndustry = new Industry()
                    {
                        Name = industryName
                    };

                    this.context.Industries.Add(newIndustry);
                }

                this.context.SaveChanges();
            }

            if (!this.context.HazardClassifications.Any())
            {
                foreach (var hazard in hazards)
                {
                    var newHazard = new HazardClassification()
                    {
                        Class = hazard
                    };

                    this.context.HazardClassifications.Add(newHazard);
                }

                this.context.SaveChanges();
            }

            if (!this.context.TransportModes.Any())
            {
                var sea = new TransportMode()
                {
                    Mode = "sea freight"
                };

                var air = new TransportMode()
                {
                    Mode = "air freight"
                };

                this.context.TransportModes.Add(sea);
                this.context.TransportModes.Add(air);

                this.context.SaveChanges();
            }

            // Producers
            if (!this.context.Producers.Any())
            {
                var inputCountries = this.context.Countries.ToList();
                SeedProducers(inputCountries);
            }

            if (!this.context.Products.Any())
            {

                // Images
                var images = new List<Image>();
                var directory = AssemblyHelpers.GetDirectoryForAssembyl(Assembly.GetExecutingAssembly());
                var files = Directory.GetFiles(directory + "/Images/", "*.*");
                foreach (var file in files)
                {
                    var byteArray = File.ReadAllBytes(file);
                    var image = new Image
                    {
                        Content = byteArray,
                        FileExtension = file.Substring(file.LastIndexOf(".") + 1)
                    };

                    images.Add(image);
                }

                // Products
                var producers = this.context.Producers.ToList();
                var classifications = this.context.HazardClassifications.ToList();
                var industryType = this.context.Industries.ToList();
                var products = new List<Product>
            {
                new Product
                {
                     Name = "ACETIC ACID",
                     Description = "An organic compound with the chemical formula CH3COOH (also written as CH3CO2H or C2H4O2). It is a colourless liquid that when undiluted is also called glacial acetic acid. Vinegar is roughly 3–9% acetic acid by volume, making acetic acid the main component of vinegar apart from water. Acetic acid has a distinctive sour taste and pungent smell. Besides its production as household vinegar, it is mainly produced as a precursor to polyvinylacetate and cellulose acetate. Although it is classified as a weak acid, concentrated acetic acid is corrosive and can attack the skin.",
                     Price = 22.49M,
                     Quantity = 10M,
                     ProductType = ProductType.Liquid,
                     DateAdded = DateTime.Now
                },
                  new Product
                {
                     Name = "AMMONIUM BISULPHITE",
                     Description = "A white, crystalline solid with formula (NH4)HSO4. It is the product of the half-neutralization of sulfuric acid by ammonia.",
                     Price = 15.50M,
                     Quantity = 5M,
                     ProductType = ProductType.Powder,
                     DateAdded = DateTime.Now
                },
                new Product
                {
                     Name = "AMMONIUM CHLORIDE",
                     Description = "An inorganic compound with the formula NH4Cl, is a white crystalline salt, highly soluble in water. Solutions of ammonium chloride are mildly acidic. Sal ammoniac is a name of the natural, mineralogical form of ammonium chloride. The mineral is commonly formed on burning coal dumps, due to condensation of coal-derived gases. It is also found around some types of volcanic vents. It is mainly used as fertilizer and a flavouring agent in some types of liquorice. It is the product from the reaction of hydrochloric acid and ammonia.",
                     Price = 14.44M,
                     Quantity = 6M,
                     ProductType = ProductType.Powder,
                     DateAdded = DateTime.Now
                },
                new Product
                {
                     Name = "Baryte",
                     Description = "A mineral consisting of barium sulfate.The baryte group consists of baryte, celestine, anglesite and anhydrite. Baryte is generally white or colorless, and is the main source of barium. Baryte and celestine form a solid solution (Ba,Sr)SO4",
                     Price = 16.99M,
                     Quantity = 7M,
                     ProductType = ProductType.Powder,
                     DateAdded = DateTime.Now
                },
                 new Product
                {
                     Name = "HYDRATED ALUMINIUM SILICATE",
                     Description = "Aluminium silicate is a type of fibrous material made of aluminium oxide and silicon dioxide, (such materials are also called aluminosilicate fibres). These are glassy solid solutions rather than chemical compounds. The compositions are often described in terms of % weight of alumina, Al2O3 and silica, SiO2. Temperature resistance increases as the % alumina increases. These fibrous materials can be encountered as loose wool, blanket, felt, paper or boards.",
                     Price = 16.89M,
                     Quantity = 5.5M,
                     ProductType = ProductType.Powder,
                     DateAdded = DateTime.Now
                },
                 new Product
                {
                     Name = "CALCIUM CARBONATE",
                     Description = "A chemical compound with the formula CaCO3. It is a common substance found in rocks as the minerals calcite and aragonite (most notably as limestone), and is the main component of shells of marine organisms, snails, pearls, and eggshells. Calcium carbonate is the active ingredient in agricultural lime, and is created when calcium ions in hard water react with carbonate ions creating limescale. It is commonly used medicinally as a calcium supplement or as an antacid, but excessive consumption can be hazardous.",
                     Price = 16.89M,
                     Quantity = 6M,
                     ProductType = ProductType.Powder,
                     DateAdded = DateTime.Now
                },
                  new Product
                {
                     Name = "CITRIC ACID",
                     Description = "A weak organic tribasic acid. It occurs naturally in citrus fruits. In biochemistry, it is an intermediate in the citric acid cycle, which occurs in the metabolism of all aerobic organisms.More than a million tons of citric acid are manufactured every year. It is used widely as an acidifier, as a flavoring, and as a chelating agent.",
                     Price = 22M,
                     Quantity = 9M,
                     ProductType = ProductType.Liquid,
                     DateAdded = DateTime.Now
                },
                new Product
                {
                     Name = "CITRIC ACID",
                     Description = "A weak organic tribasic acid. It occurs naturally in citrus fruits. In biochemistry, it is an intermediate in the citric acid cycle, which occurs in the metabolism of all aerobic organisms.More than a million tons of citric acid are manufactured every year. It is used widely as an acidifier, as a flavoring, and as a chelating agent.",
                     Price = 22M,
                     Quantity = 9M,
                     ProductType = ProductType.Liquid,
                     DateAdded = DateTime.Now
                },
                new Product
                {
                     Name = "GLUTARALDEHYDE",
                     Description = "An organic compound with the formula CH2(CH2CHO)2. A pungent colorless oily liquid, glutaraldehyde is used to sterilise medical and dental equipment. It is also used for industrial water treatment and as a preservative. It is mainly available as an aqueous solution, and in these solutions the aldehyde groups are hydrated.",
                     Price = 23.99M,
                     Quantity = 8M,
                     ProductType = ProductType.Liquid,
                     DateAdded = DateTime.Now
                },
                new Product
                {
                     Name = "GLUTARALDEHYDE",
                     Description = "A clear, colorless, highly pungent solution of hydrogen chloride (HCl) in water. It is a highly corrosive, strong mineral acid with many industrial uses. Hydrochloric acid is found naturally in gastric acid. When it reacts with an organic base it forms a hydrochloride salt",
                     Price = 10.99M,
                     Quantity = 6M,
                     ProductType = ProductType.Liquid,
                     DateAdded = DateTime.Now
                },
                 new Product
                {
                     Name = "ISO-BUTANOL",
                     Description = "An organic compound with the formula (CH3)2CHCH2OH (sometimes represented as i-BuOH). This colorless, flammable liquid with a characteristic smell is mainly used as a solvent. Its isomers, the other butanols, include n-butanol, 2-butanol, and tert-butanol, all of which are important industrially.",
                     Price = 9.95M,
                     Quantity = 7M,
                     ProductType = ProductType.Liquid,
                     DateAdded = DateTime.Now
                },
                new Product
                {
                     Name = "Starch",
                     Description = "A carbohydrate consisting of a large number of glucose units joined by glycosidic bonds. This polysaccharide is produced by most green plants as an energy store. It is the most common carbohydrate in human diets and is contained in large amounts in staple foods such as potatoes, wheat, maize (corn), rice, and cassava. Pure starch is a white, tasteless and odorless powder that is insoluble in cold water or alcohol. It consists of two types of molecules: the linear and helical amylose and the branched amylopectin.Depending on the plant, starch generally contains 20 to 25 % amylose and 75 to 80 % amylopectin by weight.",
                     Price = 25M,
                     Quantity = 10M,
                     ProductType = ProductType.Powder,
                     DateAdded = DateTime.Now
                },
                 new Product
                {
                     Name = "SODIUM CHLORIDE",
                     Description = "An ionic compound with the chemical formula NaCl, representing a 1:1 ratio of sodium and chloride ions. Sodium chloride is the salt most responsible for the salinity of seawater and of the extracellular fluid of many multicellular organisms. In the form of edible or table salt it is commonly used as a condiment and food preservative. Large quantities of sodium chloride are used in many industrial processes, and it is a major source of sodium and chlorine compounds used as feedstocks for further chemical syntheses. A second major consumer of sodium chloride is de-icing of roadways in sub-freezing weather.",
                     Price = 21M,
                     Quantity = 10M,
                     ProductType = ProductType.Powder,
                     DateAdded = DateTime.Now
                }
            };

                for (int i = 0; i < products.Count; i++)
                {
                    products[i].ProducerId = producers[generator.Next(0, producers.Count())].Id;
                    products[i].HazardClassificationId = classifications[generator.Next(0, classifications.Count())].Id;
                    products[i].Industries.Add(industryType[generator.Next(0, industryType.Count())]);
                    products[i].Image = images[i];

                    this.context.Products.Add(products[i]);
                }

                this.context.SaveChanges();
            }
        }
        public void UpdateTestForTransactionRollback()
        {
            var country = new Country() { Name = "Wellington", Code = "NZ" };
            dataHelper.Create(country);

            Console.WriteLine("Before update, there are {0} events", Database.Instance.GetNumRows("events"));
            try
            {
                dataHelper.Update(country);
                throw new AssertFailedException("Should have thrown a DatabaseException");
            }
            catch (SQLiteException e)
            {
                Console.WriteLine(e);
                VerifyNumberOfEvents(1);
            }
        }
        public void UpdateTest2()
        {
            long countryId = 1;
            object created = DateTime.UtcNow;
            string name = "Wellington";
            string code = "NZ";

            // create
            var country = new Country() {Name = name, Code = code};
            dataHelper.Create(country);

            // update
            country.Code = "NB";
            dataHelper.Update(country);

            // get last two rows of database
            var actual = Database.Instance.GetLastRows("countries", 2);

            // what we expect them to look like
            var expected1 = new object[] { 0, 0, countryId, created, 0, name, code };
            var expected2 = new object[] { 0, 0, countryId, created, 1, name, "NB" };

            // assert
            AssertRowValuesMatch(expected1, actual[0]);
            AssertRowValuesMatch(expected2, actual[1]);
        }
 public void UpdateTest1()
 {
     try
     {
         var country = new Country() {Name = "Wellington", Code = "NZ"};
         dataHelper.Update(country);
         throw new AssertFailedException("Should have thrown a DatabaseException");
     }
     catch (DatabaseException e)
     {
         Console.WriteLine(e);
         VerifyNumberOfEvents(0);
     }
 }
        public void UpdateTest()
        {
            var country = new Country() {Name = "Wellington", Code = "NZ"};

            dataHelper.Create(country);

            country.Code = "NB";
            dataHelper.Update(country);

            VerifyEvent(EventType.Update);
            VerifyNumberOfEvents(2);
        }
        public void LoadAllTimestamp1()
        {
            Country newCountry = new Country();
            newCountry.Name = "TestCountry";
            newCountry.Code = "TST";
            CountryDataHelper target = new CountryDataHelper(); // TODO: Initialize to an appropriate value
            DateTime timestamp;
            Console.WriteLine("Create start");
            target.Create(newCountry);
            Console.WriteLine("Create end");
            timestamp = DateTime.Now;
            Console.WriteLine("Delete start");
            target.Delete(newCountry);
            Console.WriteLine("Delete end");

            Console.WriteLine("LoadAll() start");
            Assert.IsTrue(target.LoadAll().Count == 0);
            Console.WriteLine("LoadAll() end");

            Console.WriteLine("LoadAll(timestamp) start");
            var data = target.LoadAll(timestamp);
            Country[] returned = new Country[data.Count];
            data.Values.CopyTo(returned, 0);
            Assert.IsTrue(returned.Length == 1);
        }
Exemplo n.º 10
0
 public InternationalPort(Country country)
     : base(country)
 {
 }
Exemplo n.º 11
0
        private void SetUpDatabaseWithData()
        {
            var countryDataHelper = new CountryDataHelper();

            // countries
            var newZealand = new Country { Name = "New Zealand", Code = "NZ"};
            countryDataHelper.Create(newZealand);

            var australia = new Country { Name = "Australia", Code = "AUS" };
            countryDataHelper.Create(australia);

            var japan = new Country { Name = "Japan", Code = "JAP" };
            countryDataHelper.Create(japan);

            var routeNodeDataHelper = new RouteNodeDataHelper();
            // international ports
            var australiaP = new InternationalPort(australia);
            routeNodeDataHelper.Create(australiaP);

            var japanP = new InternationalPort(japan);
            routeNodeDataHelper.Create(japanP);

            // distribution centres
            var auckland = new DistributionCentre("Auckland");
            routeNodeDataHelper.Create(auckland);
            var wellington = new DistributionCentre("Wellington");
            routeNodeDataHelper.Create(wellington);
            var christchurch = new DistributionCentre("Christchurch");
            routeNodeDataHelper.Create(christchurch);
            var hamilton = new DistributionCentre("Hamilton");
            routeNodeDataHelper.Create(hamilton);
            var rotorua = new DistributionCentre("Rotorua");
            routeNodeDataHelper.Create(rotorua);
            var palmerstonNorth = new DistributionCentre("Palmerston North");
            routeNodeDataHelper.Create(palmerstonNorth);
            var dunedin = new DistributionCentre("Dunedin");
            routeNodeDataHelper.Create(dunedin);

            // company
            var companyDataHelper = new CompanyDataHelper();
            var nzPost = new Company{ Name = "NZ Post" };
            companyDataHelper.Create(nzPost);
            var quantas = new Company{ Name = "Quantas" };
            companyDataHelper.Create(quantas);
            var airNZ = new Company { Name = "Air New Zealand" };
            companyDataHelper.Create(airNZ);

            // routes
            var routeDataHelper = new RouteDataHelper();
            var wellToAuckLand = new Route { Origin = wellington, Destination = auckland, Company = nzPost, TransportType = TransportType.Land, CostPerCm3 = 2, CostPerGram = 2, MaxVolume = 10000, MaxWeight = 5000, Duration = 480, DepartureTimes = new List<WeeklyTime> { new WeeklyTime(DayOfWeek.Monday, 8, 0), new WeeklyTime(DayOfWeek.Tuesday, 8, 0), new WeeklyTime(DayOfWeek.Wednesday, 8, 0), new WeeklyTime(DayOfWeek.Thursday, 8, 0), new WeeklyTime(DayOfWeek.Friday, 8, 0) } };
            routeDataHelper.Create(wellToAuckLand);

            var wellToAuckAir = new Route { Origin = wellington, Destination = auckland, Company = airNZ, TransportType = TransportType.Air, CostPerCm3 = 8, CostPerGram = 10, MaxVolume = 10000, MaxWeight = 5000, Duration = 100, DepartureTimes = new List<WeeklyTime> { new WeeklyTime(DayOfWeek.Monday, 8, 0), new WeeklyTime(DayOfWeek.Tuesday, 8, 0), new WeeklyTime(DayOfWeek.Wednesday, 8, 0), new WeeklyTime(DayOfWeek.Thursday, 8, 0), new WeeklyTime(DayOfWeek.Friday, 8, 0) } };
            routeDataHelper.Create(wellToAuckAir);

            var auckToAusAir = new Route { Origin = auckland, Destination = australiaP, Company = airNZ, TransportType = TransportType.Air, CostPerCm3 = 10, CostPerGram = 12, MaxVolume = 8000, MaxWeight = 3000, Duration = 150, DepartureTimes = new List<WeeklyTime> { new WeeklyTime(DayOfWeek.Monday, 11, 0), new WeeklyTime(DayOfWeek.Tuesday, 11, 0), new WeeklyTime(DayOfWeek.Wednesday, 11, 0), new WeeklyTime(DayOfWeek.Thursday, 11, 0), new WeeklyTime(DayOfWeek.Friday, 11, 0) } };
            routeDataHelper.Create(auckToAusAir);

            // prices
            var priceDataHelper = new PriceDataHelper();
            var wellToAuckStandardPrice = new Price { Origin = wellington, Destination = auckland, Priority = Priority.Standard, PricePerCm3 = 4, PricePerGram = 4 };
            priceDataHelper.Create(wellToAuckStandardPrice);

            var wellToAuckAirPrice = new Price { Origin = wellington, Destination = auckland, Priority = Priority.Air, PricePerCm3 = 12, PricePerGram = 12 };
            priceDataHelper.Create(wellToAuckAirPrice);

            var auckToAusAirPrice = new Price { Origin = auckland, Destination = australiaP, Priority = Priority.Air, PricePerCm3 = 15, PricePerGram = 15 };
            priceDataHelper.Create(auckToAusAirPrice);
        }
Exemplo n.º 12
0
 protected bool Equals(Country other)
 {
     return string.Equals(name, other.name);
 }
        /// <summary>
        /// Setups the manager.
        /// </summary>
        private void SetupData()
        {
            var countries = new Country { CountryId = "1", Name = "USA", SourceCode = "USA", CountryFlagAddress = "http://localhost" };

            var states = new State { StateId = "2", CountryId = "1", Name = "Florida" };

            var ports = new Port { PortId = "1", City = "Florida", Name = "Miami", State = "Florida", StateId = "2", CountryId = "1" };

            var brands = new Brand { BrandId = "5", Name = "Carnival", MediaItemAddress = "http://localhost" };

            var personTypes = new PersonTypeEntity { PersonTypeId = "1001", Name = "Daniel" };

            var loyaltyLevelTypes = new LoyaltyLevelType { LoyaltyLevelTypeId = "1001", Name = "abc", BrandId = "1", NoOfCruiseNights = 3, LogoImageAddress = "ABC" };

            var documentType = new DocumentType { CountryId = "231", Code = "USA", DocumentTypeId = "1", Name = "Passport" };

            var brand = new ListResult<Brand>();
            brand.Items.Add(brands);

            var country = new ListResult<Country>();
            country.Items.Add(countries);

            var state = new ListResult<State>();
            state.Items.Add(states);

            var port = new ListResult<Port>();
            port.Items.Add(ports);

            var personTypeEntity = new ListResult<PersonTypeEntity>();
            personTypeEntity.Items.Add(personTypes);

            var loyaltyLevelType = new ListResult<LoyaltyLevelType>();
            loyaltyLevelType.Items.Add(loyaltyLevelTypes);

            var documentTypes = new ListResult<DocumentType>();
            documentTypes.Items.Add(documentType);

            this.referenceDataRepository.Setup(data => data.RetrieveBrandListAsync()).Returns(Task.FromResult(brand));
            this.referenceDataRepository.Setup(data => data.RetrieveCountryListAsync(It.IsAny<string>(), It.IsAny<string>())).Returns(Task.FromResult(country));
            this.referenceDataRepository.Setup(data => data.RetrieveLoyaltyLevelTypeListAsync()).Returns(Task.FromResult(loyaltyLevelType));
            this.referenceDataRepository.Setup(data => data.RetrievePersonTypeListAsync()).Returns(Task.FromResult(personTypeEntity));
            this.referenceDataRepository.Setup(data => data.RetrievePortListAsync()).Returns(Task.FromResult(port));
            this.referenceDataRepository.Setup(data => data.RetrieveStateListAsync()).Returns(Task.FromResult(state));
            this.referenceDataRepository.Setup(data => data.RetrieveDocumentTypeListAsync()).Returns(Task.FromResult(documentTypes));
        }
Exemplo n.º 14
0
 public void SaveCountry(Country country)
 {
     countries[country.ID] = country;
 }
Exemplo n.º 15
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Country EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToCountry(Country country)
 {
     base.AddObject("Country", country);
 }
Exemplo n.º 16
0
        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);
            }
        }
Exemplo n.º 17
0
 /// <summary>
 /// Create a new Country object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 public static Country CreateCountry(global::System.Int32 id, global::System.String name)
 {
     Country country = new Country();
     country.ID = id;
     country.Name = name;
     return country;
 }
 /// <summary>
 /// Create a new Country object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="country1">Initial value of the Country1 property.</param>
 public static Country CreateCountry(global::System.Int32 id, global::System.String country1)
 {
     Country country = new Country();
     country.Id = id;
     country.Country1 = country1;
     return country;
 }