public void ShouldShowErrorMessageWhenNoBoxAvailableInAnyCabinet() { var cabinet = new Cabinet(1); var cabinets = new List<Cabinet> {cabinet}; cabinet.Store(new Bag()); var robot = new Robot(cabinets, new SequentialSelector(cabinets)); robot.Store(new Bag()); }
public void ShouldPickBagSuccessfullyBySuperRobot() { var cabinet1 = new Cabinet(1); var cabinet2 = new Cabinet(2); var cabinets = new List<Cabinet> { cabinet1, cabinet2 }; var superRobot = new Robot(cabinets, new HighestVacancyRateSelector(cabinets)); var bag = new Bag(); var ticket = superRobot.Store(bag); var pickedBag = superRobot.Pick(ticket); Assert.AreSame(bag, pickedBag); }
public void ShouldStoreBagByAnyRobot() { var cabinet = new Cabinet(10); var cabinets1 = new List<Cabinet> {cabinet}; var robot = new Robot(cabinets1, new SequentialSelector(cabinets1)); var manager = new Manager(new List<IStoreable> {robot}); var storedBag = new Bag(); var ticket = manager.Store(storedBag); Assert.AreEqual(9, cabinet.AvailableBoxes()); Assert.AreSame(storedBag, manager.Pick(ticket)); }
public void ShouldStoreBagInTheSecondAvailableCabinetIfFirstIsFull() { var cabinet1 = new Cabinet(1); cabinet1.Store(new Bag()); var cabinet2 = new Cabinet(1); var cabinets = new List<Cabinet> {cabinet1, cabinet2}; var robot = new Robot(cabinets, new SequentialSelector(cabinets)); var ticket = robot.Store(new Bag()); Assert.IsNotNull(ticket); Assert.AreEqual(0, cabinet2.AvailableBoxes()); }
public void ShouldPickBagSuccessfullyByRobot() { var cabinet1 = new Cabinet(1); cabinet1.Store(new Bag()); var cabinet2 = new Cabinet(1); var cabinets = new List<Cabinet> {cabinet1, cabinet2}; var robot = new Robot(cabinets, new SequentialSelector(cabinets)); var bag = new Bag(); var ticket = robot.Store(bag); var pickedBag = robot.Pick(ticket); Assert.AreSame(bag, pickedBag); }
public void ShouldStoreBagToCabinetWithHighestVacancyRate() { var cabinet1 = new Cabinet(2); cabinet1.Store(new Bag()); var cabinet2 = new Cabinet(5); cabinet2.Store(new Bag()); cabinet2.Store(new Bag()); cabinet2.Store(new Bag()); var cabinets = new List<Cabinet> { cabinet1, cabinet2 }; var superRobot = new Robot(cabinets, new HighestVacancyRateSelector(cabinets)); superRobot.Store(new Bag()); Assert.AreEqual(0, cabinet1.AvailableBoxes()); Assert.AreEqual(2, cabinet2.AvailableBoxes()); }
public void ShouldGetFormattedAvailbeBoxesMessagesForAllCabinets() { var cabinet1 = new Cabinet(1); cabinet1.Store(new Bag()); var cabinet2 = new Cabinet(1); var cabinets = new List<Cabinet> { cabinet1, cabinet2 }; var robot = new Robot(cabinets, new HighestVacancyRateSelector(cabinets)); robot.Store(new Bag()); var message = robot.ReportEmptyBox(new EmptyBoxReporter()); Assert.AreEqual(message, string.Format("SuperRobot{0}\n Cabinet{1}:{2}\n Cabinet{3}:{4}\n", robot.GetHashCode(), cabinet1.GetHashCode(), cabinet1.AvailableBoxes(), cabinet2.GetHashCode(), cabinet2.AvailableBoxes() )); }
public void ShouldManageMutipleRobots() { var cabinet1 = new Cabinet(10); var cabinets1 = new List<Cabinet> {cabinet1}; var robot = new Robot(cabinets1, new SequentialSelector(cabinets1)); var cabinet2 = new Cabinet(5); var cabinets2 = new List<Cabinet> {cabinet2}; var smartRobot = new Robot(cabinets2, new MostAvailableSelector(cabinets2)); var cabinet3 = new Cabinet(4); var cabinets3 = new List<Cabinet> {cabinet3}; var superRobot = new Robot(cabinets3, new HighestVacancyRateSelector(cabinets3)); var manager = new Manager(new List<IStoreable> {robot, smartRobot, superRobot}); manager.Store(new Bag()); Assert.AreEqual(9, cabinet1.AvailableBoxes()); }
public void ShouldGetFormattedAvailbeBoxesMessagesFromAllManagedCabinets() { var cabinet1 = new Cabinet(10); var cabinets1 = new List<Cabinet> {cabinet1}; var robot = new Robot(cabinets1, new SequentialSelector(cabinets1)); var cabinet2 = new Cabinet(2); var manager = new Manager(new List<IStoreable> {robot, cabinet2}); manager.Store(new Bag()); var message = manager.ReportEmptyBox(new EmptyBoxReporter()); Assert.AreEqual(string.Format("Manager{0}\n" + " Robot{1}\n" + " Cabinet{2}:{3}\n"+ " Cabinet{4}:{5}\n", manager.GetHashCode(), robot.GetHashCode(), cabinet1.GetHashCode(), cabinet1.AvailableBoxes(), cabinet2.GetHashCode(), cabinet2.AvailableBoxes() ), message); }
public void ShouldTellWhetherCanStoreBox() { var cabinet = new Cabinet(1); var cabinets = new List<Cabinet> {cabinet}; var robot = new Robot(cabinets, new SequentialSelector(cabinets)); var canStore = robot.CanStore(); Assert.IsTrue(canStore); }
public void ShouldStoreBagSuccessfullyInFirstAvailableBox() { var cabinet1 = new Cabinet(1); var cabinet2 = new Cabinet(1); var cabinets = new List<Cabinet> {cabinet1, cabinet2}; var robot = new Robot(cabinets, new SequentialSelector(cabinets)); var ticket = robot.Store(new Bag()); Assert.IsNotNull(ticket); Assert.AreEqual(0, cabinet1.AvailableBoxes()); }