コード例 #1
0
        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!"));
        }
コード例 #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);
        }
コード例 #3
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);
        }
コード例 #4
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);
        }
コード例 #5
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"));
        }
コード例 #6
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);
        }
コード例 #7
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));
        }