def setUp(self): self.builder = BoxGroupBuilder() self.boxGroup = self.builder.withA(2).withB(4).withC(2).build() self.packMachine = PackMachine("PCK0") self.packMachine.add(self.boxGroup) self.pack = Pack("1", PackSize.A) self.transport = Transport("TR1", self.pack, "PCK1")
def setUp(self): self.visitor = MachineFreeSpaceVisitor() self.packMachine = PackMachine("PCK0") self.builder = BoxGroupBuilder() boxGroup = self.builder.withA(2).withB(4).withC(2).build() self.packMachine.add(boxGroup) self.pack = Pack("1", PackSize.B)
class SendPackOperationTest(unittest.TestCase): def setUp(self): self.builder = BoxGroupBuilder() self.boxGroup = self.builder.withA(2).withB(4).withC(2).build() self.packMachine = PackMachine("PCK0") self.packMachine.add(self.boxGroup) self.pack = Pack("1", PackSize.A) self.transport = Transport("TR1", self.pack, "PCK1") @unittest.skip def testShouldPutPackIntoMachineUsingTransport(self): # given self.assertPackMachineEmpty() operation = SendPackOperation(self.transport, self.packMachine) # when operation.execute() # then self.assertEqual("PCK0", self.transport.place) self.assertPackMachineWithOneOccupiedBox() def assertPackMachineWithOneOccupiedBox(self): self.visitor = MachineFreeSpaceVisitor() self.packMachine.accept(self.visitor) self.assertEqual(1, self.visitor.quantities[PackSize.A]) self.assertEqual(4, self.visitor.quantities[PackSize.B]) self.assertEqual(2, self.visitor.quantities[PackSize.C]) def assertPackMachineEmpty(self): self.visitor = MachineFreeSpaceVisitor() self.packMachine.accept(self.visitor) self.assertEqual(2, self.visitor.quantities[PackSize.A]) self.assertEqual(4, self.visitor.quantities[PackSize.B]) self.assertEqual(2, self.visitor.quantities[PackSize.C])
class BoxGroupBuilderTest(unittest.TestCase): def setUp(self): self.builder = BoxGroupBuilder() def testBuilder(self): # when boxGroup = self.builder.withA(2).withB(4).withC(2).build() # then self.assertEqual(8, len(boxGroup.boxes)) self.assertEqual(PackSize.A, boxGroup.boxes[0].size) self.assertEqual(PackSize.B, boxGroup.boxes[2].size) self.assertEqual(PackSize.C, boxGroup.boxes[6].size)
class PackMachineTest(unittest.TestCase): def setUp(self): self.builder = BoxGroupBuilder() self.boxGroup = self.builder.withA(2).withB(4).withC(2).build() self.packMachine = PackMachine("PCK0") self.packMachine.add(self.boxGroup) def testShouldAddPackToFirstBox(self): # given self.pack = Pack("1", PackSize.A) # when self.packMachine.put(self.pack) # then self.assertFalse(self.boxGroup.boxes[0].isEmpty())
class VisitorTest(unittest.TestCase): def setUp(self): self.visitor = MachineFreeSpaceVisitor() self.packMachine = PackMachine("PCK0") self.builder = BoxGroupBuilder() boxGroup = self.builder.withA(2).withB(4).withC(2).build() self.packMachine.add(boxGroup) self.pack = Pack("1", PackSize.B) @unittest.skip def testShouldCountWithVisitor(self): # given self.packMachine.put(self.pack) # when self.packMachine.accept(self.visitor) # then self.assertEqual(2, self.visitor.quantities[PackSize.A]) self.assertEqual(3, self.visitor.quantities[PackSize.B]) self.assertEqual(2, self.visitor.quantities[PackSize.C])
def setUp(self): self.builder = BoxGroupBuilder()
def setUp(self): self.builder = BoxGroupBuilder() self.boxGroup = self.builder.withA(2).withB(4).withC(2).build() self.packMachine = PackMachine("PCK0") self.packMachine.add(self.boxGroup)