Beispiel #1
0
        public void Test_PartOne()
        {
            int numSteps = 1000;
            //< Get them moons
            var moons = GetMoons(PartOneMoons);
            //< Get the helper
            var helper = new MoonHelper(moons);

            helper.Simulate(numSteps);
            //< Get the total energy and check it's correct
            var energies = helper.Moons.Select(moon => moon.CalculateTotalEnergy()).ToList();
            var total    = energies.Sum();

            Assert.IsTrue(total == 8538);
        }
Beispiel #2
0
        public void Test_PartTwo()
        {
            //< Get them moons
            var moons = GetMoons(PartOneMoons);
            //< Get the helper
            var helper = new MoonHelper(moons);
            //< Omae wa mou shindeiru
            var numSteps = helper.GetStepsToRepeat();

            //< NANI???
            Assert.IsTrue(numSteps == 506359021038056);

            //< Some quik mafs - it takes ~12ms for 1000 steps in PartOne
            var secPerStep   = (12.0 / 10E3) / 100.0;
            var simTimeSec   = numSteps * secPerStep;
            var simTimeDays  = simTimeSec / 86400.0;
            var simTimeYears = simTimeDays / 365.0;

            Assert.IsTrue(IsToFuckingMuch(simTimeSec));
        }
Beispiel #3
0
        public void Test_MoonsTwo()
        {
            int numSteps = 100;
            //< Get them moons
            var moons = GetMoons(TestMoonsTwo);
            //< Get the helper
            var helper = new MoonHelper(moons);

            helper.Simulate(numSteps);
            //< Check the results
            for (int i = 0; i < helper.Moons.Count; i++)
            {
                var moon = helper.Moons[i];
                var res  = TestResultsTwo[i];
                Assert.IsTrue(moon.X == res[0] && moon.Y == res[1] && moon.Z == res[2]);
                Assert.IsTrue(moon.Vx == res[3] && moon.Vy == res[4] && moon.Vz == res[5]);
            }
            //< Get the total energy and check it's correct
            var energies = helper.Moons.Select(moon => moon.CalculateTotalEnergy()).ToList();
            var total    = energies.Sum();

            Assert.IsTrue(total == 1940);
        }