Пример #1
0
        public void TestCreateUser()
        {
            TruncateTable("User");

            TmsDal dal = new TmsDal();

            User user = new User();

            user.Username  = "******";
            user.Password  = "******";
            user.Email     = "*****@*****.**";
            user.FirstName = "Testing";
            user.LastName  = "Testerson";
            user.Type      = UserType.Admin;

            bool excepted = false;

            try
            {
                dal.CreateUser(user);
            }
            catch (CouldNotInsertException)
            {
                excepted = true;
            }

            Assert.IsFalse(excepted);
        }
Пример #2
0
        public void TestCreateCarrier()
        {
            TruncateTable("User");

            Carrier carrier = new Carrier();

            carrier.Name            = "WindsorCarrier1";
            carrier.DepotCity       = City.Windsor;
            carrier.FtlAvailability = 100;
            carrier.LtlAvailability = 50;

            TmsDal dal = new TmsDal();

            bool excepted = false;

            try
            {
                carrier = dal.CreateCarrier(carrier);
            }
            catch (CouldNotInsertException)
            {
                excepted = true;
            }

            Assert.IsFalse(excepted);
            Assert.IsTrue(carrier.CarrierID > 0);
        }
        public void CityListValid()
        {
            TmsDal      CityData = new TmsDal();
            List <Trip> CityInfo = CityData.GetTrips();

            CitiesData[] CityList = new CitiesData[CityInfo.Count];
            int          indexNum = 0;

            foreach (Trip City in CityInfo)
            {
                CityList[indexNum] = new CitiesData(indexNum, City.Distance, City.TravelTime);
                indexNum++;
            }
            //Validate KMs
            Assert.AreEqual(CityList[0].EastKM, 191);
            Assert.AreEqual(CityList[1].EastKM, 128);
            Assert.AreEqual(CityList[2].EastKM, 68);
            Assert.AreEqual(CityList[3].EastKM, 60);
            Assert.AreEqual(CityList[4].EastKM, 134);
            Assert.AreEqual(CityList[5].EastKM, 82);
            Assert.AreEqual(CityList[6].EastKM, 196);

            //Validate Time
            Assert.AreEqual(CityList[0].EastMinutes, 150);
            Assert.AreEqual(CityList[1].EastMinutes, 105);
            Assert.AreEqual(CityList[2].EastMinutes, 75);
            Assert.AreEqual(CityList[3].EastMinutes, 78);
            Assert.AreEqual(CityList[4].EastMinutes, 99);
            Assert.AreEqual(CityList[5].EastMinutes, 72);
            Assert.AreEqual(CityList[6].EastMinutes, 150);
        }
Пример #4
0
        public void TestGetCarrier()
        {
            Carrier carrier = new Carrier();

            carrier.Name            = "HamiltonCarrier1";
            carrier.DepotCity       = City.Hamilton;
            carrier.FtlAvailability = 20;
            carrier.LtlAvailability = 13;

            TmsDal dal = new TmsDal();

            bool excepted = false;

            try
            {
                carrier = dal.CreateCarrier(carrier);
            }
            catch (CouldNotInsertException)
            {
                excepted = true;
            }

            try
            {
                carrier = dal.GetCarrier(carrier.CarrierID);
            }
            catch (CarrierNotExistsException)
            {
                excepted = true;
            }

            Assert.IsFalse(excepted);
        }
Пример #5
0
        public void TestGetCarriers()
        {
            TmsDal dal = new TmsDal();

            List <Carrier> carriers = dal.GetCarriers();

            Assert.IsFalse(carriers.Count == 0);
        }
Пример #6
0
        public void TestGetTrips()
        {
            TmsDal dal = new TmsDal();

            List <Trip> trips = dal.GetTrips();

            Assert.IsTrue(trips.Count > 0);
        }
Пример #7
0
        public void TestGetCustomers()
        {
            Customer customer = new Customer();

            customer.Name = "Test Customer";

            TmsDal dal = new TmsDal();

            customer = dal.CreateCustomer(customer);

            Assert.IsTrue(dal.GetCustomers().Count > 0);
        }
Пример #8
0
        public void TestBackupDatabase()
        {
            TmsDal dal = new TmsDal();

            if (!Directory.Exists("testbackups"))
            {
                Directory.CreateDirectory("testbackups");
            }

            dal.BackupDatabase("testbackups");

            Directory.Delete("testbackups", true);
        }
