public void should_get_error_message_when_manager_is_full()
        {
            //Given
            var bagKeepers = new List<IBagKeeper>();
            IBagKeeper lockerForManager = new Locker(1);
            lockerListForRobot = new List<IBagKeeper>();
            lockerListForRobot.Add(new Locker(1));
            var lockerListForSmartRobot = new List<IBagKeeper>();
            lockerListForSmartRobot.Add(new Locker(1));
            var lockerListForSuperRobot = new List<IBagKeeper>();
            lockerListForSuperRobot.Add(new Locker(1));
            robot = new Robot(lockerListForRobot);
            var smartRobot = new SmartRobot(lockerListForSmartRobot);
            var superRobot = new SuperRobot(lockerListForSuperRobot);

            bagKeepers.Add(smartRobot);
            bagKeepers.Add(superRobot);
            bagKeepers.Add(lockerForManager);
            bagKeepers.Add(robot);
            manager = new Manager(bagKeepers);

            //When
            for (int i = 0; i < 4; i++)
            {
                manager.Store(new Bag());
            }

            //Then
            var ex = Assert.Throws<ArgumentException>(() => manager.Store(new Bag()));
            Assert.That(ex.Message, Is.EqualTo("The manager is full!"));
        }
Ejemplo n.º 2
0
        public void should_get_a_ticket_when_robot_fisrt_store_a_bag_in_locker()
        {
            var robot = new Robot(lockers);
            var bag = new Bag();
            Ticket ticket = robot.Store(bag);

            Assert.NotNull(ticket);
        }
Ejemplo n.º 3
0
        public void should_pick_bag_which_we_stroed_in()
        {
            var robot = new Robot(lockers);
            var bagStore = new Bag();

            Ticket ticket = robot.Store(bagStore);

            var bagPick = robot.Pick(ticket);

            Assert.AreSame(bagPick, bagStore);
        }
        public void should_return_error_message_when_lockers_are_full()
        {
            var lockerSize = 10;
            var robot = new Robot(oneLocker);

            for (int i = 0; i < lockerSize; i++)
            {
                robot.Store(new Bag());
            }
            var anotherBag = new Bag();

            var ex = Assert.Throws<ArgumentException>(() => robot.Store(anotherBag));
            Assert.That(ex.Message, Is.EqualTo("The lockers are full!"));
        }
Ejemplo n.º 5
0
        public void should_circle_pick_and_store()
        {
            var robot = new Robot(oneLocker);
            for (int i = 0; i <= oneLocker.Count; i++)
            {
                robot.Store(new Bag());
            }

            var firstBag = new Bag();
            var secondBag = new Bag();

            var firstTicket = robot.Store(firstBag);
            robot.Pick(firstTicket);

            var secondTicket = robot.Store(secondBag);

            Assert.NotNull(secondTicket);
        }
Ejemplo n.º 6
0
        public void should_return_error_message_when_robot_without_lockers()
        {
            List<IBagKeeper> emptyLockers = new List<IBagKeeper>();
            var bag1 = new Bag();

            var robot = new Robot(emptyLockers);

            var ex = Assert.Throws<ArgumentException>(() => robot.Store(bag1));
            Assert.That(ex.Message, Is.EqualTo("No locker is available"));
        }
Ejemplo n.º 7
0
        public void should_store_bag_in_sequence()
        {
            var lockersWithOneCapcity = new List<IBagKeeper>();
            for (int i = 0; i < LOCKER_COUNT; i++)
            {
                lockersWithOneCapcity.Add(new Locker(1));
            }

            var robot = new Robot(lockersWithOneCapcity);

            lockersWithOneCapcity[0].Store(new Bag());
            lockersWithOneCapcity[2].Store(new Bag());

            robot.Store(new Bag());

            Assert.AreEqual(lockersWithOneCapcity[1].Capacity, 0);
            Assert.AreEqual(lockersWithOneCapcity[3].Capacity, 1);
        }
Ejemplo n.º 8
0
        public void should_return_null_when_pick_bag_with_used_ticket()
        {
            var robot = new Robot(oneLocker);
            var firstBag = new Bag();

            var ticket = robot.Store(firstBag);

            robot.Pick(ticket);

            Assert.Null(robot.Pick(ticket));
        }
        public void should_get_ticket_when_manage_robots_to_store_bag()
        {
            //Given
            lockerListForRobot = new List<IBagKeeper>();
            lockerListForRobot.Add(locker);

            robot = new Robot(lockerListForRobot);
            robotList = new List<IBagKeeper>();
            robotList.Add(robot);

            manager = new Manager(robotList);

            //When
            var ticket = manager.Store(bag);

            //Then
            Assert.AreSame(bag, robot.Pick(ticket));
        }
Ejemplo n.º 10
0
        public void should_manage_robots_and_lockers_to_store_bag()
        {
            //Given
            var bagKeepers = new List<IBagKeeper>();
            locker = new Locker(1);
            IBagKeeper lockerForManager = new Locker(1);
            lockerListForRobot = new List<IBagKeeper>();
            lockerListForRobot.Add(locker);
            robot = new Robot(lockerListForRobot);
            bagKeepers.Add(lockerForManager);
            bagKeepers.Add(robot);
            manager = new Manager(bagKeepers);

            //When
            Ticket ticket = manager.Store(bag);
            Ticket ticket2 = manager.Store(bag2);

            //Then
            Assert.NotNull(ticket);
            Assert.NotNull(ticket2);
            Assert.AreSame(bag, manager.Pick(ticket));
            Assert.AreSame(bag2, manager.Pick(ticket2));
        }