public void ShouldReturnCabinetVacancyReate() { var cabinet = new Cabinet(2); cabinet.Store(new Bag()); Assert.AreEqual(0.5, cabinet.VacancyRate(), 0.001); }
public void ShouldGetBagSuccessfullyGivenUnusedTicked() { var cabinet = new Cabinet(1); var bag = new Bag(); var ticket = cabinet.Store(bag); var actualBag = cabinet.Pick(ticket); Assert.AreSame(bag, actualBag); }
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 ShouldGetFormattedMessageOfAvaialbeBoxes() { var cabinet = new Cabinet(2); var bag = new Bag(); cabinet.Store(bag); var message = cabinet.ReportEmptyBox(new EmptyBoxReporter()); Assert.AreEqual(message, string.Format("Cabinet{0}:{1}\n", cabinet.GetHashCode(), cabinet.AvailableBoxes())); Console.Out.WriteLine(message); }
public void ShouldNotGetBagGivenUsedTicked() { var cabinet = new Cabinet(1); var bag = new Bag(); var ticket = cabinet.Store(bag); var actualBag = cabinet.Pick(ticket); Assert.AreEqual(bag, actualBag); var secondBag = cabinet.Pick(ticket); Assert.IsNull(secondBag); }
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 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()); }
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 ShouldManagerManageOtherMangers() { var cabinet1 = new Cabinet(2); var manager1 = new Manager(new List<IStoreable> {cabinet1}); var manager = new Manager(new List<IStoreable> {manager1}); var storedBag = new Bag(); var ticket = manager.Store(storedBag); Assert.AreEqual(1, cabinet1.AvailableBoxes()); var pickedBag = manager.Pick(ticket); Assert.AreSame(storedBag, pickedBag); }
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 ShouldTellWhetherCanStoreBag() { var cabinet = new Cabinet(1); var canStore = cabinet.CanStore(); Assert.IsTrue(canStore); }
public void ShouldStoreBagSuccessfullyWhenThereIsBoxAvailable() { var cabinet = new Cabinet(1); var ticket =cabinet.Store(new Bag()); Assert.IsNotNull(ticket); }
public void ShouldShowErrorMessageWhenNoBoxAvailableToStoreBag() { var cabinet = new Cabinet(0); cabinet.Store(new Bag()); }
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 ShouldReturnAvailableBoxNumber() { var cabinet = new Cabinet(1); Assert.AreEqual(1, cabinet.AvailableBoxes()); }
public void ShouldStoreBagWithDirectlyByCabinet() { var cabinet = new Cabinet(10); var manager = new Manager(new List<IStoreable> {cabinet}); var storedBag = new Bag(); var ticket = manager.Store(storedBag); Assert.AreEqual(9, cabinet.AvailableBoxes()); var pickedBag = manager.Pick(ticket); Assert.AreSame(storedBag, pickedBag); }