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); }
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); }
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); }