public void TestValidateBooking1()
        {
            IDStation dbStation = new DStation();
            IDBatteryType dbType = new DBatteryType();
            IDBBatteryStorage dbStorage = new DBBatteryStorage();
            IDPeriod dbPeriod = new DBPeriod();
            int sid = dbStation.addNewRecord("name", "address", "country", "state");
            int btid = dbType.addNewRecord("name", "producer", 10, 10);
            int bsid = dbStorage.addNewRecord(btid, sid, 10);
            MBatteryStorage storage = dbStorage.getRecord(bsid, true);
            try
            {

                MPeriod firstPeriod = new MPeriod();
                firstPeriod.bookedBatteryNumber = 6;
                firstPeriod.initBatteryNumber = 10;
                firstPeriod.time = DateTime.Today;
                dbPeriod.addNewRecord(bsid, firstPeriod.time, firstPeriod.initBatteryNumber, firstPeriod.bookedBatteryNumber);
                storage.periods.Add(firstPeriod);
                MPeriod testPeriod = new MPeriod();
                testPeriod.time = DateTime.Today.AddHours(10);
                testPeriod.initBatteryNumber = 10;
                testPeriod.bookedBatteryNumber = 4;
                dbPeriod.addNewRecord(bsid, testPeriod.time, testPeriod.initBatteryNumber, testPeriod.bookedBatteryNumber);
                storage.periods.Add(testPeriod);
                MPeriod lastPeriod = new MPeriod();
                lastPeriod.time = DateTime.Today.AddHours(20);
                lastPeriod.initBatteryNumber = 10;
                lastPeriod.bookedBatteryNumber = 5;
                dbPeriod.addNewRecord(bsid, lastPeriod.time, lastPeriod.initBatteryNumber, lastPeriod.bookedBatteryNumber);
                storage.periods.Add(lastPeriod);
                BatteryStorageCtr storageCtr = new BatteryStorageCtr();
                if (storageCtr.validateBookingForStation(sid, btid, 1, DateTime.Today.AddHours(10)))
                {
                    Assert.AreEqual(2, 1);
                }
                else
                {
                    Assert.AreEqual(1, 1); //it should fail
                }
                if (storageCtr.validateUpdateBookingForStation(sid, btid, 1, DateTime.Today.AddHours(10)))
                {
                    Assert.AreEqual(2, 1);
                }
                else
                {
                    Assert.AreEqual(1, 1); //it should fail
                }
            }
            finally
            {
                foreach (MPeriod p in storage.periods)
                {
                    dbPeriod.deleteRecord(bsid, p.time);
                }
                dbStorage.deleteRecord(bsid);
                dbType.deleteRecord(btid);
                dbStation.deleteRecord(sid);
            }
        }
Exemple #2
0
 public int addNewStorage(int btID, int sID, int storageNumber)
 {
     BatteryStorageCtr sCtr = new BatteryStorageCtr();
     return sCtr.addNewRecord(btID, sID, storageNumber);
 }
Exemple #3
0
 public void updateStorage(int id, int btid, int sID, int storageNumber)
 {
     BatteryStorageCtr sCtr = new BatteryStorageCtr();
     sCtr.updateRecord(id, btid, sID, storageNumber);
 }
Exemple #4
0
        public BatteryStorage getStorage(int id)
        {
            BatteryStorageCtr sCtr = new BatteryStorageCtr();
            PeriodCtr pCtr = new PeriodCtr();
            MBatteryStorage storage = sCtr.getRecord(id, true);
            BatteryStorage s = new BatteryStorage();
            if (storage != null)
            {
                s.ID = storage.id;
                s.typeID = storage.type.id;
                s.periods = getStoragePeriods(id);
                s.storageNumber = storage.storageNumber;

            }
            return s;
        }
Exemple #5
0
 public List<BatteryStorage> getStationStorages(int sID)
 {
     BatteryStorageCtr sCtr = new BatteryStorageCtr();
     List<MBatteryStorage> storages = sCtr.getStationStorages(sID);
     List<BatteryStorage> bss = new List<BatteryStorage>();
     foreach (MBatteryStorage storage in storages)
     {
         BatteryStorage bs = new BatteryStorage();
         bs.ID = storage.id;
         bs.typeID = storage.type.id;
         bs.periods = getStoragePeriods(bs.ID);
         bs.storageNumber = storage.storageNumber;
         bss.Add(bs);
     }
     return bss;
 }
Exemple #6
0
 public List<string> getAllStorageInfo()
 {
     BatteryStorageCtr sCtr = new BatteryStorageCtr();
     return sCtr.getAllInfo();
 }
Exemple #7
0
 public void deleteStorageByType(int btID)
 {
     BatteryStorageCtr bCtr = new BatteryStorageCtr();
     bCtr.deleteRecordByType(btID);
 }
Exemple #8
0
 public void deleteStorage(int id)
 {
     BatteryStorageCtr sCtr = new BatteryStorageCtr();
     sCtr.deleteRecord(id);
 }