Esempio n. 1
0
        public void ConnectTankPipe()
        {
            Tank emptyTank = new Tank("testTank", 123);
            Pipe testPipe  = new Pipe("First", 1);

            emptyTank.AddConnection(testPipe);
            Assert.AreEqual(testPipe, emptyTank.GetConnections()[0]);
            Assert.AreEqual(emptyTank, testPipe.GetConnections()[0]);

            Factory factory = new Factory();

            factory.AddEquipment(testPipe);
            factory.AddEquipment(emptyTank);
        }
Esempio n. 2
0
        // unlimited source direct connected to tank = instant filled
        public void SourceToFillTank()
        {
            Source source = new Source("test source");
            Tank   tank   = new Tank("test tank", 1000);

            source.AddConnection(tank);
            tank.AddConnection(source);

            Factory fac = new Factory();

            fac.AddEquipment(source);
            fac.AddEquipment(tank);

            Assert.AreEqual(tank.Content, 0);

            fac.BalanceContents();
            Assert.AreEqual(tank.Content, tank.Volume);
        }
Esempio n. 3
0
        // connect 2 tanks: tank 1 = 600, pipe = 0 , tank 2 = 300 ==> 400,100,400
        public void Connect2Tanks()
        {
            const int tank1Start = 600;
            const int tank2Start = 300;
            Tank      tank1      = new Tank("tank 600", 1000, tank1Start);
            Pipe      pipe       = new Pipe("pipe", 1);
            Tank      tank2      = new Tank("tank 300", 1000, tank2Start);

            tank1.AddConnection(pipe);
            tank2.AddConnection(pipe);

            Factory fac = new Factory();

            fac.AddEquipment(tank1);
            fac.AddEquipment(pipe);
            fac.AddEquipment(tank2);

            Assert.AreEqual(tank1.Content, tank1Start);
            Assert.AreEqual(pipe.Content, 0);
            Assert.AreEqual(tank2.Content, tank2Start);

            fac.BalanceContents();//500, 0, 400
            Assert.AreEqual(tank1.Content, tank1Start - pipe.Volume);
            Assert.AreEqual(pipe.Content, 0);
            Assert.AreEqual(tank2.Content, tank2Start + pipe.Volume);

            fac.BalanceContents();
            // 400, 100, 400
            Assert.AreEqual(400, tank1.Content);
            Assert.AreEqual(100, pipe.Content);
            Assert.AreEqual(400, tank2.Content);

            fac.BalanceContents();
            // 400, 100, 400
            Assert.AreEqual(400, tank1.Content);
            Assert.AreEqual(100, pipe.Content);
            Assert.AreEqual(400, tank2.Content);

            fac.BalanceContents();
            // 400, 100, 400
            Assert.AreEqual(400, tank1.Content);
            Assert.AreEqual(100, pipe.Content);
            Assert.AreEqual(400, tank2.Content);
        }