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!")); }
public void should_get_a_ticket_when_store_a_bag() { SmartRobot smartRobot = new SmartRobot(oneLocker); Bag bag = new Bag(); Ticket ticket = smartRobot.Store(bag); Assert.NotNull(ticket); }
public void should_return_error_message_when_robot_without_lockers() { List<IBagKeeper> emptyLockers = new List<IBagKeeper>(); var bag1 = new Bag(); var smartRobot = new SmartRobot(emptyLockers); var ex = Assert.Throws<ArgumentException>(() => smartRobot.Store(bag1)); Assert.That(ex.Message, Is.EqualTo("No locker is available")); }
public void should_store_bag_in_the_locker_which_has_largest_number_of_empty_boxes() { var bag1 = new Bag(); var bag2 = new Bag(); var bag3 = new Bag(); var bag4 = new Bag(); lockers[0].Store(bag1); lockers[1].Store(bag2); lockers[3].Store(bag3); var smartRobot = new SmartRobot(lockers); var ticket4 = smartRobot.Store(bag4); Assert.Null(lockers[0].Pick(ticket4)); Assert.Null(lockers[1].Pick(ticket4)); Assert.Null(lockers[3].Pick(ticket4)); Assert.AreSame(bag4, lockers[2].Pick(ticket4)); }