public void TransferToBiggerBatteriesPossible()
        {
            Storages = new Storages
            {
                { newStorage(200, 100), 1 },
                { newStorage(5000, 100) }
            };

            Update(0);
            Update(1);

            Assert.IsTrue(Power(0) < 100); //transferred
            Assert.IsTrue(Power(1) > 100); //received something
        }
        public void PowerGetsTransferredEventually()
        {
            Storages = new Storages
            {
                { newStorage(1500, 1500) },
                { newStorage(200, 200 - ToPerTickRate(PPS)), 0, 2 },
                { newStorage(1500, 1500) }
            };

            for (int i = 0; i < 10000; ++i)
            {
                Update();
                AssertClose(3200 - ToPerTickRate(PPS), Power(0) + Power(1) + Power(2), 2);
            }
        }
        public void DeliverAllThePowerToRegularConsumer()
        {
            Storages = new Storages
            {
                { newStorage(100, 100), 1 },
                { newConsumer(100) }
            };

            for (int i = 0; i < 100 / ToPerTickRate(PPS); ++i)
            {
                Update();
            }
            AssertClose(Power(0), 0);
            AssertClose(Power(1), 100);
        }
        public void TakePowerButWontGiveBack()
        {
            Storages = new Storages
            {
                { newStorage(200, 100), 1 },
                { newStorage(200) }
            };

            Update(0);
            var power0 = Power(0);

            Update(1);

            Assert.IsTrue(Power(0) < 100);     //transferred
            Assert.AreEqual(power0, Power(0)); // didn't receive anything back
            Assert.IsTrue(Power(1) > 0);       //received something
        }
        public void PowerGetsEvenEventually()
        {
            Storages = new Storages
            {
                { newStorage(1500, 0) },
                { newStorage(200, 100), 0, 2 },
                { newStorage(5000, 1300) }
            };

            for (int i = 0; i < 100; ++i)
            {
                Update();
            }

            AssertClose(300, Power(0), 2);
            AssertClose(1000, Power(2), 2);
        }
        public void FeedingOneFillsOther()
        {
            Storages = new Storages
            {
                { newStorage(5000), 1 },
                { newStorage(5000) }
            };

            float delivered = 0f;

            for (int i = 0; i < 260; ++i)
            {
                var storage = Storages.PowerStorages[0];
                var toDeliver = new[] { 100, storage.GetRemainingPowerCapacity() }.Min();
                storage.DeliverPower(toDeliver);
                delivered += toDeliver;
                Update();
            }
            Assert.AreEqual(10000, Power(0) + Power(1));
            AssertClose(Power(0) + Power(1), delivered);
        }