Beispiel #1
0
        public void ConstructorCreatesProperRobotManager()
        {
            RobotManager robotManager = new RobotManager(10);

            Assert.That(robotManager.Capacity, Is.EqualTo(10));
            Assert.That(robotManager.Count, Is.EqualTo(0));
        }
Beispiel #2
0
        public void RobotManagerAddsProperly()
        {
            Robot        robot        = new Robot("Pesho", 100);
            RobotManager robotManager = new RobotManager(10);

            robotManager.Add(robot);
            Assert.That(robotManager.Count, Is.EqualTo(1));
        }
Beispiel #3
0
        public void ThrowsExceptionOnWorkingWithoutBattery()
        {
            Robot        robot        = new Robot("Pesho", 100);
            RobotManager robotManager = new RobotManager(1);

            robotManager.Add(robot);
            Assert.That(() => robotManager.Work(robot.Name, "d", 200), Throws.InvalidOperationException.With.Message.EqualTo($"{robot.Name} doesn't have enough battery!"));
        }
Beispiel #4
0
        public void RobotManagerRemovesProperly()
        {
            Robot        robot        = new Robot("Pesho", 100);
            RobotManager robotManager = new RobotManager(10);

            robotManager.Add(robot);
            robotManager.Remove(robot.Name);
            Assert.That(robotManager.Count, Is.EqualTo(0));
        }
Beispiel #5
0
        public void ThrowsExceptionOnAddingSameRobot()
        {
            Robot        robot        = new Robot("Pesho", 100);
            RobotManager robotManager = new RobotManager(1);

            robotManager.Add(robot);

            Assert.That(() => robotManager.Add(robot), Throws.InvalidOperationException.With.Message.EqualTo($"There is already a robot with name {robot.Name}!"));
        }
Beispiel #6
0
        public void ThrowsExceptionOnFullManager()
        {
            Robot        robot        = new Robot("Pesho", 100);
            Robot        robotOne     = new Robot("Peshoo", 100);
            RobotManager robotManager = new RobotManager(1);

            robotManager.Add(robot);

            Assert.That(() => robotManager.Add(robotOne), Throws.InvalidOperationException.With.Message.EqualTo("Not enough capacity!"));
        }
Beispiel #7
0
        public void RobotManagerWorksProperly()
        {
            Robot        robot        = new Robot("Pesho", 100);
            RobotManager robotManager = new RobotManager(1);

            robotManager.Add(robot);

            robotManager.Work(robot.Name, "do stuff", 20);

            Assert.That(robot.Battery, Is.EqualTo(80));
        }
Beispiel #8
0
        public void RobotManagerChargesProperly()
        {
            RobotManager robotManager = new RobotManager(1);
            Robot        robot        = new Robot("Pesho", 100);

            robotManager.Add(robot);
            robotManager.Work(robot.Name, "da", 100);

            robotManager.Charge(robot.Name);

            Assert.That(robot.Battery, Is.EqualTo(robot.MaximumBattery));
        }
Beispiel #9
0
        public void ThrowsExceptionOnWorkingNonExistedRobot()
        {
            RobotManager robotManager = new RobotManager(1);

            Assert.That(() => robotManager.Work("d", "d", 2), Throws.InvalidOperationException.With.Message.EqualTo($"Robot with the name d doesn't exist!"));
        }
Beispiel #10
0
        public void RobotManagerThorowsExceptionOnInvalidNameToRemove()
        {
            RobotManager robotManager = new RobotManager(10);

            Assert.That(() => robotManager.Remove("Goso"), Throws.InvalidOperationException.With.Message.EqualTo($"Robot with the name Goso doesn't exist!"));
        }
Beispiel #11
0
        public void ThrowsExceptionOnChargingNullRobot()
        {
            RobotManager robotManager = new RobotManager(1);

            Assert.That(() => robotManager.Charge("d"), Throws.InvalidOperationException.With.Message.EqualTo($"Robot with the name d doesn't exist!"));
        }