// unlimited source connected via 1 pipe to tank public void SourceToPipeTOFillTank() { Source source = new Source("test source"); Pipe pipe = new Pipe("test pipe", 5); // 500 Tank tank = new Tank("test tank", 1500); source.AddConnection(pipe); pipe.AddConnection(tank); Factory fac = new Factory(); fac.AddEquipment(source); fac.AddEquipment(pipe); fac.AddEquipment(tank); Assert.AreEqual(0, tank.Content); Assert.AreEqual(0, pipe.Content); // P500,T0 // P0,T500 fac.BalanceContents(); Assert.AreEqual(0, pipe.Content); // pipe.Volume / EquipmentCst.BalanceFactor); Assert.AreEqual(500, tank.Content); // pipe.Volume / EquipmentCst.BalanceFactor); int count = 0; do { fac.BalanceContents(); count++; } while (tank.Content != tank.Volume); //(pipe.Content !=pipe.Volume); Assert.GreaterOrEqual(tank.Content, tank.Volume); }
public void TwoPipeCloseValveAfterCreation() { // close valve after creation Pipe startPipe = new Pipe("start pipe", 1, 100); Valve valve = new Valve("test valve"); Pipe endPipe = new Pipe("end pipe", 1, 0); Assert.IsTrue(valve.Open); valve.SetClosed(); Assert.IsFalse(valve.Open); startPipe.AddConnection(valve); valve.AddConnection(endPipe); Factory fac = new Factory(); fac.AddEquipment(startPipe); fac.AddEquipment(valve); fac.AddEquipment(endPipe); Assert.AreEqual(100, startPipe.Content); Assert.AreEqual(0, valve.Content); Assert.AreEqual(0, endPipe.Content); fac.BalanceContents(); Assert.AreEqual(100, startPipe.Content); Assert.AreEqual(0, valve.Content); Assert.AreEqual(0, endPipe.Content); }
// factory with pipe 1 : 100 - pipe 2 : 100, tank : empty // no pressure = balance content public void PipesWithoutPressureToFillTank() { const int tankStartContent = 0; Tank tank = new Tank("test tank", 1000, tankStartContent); Pipe pipeStart = new Pipe("pipeStart", 1, 100); Pipe pipeAtTank = new Pipe("pipeAtTank", 1, 100); pipeStart.AddConnection(pipeAtTank); pipeAtTank.AddConnection(tank); Factory facWithTank = new Factory(); facWithTank.AddEquipment(tank); facWithTank.AddEquipment(pipeAtTank); facWithTank.AddEquipment(pipeStart); Assert.AreEqual(tank.Content, tankStartContent); Assert.AreEqual(pipeAtTank.Content, 100); Assert.AreEqual(pipeStart.Content, 100); facWithTank.BalanceContents(); Assert.AreEqual(69, pipeStart.Content); Assert.AreEqual(69, pipeAtTank.Content); Assert.AreEqual(62, tank.Content); }
public void TwoPipeOpenValve() { Pipe startPipe = new Pipe("start pipe", 1, 100); Valve valve = new Valve("test valve"); Pipe endPipe = new Pipe("end pipe", 1, 0); Assert.IsTrue(valve.Open); startPipe.AddConnection(valve); valve.AddConnection(endPipe); Factory fac = new Factory(); fac.AddEquipment(startPipe); fac.AddEquipment(valve); fac.AddEquipment(endPipe); Assert.AreEqual(100, startPipe.Content); Assert.AreEqual(0, valve.Content); Assert.AreEqual(0, endPipe.Content); fac.BalanceContents(); Assert.AreEqual(50, startPipe.Content); Assert.AreEqual(25, valve.Content); Assert.AreEqual(25, endPipe.Content); }
// factory with one tank - pipe 1 - pipe 2 -pipe 3 public void TankTo3pipes() { const int tankStartContent = 800; Tank tank = new Tank("test tank", 1000, tankStartContent); Pipe pipeAtTank = new Pipe("pipeAtTank", 1); Pipe pipeMiddle = new Pipe("pipeMiddle", 1); Pipe pipeEnd = new Pipe("pipeEnd", 1); pipeAtTank.AddConnection(tank); pipeAtTank.AddConnection(pipeMiddle); pipeMiddle.AddConnection(pipeEnd); Factory facWithTank = new Factory(); facWithTank.AddEquipment(tank); facWithTank.AddEquipment(pipeAtTank); facWithTank.AddEquipment(pipeMiddle); facWithTank.AddEquipment(pipeEnd); Assert.AreEqual(tank.Content, tankStartContent); Assert.AreEqual(0, pipeAtTank.Content); Assert.AreEqual(0, pipeMiddle.Content); Assert.AreEqual(0, pipeEnd.Content); facWithTank.BalanceContents(); // 700,50,25,25 Assert.AreEqual(tankStartContent - pipeAtTank.Volume, tank.Content); Assert.AreEqual(pipeAtTank.Volume / EquipmentCst.BalanceFactor, pipeAtTank.Content); Assert.AreEqual(pipeMiddle.Volume / (EquipmentCst.BalanceFactor * 2), pipeMiddle.Content); Assert.AreEqual(pipeEnd.Volume / (EquipmentCst.BalanceFactor * 2), pipeEnd.Content); int count = 0; do { facWithTank.BalanceContents(); count++; } while (pipeAtTank.Content != pipeAtTank.Volume); Assert.AreEqual(tankStartContent - pipeAtTank.Volume * 3, tank.Content); Assert.AreEqual(pipeAtTank.Volume, pipeAtTank.Content); Assert.AreEqual(pipeMiddle.Volume, pipeMiddle.Content); Assert.AreEqual(pipeMiddle.Volume, pipeEnd.Content); }
private void PipesTestSetup() { Pipe pipe1 = new Pipe(Pipe1Name, 1); Pipe pipe2 = new Pipe(Pipe2Name, 1); Pipe pipe3 = new Pipe(Pipe3Name, 1); pipe1.AddConnection(pipe2); pipe2.AddConnection(pipe3); factory = new Factory(); factory.AddEquipment(pipe1); factory.AddEquipment(pipe2); factory.AddEquipment(pipe3); }
public void AddFromConnectedPipe() { Pipe pipeOne = new Pipe("testPipe IN", 1, 70); Assert.AreEqual(pipeOne.Content, 70); Pipe pipeTest = new Pipe("testPipe test", 1); pipeTest.AddConnection(pipeOne); pipeTest.BalanceConnections(); Assert.AreEqual(pipeOne.Content, 35); Assert.AreEqual(pipeTest.Content, 35); }
public void SendToConnectedPipe() { Pipe pipeOne = new Pipe("testPipe IN", 1, 10); Assert.AreEqual(pipeOne.Content, 10); Pipe pipeTest = new Pipe("testPipe test", 1, 80); Assert.AreEqual(pipeTest.Content, 80); pipeTest.AddConnection(pipeOne); pipeTest.BalanceConnections(); Assert.AreEqual(pipeOne.Content, 45); Assert.AreEqual(pipeTest.Content, 45); }
public void FromGreaterPipeDontOverFill() { Pipe pipeOne = new Pipe("Greater pipe 300", 3, 300); Assert.AreEqual(300, pipeOne.Content); Assert.AreEqual(pipeOne.Mark, 3); Pipe pipeTest = new Pipe("normal pipe 100", 1); Assert.AreEqual(0, pipeTest.Content); pipeTest.AddConnection(pipeOne); pipeTest.BalanceConnections(); Assert.AreEqual(200, pipeOne.Content); Assert.AreEqual(100, pipeTest.Content); }
public void FromGreaterPipe() { Pipe pipeOne = new Pipe("testPipe IN", 2, 150); Assert.AreEqual(150, pipeOne.Content); Assert.AreEqual(2, pipeOne.Mark); Pipe pipeTest = new Pipe("testPipe test", 1); Assert.AreEqual(0, pipeTest.Content); pipeTest.AddConnection(pipeOne); pipeTest.BalanceConnections(); Assert.AreEqual(75, pipeOne.Content); Assert.AreEqual(75, pipeTest.Content); }