Exemple #1
0
        public void DetermineIndexOfHighestLoadShould_ReturnBankWithMostBlocks()
        {
            var allocation = new MemoryAllocation(input);
            var highest    = allocation.DetermineIndexOfHighestLoad();

            Assert.Equal(2, highest);

            allocation = new MemoryAllocation(inputTwo);
            highest    = allocation.DetermineIndexOfHighestLoad();

            Assert.Equal(2, highest);
        }
Exemple #2
0
        public void DistributeMemoryShould_DistributeMemoryToOtherBanksAndSaveHistory()
        {
            var allocation = new MemoryAllocation(input);
            var original   = allocation.MemoryBanks;

            var highest       = allocation.DetermineIndexOfHighestLoad();
            var originalValue = allocation.MemoryBanks[highest];

            allocation.DistributeMemory(highest);

            Assert.Single(allocation.MemoryBankHistory);
            Assert.True(originalValue > allocation.MemoryBanks[highest]);
            for (var i = 0; i < allocation.MemoryBanks.Length; i++)
            {
                if (i == highest)
                {
                    continue;
                }

                Assert.True(original[i] < allocation.MemoryBanks[i]);
            }
        }