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

            Assert.That(robotManager.Capacity, Is.EqualTo(10));
            Assert.That(robotManager.Count, Is.EqualTo(0));
        }
示例#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));
        }
示例#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!"));
        }
示例#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));
        }
示例#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}!"));
        }
示例#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!"));
        }
示例#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));
        }
示例#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));
        }
示例#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!"));
        }
示例#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!"));
        }
示例#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!"));
        }