Пример #9
0
        public void TestDeleteCarrier()
        {
            Carrier carrier = new Carrier();

            carrier.Name            = "BellevilleCarrier1";
            carrier.DepotCity       = City.Belleville;
            carrier.FtlAvailability = 53;
            carrier.LtlAvailability = 28;

            TmsDal dal = new TmsDal();

            bool excepted = false;

            try
            {
                carrier = dal.CreateCarrier(carrier);
            }
            catch (CouldNotInsertException)
            {
                excepted = true;
            }

            try
            {
                dal.SetFtlRate(carrier.CarrierID, (float)1.28);
            }
            catch (CouldNotInsertException)
            {
                excepted = true;
            }

            try
            {
                dal.SetLtlRate(carrier.CarrierID, (float)5.23);
            }
            catch (CouldNotInsertException)
            {
                excepted = true;
            }

            try
            {
                dal.DeleteCarrier(carrier.CarrierID);
            }
            catch (CouldNotDeleteException)
            {
                excepted = true;
            }

            Assert.IsFalse(excepted);
        }
Пример #10
0
        public void TestGetFtlRate()
        {
            TmsDal dal = new TmsDal();

            Carrier carrier = new Carrier();

            carrier.Name            = "WindsorCarrier6";
            carrier.DepotCity       = City.Windsor;
            carrier.FtlAvailability = 53;
            carrier.LtlAvailability = 28;
            carrier = dal.CreateCarrier(carrier);

            dal.SetFtlRate(carrier.CarrierID, (float)7.283);
            dal.GetFtlRate(carrier.CarrierID);
        }
Пример #11
0
        public void TestGetReeferCharge()
        {
            TmsDal dal = new TmsDal();

            Carrier carrier = new Carrier();

            carrier.Name            = "WindsorCarrier7";
            carrier.DepotCity       = City.Windsor;
            carrier.FtlAvailability = 53;
            carrier.LtlAvailability = 28;
            carrier = dal.CreateCarrier(carrier);

            dal.SetReeferCharge(carrier.CarrierID, (float)5.99);
            dal.GetReeferCharge(carrier.CarrierID);
        }
        static private CitiesData[] GetCityData()
        {
            TmsDal      CityData = new TmsDal();
            List <Trip> CityInfo = CityData.GetTrips();

            CitiesData[] CityList = new CitiesData[CityInfo.Count];
            int          indexNum = 0;

            foreach (Trip City in CityInfo)
            {
                CityList[indexNum] = new CitiesData(indexNum, City.Distance, City.TravelTime);
                indexNum++;
            }

            return(CityList);
        }
Пример #13
0
        public void TestGetUserID()
        {
            TmsDal dal = new TmsDal();

            bool excepted = false;

            try
            {
                dal.GetUserID("admin");
            }
            catch (UserNotExistsException)
            {
                excepted = true;
            }

            Assert.IsFalse(excepted);
        }
Пример #14
0
        public void TestSetFtlRate()
        {
            Carrier carrier = new Carrier();

            carrier.Name            = "OshawaCarrier1";
            carrier.DepotCity       = City.Oshawa;
            carrier.LtlAvailability = 8;
            carrier.FtlAvailability = 18;

            TmsDal dal = new TmsDal();

            bool excepted = false;

            // Insert carrier
            try
            {
                carrier = dal.CreateCarrier(carrier);
            }
            catch (CouldNotInsertException)
            {
                excepted = true;
            }

            // Try inserting a new ftl rate
            try
            {
                dal.SetFtlRate(carrier.CarrierID, (float)250.89);
            }
            catch (CouldNotInsertException)
            {
                excepted = true;
            }

            // Then try updating the existing rate
            try
            {
                dal.SetFtlRate(carrier.CarrierID, (float)180.20);
            }
            catch (CouldNotUpdateException)
            {
                excepted = true;
            }

            Assert.IsFalse(excepted);
        }
Пример #15
0
        public void TestSetReeferCharge()
        {
            Carrier carrier = new Carrier();

            carrier.Name            = "OshawaCarrier3";
            carrier.DepotCity       = City.Ottawa;
            carrier.LtlAvailability = 9;
            carrier.FtlAvailability = 19;

            TmsDal dal = new TmsDal();

            bool excepted = false;

            // Insert carrier
            try
            {
                carrier = dal.CreateCarrier(carrier);
            }
            catch (CouldNotInsertException)
            {
                excepted = true;
            }

            // Try inserting a new ltl rate
            try
            {
                dal.SetReeferCharge(carrier.CarrierID, (float)49.99);
            }
            catch (CouldNotInsertException)
            {
                excepted = true;
            }

            // Then try updating the existing rate
            try
            {
                dal.SetReeferCharge(carrier.CarrierID, (float)44.99);
            }
            catch (CouldNotUpdateException)
            {
                excepted = true;
            }

            Assert.IsFalse(excepted);
        }
