예제 #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!"));
        }