示例#1
0
        public void AddBatery(Battery bat)
        {
            _battery = bat;

            if(bat == null)
                connected = false;
            else connected = true;
        }
示例#2
0
 public void TestDrillNoSafety()
 {
     Rover myRover = new Rover ();
     Drill myDrill = new Drill ();
     Battery bat1 = new Battery (50);
     myRover.AddBattery (bat1);
     myRover.AttachDevice(myDrill);
     Assert.IsTrue(myDrill.Battery.Charge == 50);
     Assert.IsTrue(myDrill.Connected == true);
     myDrill.Operate ();
     Assert.IsTrue(myDrill.Battery.Charge == 40);
 }
示例#3
0
        public void TestConnect()
        {
            Rover myRover = new Rover();
            Radar myRadar = new Radar();
            myRover.AttachDevice(myRadar);
            Battery bat1 = new Battery (60);
            Assert.IsTrue(myRadar.Connected == false);

            myRover.AddBattery (bat1);
            myRadar.AddBatery (bat1);
            Assert.IsTrue(myRadar.Connected == true);
        }
示例#4
0
        public void TestConnectToHighestCharge()
        {
            Rover myRover = new Rover();
            Radar myRadar = new Radar();
            Battery bat1 = new Battery (50);
            Battery bat2 = new Battery (55);
            Battery bat3 = new Battery (60);
            myRover.AddBattery (bat1);
            myRover.AddBattery (bat2);
            myRover.AddBattery (bat3);

            myRover.AttachDevice(myRadar);

            Assert.IsTrue(myRadar.Battery.Charge == 60);
        }
示例#5
0
        public void TestConnectedOnAttach()
        {
            Rover myRover = new Rover();
            Radar myRadar = new Radar();
            Battery bat1 = new Battery (50);
            Battery bat2 = new Battery (55);
            Battery bat3 = new Battery (60);
            myRover.AddBattery (bat1);
            myRover.AddBattery (bat2);
            myRover.AddBattery (bat3);

            myRover.AttachDevice(myRadar);

            Assert.IsTrue(myRadar.Connected == true);
        }
示例#6
0
        public void TestSolar()
        {
            Rover myRover = new Rover();
            SolarPanel mySolar = new SolarPanel();
            Battery bat1 = new Battery (50);
            myRover.AddBattery (bat1);
            myRover.AttachDevice(mySolar);
            Assert.IsTrue(mySolar.Battery.Charge == 50);
            Assert.IsTrue(mySolar.Connected == true);

            mySolar.Operate ();
            Assert.IsTrue(mySolar.Battery.Charge == 51, mySolar.Battery.Charge.ToString());
        }
示例#7
0
        public void TestRadar()
        {
            Rover myRover = new Rover();
            Radar myRadar = new Radar();
            Battery bat1 = new Battery (50);
            myRover.AddBattery (bat1);
            myRover.AttachDevice(myRadar);
            Assert.IsTrue(myRadar.Battery.Charge == 50);
            Assert.IsTrue(myRadar.Connected == true);

            myRadar.Operate ();
            Assert.IsTrue(myRadar.Battery.Charge == 46);
        }
示例#8
0
 public void RemoveBattery(Battery b)
 {
     _batteries.Remove (b);
 }
示例#9
0
 public void AddBattery(Battery b)
 {
     _batteries.Add (b);
 }