Пример #16
0
        public void TestGetCustomer()
        {
            TmsDal dal = new TmsDal();

            Customer customer;

            bool excepted = false;

            try
            {
                customer = dal.GetCustomer("Test");
            }
            catch (CustomerNotExistsException)
            {
                excepted = true;
            }

            Assert.IsFalse(excepted);
        }
Пример #17
0
        public void TestCreateContract()
        {
            TmsDal dal = new TmsDal();

            Customer customer = new Customer();

            customer.Name = "TestCustomer";
            customer      = dal.CreateCustomer(customer);

            Contract contract = new Contract();

            contract.Carrier     = dal.GetCarrier(1);
            contract.Customer    = customer;
            contract.JobType     = JobType.FTL;
            contract.VanType     = VanType.Dry;
            contract.Quantity    = 1;
            contract.Status      = Status.STARTED;
            contract.Origin      = City.Windsor;
            contract.Destination = City.Toronto;

            contract = dal.CreateContract(contract);
        }
Пример #18
0
        public void TestCreateCustomer()
        {
            //TruncateTable("Customer");

            Customer customer = new Customer();

            customer.Name = "Test";

            TmsDal dal = new TmsDal();

            bool excepted = false;

            try
            {
                customer = dal.CreateCustomer(customer);
            }
            catch (CouldNotInsertException)
            {
                excepted = true;
            }

            Assert.IsFalse(excepted);
        }
Пример #19
0
        public void TestDeleteCustomer()
        {
            Customer customer = new Customer();

            customer.Name = "Test";

            TmsDal dal = new TmsDal();

            customer = dal.CreateCustomer(customer);

            bool excepted = false;

            try
            {
                dal.DeleteCustomer(customer.CustomerID);
            }
            catch (CouldNotDeleteException)
            {
                excepted = true;
            }

            Assert.IsFalse(excepted);
        }
Пример #20
0
        public void TestUpdateCarrier()
        {
            Carrier carrier = new Carrier();

            carrier.Name            = "WindsorCarrier2";
            carrier.DepotCity       = City.Windsor;
            carrier.LtlAvailability = 10;
            carrier.FtlAvailability = 22;

            TmsDal dal = new TmsDal();

            bool excepted = false;

            // Insert carrier
            try
            {
                carrier = dal.CreateCarrier(carrier);
            }
            catch (CouldNotInsertException)
            {
                excepted = true;
            }

            // Update values
            carrier.DepotCity = City.London;

            try
            {
                carrier = dal.UpdateCarrier(carrier.CarrierID, carrier);
            }
            catch (CouldNotUpdateException)
            {
                excepted = true;
            }

            Assert.IsFalse(excepted);
        }
        public void TripValid()
        {
            TmsDal      CityData = new TmsDal();
            List <Trip> CityInfo = CityData.GetTrips();

            CitiesData[] CityList = new CitiesData[CityInfo.Count];
            int          indexNum = 0;

            foreach (Trip City in CityInfo)
            {
                CityList[indexNum] = new CitiesData(indexNum, City.Distance, City.TravelTime);
                indexNum++;
            }

            TripLogic TripTest = new TripLogic(0, 0, 3, CityList);

            Assert.AreEqual(TripTest.BillDays, 0);
            Assert.AreEqual(TripTest.distance, 387);

            TripTest = new TripLogic(0, 0, 7, CityList);
            Assert.AreEqual(TripTest.BillDays, 1);
            Assert.AreEqual(TripTest.currentCity, 1);
            Assert.AreEqual(TripTest.distance, 859);
            TripTest.AddTime(CityList); //day 0, in transit
            Assert.AreEqual(TripTest.direction, 1);
            TripTest.AddTime(CityList); //day 1, arrived.
            Assert.AreEqual(TripTest.direction, 0);

            TripTest = new TripLogic(10, 1, 5, CityList);
            Assert.AreEqual(TripTest.BillDays, 1);
            Assert.AreEqual(TripTest.distance, 390);

            TripTest = new TripLogic(10, 5, 1, CityList);
            Assert.AreEqual(TripTest.BillDays, 1);
            Assert.AreEqual(TripTest.distance, 390);
        }
Пример #22
0
        public void TestGetContracts()
        {
            TmsDal dal = new TmsDal();

            dal.GetContracts();
        }