コード例 #1
0
        public void TestBodies()
        {
            JObject response = DeserializeJsonResource <JObject>(Resources.edsmBodies);

            List <Body> bodies = fakeEdsmService.ParseStarMapBodiesParallel(response);

            Assert.IsNotNull(bodies);

            // Test our main star and belt
            Body star = bodies.Find(s => s.bodyname == "Shinrarta Dezhra");

            Assert.AreEqual("Shinrarta Dezhra", star.shortname);
            Assert.AreEqual(14923, star.EDSMID);
            Assert.AreEqual("Star", star.bodyType.invariantName);
            Assert.AreEqual("K", star.stellarclass);
            Assert.AreEqual("Shinrarta Dezhra", star.systemname);
            Assert.AreEqual(0, star.distance);
            Assert.IsTrue((bool)star.mainstar);
            Assert.AreEqual(8068, star.age);
            Assert.AreEqual("V", star.luminosityclass);
            Assert.AreEqual(7.129517, (double)star.absolutemagnitude, 0.01);
            Assert.AreEqual(0.648438, (double)star.solarmass, 0.01);
            Assert.AreEqual(0.7666015240833932, (double)star.solarradius, 0.01);
            Assert.AreEqual(4343, (double)star.temperature, 0.01);
            Assert.AreEqual(1847.1559259259259, (double)star.orbitalperiod, 0.01);
            Assert.AreEqual(577.32870032374433, (double)star.semimajoraxis, 0.01);
            Assert.AreEqual(0.018651, (double)star.eccentricity, 0.01);
            Assert.AreEqual(21.11883, (double)star.inclination, 0.01);
            Assert.AreEqual(201.271866, (double)star.periapsis, 0.01);
            Assert.AreEqual(3.3057685908564816, (double)star.rotationalperiod, 0.01);
            Assert.AreEqual(false, star.tidallylocked);
            Assert.AreEqual(-0.041915, (double)star.tilt, 0.01);
            Assert.AreEqual(1, star.rings?.Count);
            Assert.AreEqual("Rocky", star.rings[0].invariantComposition);
            Assert.AreEqual(1522275140, star.updatedat);
            Assert.IsNull(star.scanned);
            Assert.IsNull(star.mapped);

            // Test value estimation
            Assert.AreEqual(0, star.estimatedvalue);
            star.scanned = System.DateTime.UtcNow;
            Assert.AreEqual(1212, star.estimatedvalue);

            // Test landable high metal content world
            Body body = bodies.Find(s => s.bodyname == "Shinrarta Dezhra A 1");

            Assert.AreEqual("A 1", body.shortname);
            Assert.AreEqual(7058, body.EDSMID);
            Assert.AreEqual("Planet", body.bodyType.invariantName);
            Assert.AreEqual("High metal content world", body.planetClass.invariantName);
            Assert.AreEqual(40.472694, (double)body.distance, 0.01);
            Assert.IsTrue((bool)body.landable);
            Assert.AreEqual(0.9955175545631726, (double)body.gravity, 0.01);
            Assert.AreEqual(0.777331, (double)body.earthmass, 0.01);
            Assert.AreEqual(5635.897, (double)body.radius, 0.01);
            Assert.AreEqual(581, body.temperature);
            Assert.IsNull(body.pressure);
            Assert.IsNull(body.volcanism);
            Assert.AreEqual("No atmosphere", body.atmosphereclass.invariantName);
            Assert.AreEqual(0, body.atmospherecompositions.Count);
            Assert.AreEqual("Rock", body.solidcompositions[0].invariantName);
            Assert.AreEqual(66.83109999999999, (double)body.solidcompositions[0].percent, 0.01);
            Assert.AreEqual("Metal", body.solidcompositions[1].invariantName);
            Assert.AreEqual(33.1689, (double)body.solidcompositions[1].percent, 0.01);
            Assert.AreEqual("Not terraformable", body.terraformState.invariantName);
            Assert.AreEqual(10.463153935185185, (double)body.orbitalperiod, 0.01);
            Assert.AreEqual(40.439289663517812, (double)body.semimajoraxis, 0.01);
            Assert.AreEqual(0.002692, (double)body.eccentricity, 0.01);
            Assert.AreEqual(-0.044359, (double)body.inclination, 0.01);
            Assert.AreEqual(115.330589, (double)body.periapsis, 0.01);
            Assert.AreEqual(10.341365740740741, (double)body.rotationalperiod, 0.01);
            Assert.IsTrue((bool)body.tidallylocked);
            Assert.AreEqual(0.271899, (double)body.tilt, 0.01);
            Assert.AreEqual(11, body.materials.Count);
            Assert.AreEqual("Manganese", body.materials[4].name);
            Assert.AreEqual(9.57628, (double)body.materials[4].percentage, 0.01);
            Assert.AreEqual("Arsenic", body.materials[7].name);
            Assert.AreEqual(2.16406, (double)body.materials[7].percentage, 0.01);
            Assert.AreEqual(1539922044, body.updatedat);
            Assert.IsNull(body.scanned);
            Assert.IsNull(body.mapped);

            // Test value estimation
            Assert.AreEqual(0, body.estimatedvalue);
            body.scanned = System.DateTime.UtcNow;
            Assert.AreEqual(14849, body.estimatedvalue);
            body.mapped = System.DateTime.UtcNow;
            Assert.AreEqual(49497, body.estimatedvalue);

            // Test terraformed body
            body = bodies.Find(s => s.bodyname == "Founders World");
            Assert.AreEqual("Founders World", body.shortname);
            Assert.AreEqual(12765, body.EDSMID);
            Assert.AreEqual("Planet", body.bodyType.invariantName);
            Assert.AreEqual("Earth-like world", body.planetClass.invariantName);
            Assert.AreEqual(324.465424, (double)body.distance, 0.01);
            Assert.AreEqual(false, body.landable);
            Assert.AreEqual(0.9327034079798093, (double)body.gravity, 0.01);
            Assert.AreEqual(0.69, (double)body.earthmass, 0.01);
            Assert.AreEqual(5485.766, (double)body.radius, 0.01);
            Assert.AreEqual(298, body.temperature);
            Assert.AreEqual(2.3013969590426844, (double)body.pressure, 0.01);
            Assert.IsNull(body.volcanism);
            Assert.AreEqual("Suitable for water-based life", body.atmosphereclass.invariantName);
            Assert.AreEqual(2, body.atmospherecompositions.Count);
            Assert.AreEqual("Nitrogen", body.atmospherecompositions[0].invariantName);
            Assert.AreEqual(91.2489, (double)body.atmospherecompositions[0].percent, 0.01);
            Assert.AreEqual("Oxygen", body.atmospherecompositions[1].invariantName);
            Assert.AreEqual(8.69037, (double)body.atmospherecompositions[1].percent, 0.01);
            Assert.AreEqual("Rock", body.solidcompositions[0].invariantName);
            Assert.AreEqual(70, (double)body.solidcompositions[0].percent, 0.01);
            Assert.AreEqual("Metal", body.solidcompositions[1].invariantName);
            Assert.AreEqual(30, (double)body.solidcompositions[1].percent, 0.01);
            Assert.AreEqual("Terraformed", body.terraformState.invariantName);
            Assert.AreEqual(248.72930555555556, (double)body.orbitalperiod, 0.01);
            Assert.AreEqual(334.33343980921632, (double)body.semimajoraxis, 0.01);
            Assert.AreEqual(0.034386, (double)body.eccentricity, 0.01);
            Assert.AreEqual(8.552103, (double)body.inclination, 0.01);
            Assert.AreEqual(183.237366, (double)body.periapsis, 0.01);
            Assert.AreEqual(41.96157696759259, (double)body.rotationalperiod, 0.01);
            Assert.AreEqual(false, body.tidallylocked);
            Assert.AreEqual(0.373026, (double)body.tilt, 0.01);
            Assert.AreEqual(0, body.materials.Count);
            Assert.AreEqual(1539922044, body.updatedat);
            Assert.IsNull(body.scanned);
            Assert.IsNull(body.mapped);

            // Test value estimation
            Assert.AreEqual(0, body.estimatedvalue);
            body.scanned = System.DateTime.UtcNow;
            Assert.AreEqual(276297, body.estimatedvalue);
            body.mapped = System.DateTime.UtcNow;
            Assert.AreEqual(920990, body.estimatedvalue);

            // Test volcanic icy body
            body = bodies.Find(s => s.bodyname == "Shinrarta Dezhra AB 1 b");
            Assert.AreEqual("AB 1 b", body.shortname);
            Assert.AreEqual(8138660, body.EDSMID);
            Assert.AreEqual("Moon", body.bodyType.invariantName);
            Assert.AreEqual("Icy body", body.planetClass.invariantName);
            Assert.AreEqual(3250.803223, (double)body.distance, 0.01);
            Assert.AreEqual(false, body.landable);
            Assert.AreEqual(0.08637144960988087, (double)body.gravity, 0.01);
            Assert.AreEqual(0.004357, (double)body.earthmass, 0.01);
            Assert.AreEqual(1432.49525, (double)body.radius, 0.01);
            Assert.AreEqual(124, body.temperature);
            Assert.AreEqual(0.3520057673328399, (double)body.pressure, 0.01);
            Assert.IsNotNull(body.volcanism);
            Assert.AreEqual("Minor", body.volcanism.invariantAmount);
            Assert.AreEqual("Nitrogen", body.volcanism.invariantComposition);
            Assert.AreEqual("Magma", body.volcanism.invariantType);
            Assert.AreEqual("Methane", body.atmosphereclass.invariantName);
            Assert.AreEqual(1, body.atmospherecompositions.Count);
            Assert.AreEqual("Ice", body.solidcompositions[0].invariantName);
            Assert.AreEqual(81.6586, (double)body.solidcompositions[0].percent, 0.01);
            Assert.AreEqual("Rock", body.solidcompositions[1].invariantName);
            Assert.AreEqual(16.653200000000002, (double)body.solidcompositions[1].percent, 0.01);
            Assert.AreEqual("Metal", body.solidcompositions[2].invariantName);
            Assert.AreEqual(1.6882000000000001, (double)body.solidcompositions[2].percent, 0.01);
            Assert.AreEqual("Not terraformable", body.terraformState.invariantName);
            Assert.AreEqual(7.854005353009259, (double)body.orbitalperiod, 0.01);
            Assert.AreEqual(4.9088274262056295, (double)body.semimajoraxis, 0.01);
            Assert.AreEqual(0.000164, (double)body.eccentricity, 0.01);
            Assert.AreEqual(0.025755, (double)body.inclination, 0.01);
            Assert.AreEqual(300.792816, (double)body.periapsis, 0.01);
            Assert.AreEqual(7.854289641203704, (double)body.rotationalperiod, 0.01);
            Assert.IsTrue((bool)body.tidallylocked);
            Assert.AreEqual(-0.287234, (double)body.tilt, 0.01);
            Assert.AreEqual(0, body.materials.Count);
            Assert.AreEqual(1539922044, body.updatedat);
            Assert.IsNull(body.scanned);
            Assert.IsNull(body.mapped);

            // Test value estimation
            Assert.AreEqual(0, body.estimatedvalue);
            body.scanned = System.DateTime.UtcNow;
            Assert.AreEqual(500, body.estimatedvalue);
            body.mapped = System.DateTime.UtcNow;
            Assert.AreEqual(1191, body.estimatedvalue);

            // Test ringed gas giant
            body = bodies.Find(s => s.bodyname == "Shinrarta Dezhra AB 2");
            Assert.AreEqual("AB 2", body.shortname);
            Assert.AreEqual(8138626, body.EDSMID);
            Assert.AreEqual("Planet", body.bodyType.invariantName);
            Assert.AreEqual("Class I gas giant", body.planetClass.invariantName);
            Assert.AreEqual(3767.557861, (double)body.distance, 0.01);
            Assert.AreEqual(false, body.landable);
            Assert.AreEqual(3.8552143758323023, (double)body.gravity, 0.01);
            Assert.AreEqual(484.303284, (double)body.earthmass, 0.01);
            Assert.AreEqual(71485.664, (double)body.radius, 0.01);
            Assert.AreEqual(123, body.temperature);
            Assert.IsNull(body.pressure);
            Assert.IsNull(body.volcanism);
            Assert.AreEqual("Gas giant", body.atmosphereclass.invariantName);
            Assert.AreEqual(2, body.atmospherecompositions.Count);
            Assert.AreEqual("Hydrogen", body.atmospherecompositions[0].invariantName);
            Assert.AreEqual(72.8469, (double)body.atmospherecompositions[0].percent, 0.01);
            Assert.AreEqual("Helium", body.atmospherecompositions[1].invariantName);
            Assert.AreEqual(27.1531, (double)body.atmospherecompositions[1].percent, 0.01);
            Assert.AreEqual(0, body.solidcompositions.Count);
            Assert.AreEqual("Not terraformable", body.terraformState.invariantName);
            Assert.AreEqual(7354.8133333333335, (double)body.orbitalperiod, 0.01);
            Assert.AreEqual(3765.2874442358393, (double)body.semimajoraxis, 0.01);
            Assert.AreEqual(0.007439, (double)body.eccentricity, 0.01);
            Assert.AreEqual(-0.406597, (double)body.inclination, 0.01);
            Assert.AreEqual(305.503632, (double)body.periapsis, 0.01);
            Assert.AreEqual(1.1907941804166666, (double)body.rotationalperiod, 0.01);
            Assert.AreEqual(false, body.tidallylocked);
            Assert.AreEqual(0.868699, (double)body.tilt, 0.01);
            Assert.AreEqual(0, body.materials.Count);
            Assert.IsNotNull(body.rings);
            Assert.AreEqual(1, body.rings.Count);
            Assert.AreEqual("Shinrarta Dezhra AB 2 A Ring", body.rings[0].name);
            Assert.AreEqual("Icy", body.rings[0].invariantComposition);
            Assert.AreEqual(239990000000, body.rings[0].mass);
            Assert.AreEqual(130900, body.rings[0].innerradius);
            Assert.AreEqual(273390, body.rings[0].outerradius);
            Assert.AreEqual("Common", body.reserveLevel.invariantName);
            Assert.AreEqual(1539922044, body.updatedat);
            Assert.IsNull(body.scanned);
            Assert.IsNull(body.mapped);

            // Test value estimation
            Assert.AreEqual(0, body.estimatedvalue);
            body.scanned = System.DateTime.UtcNow;
            Assert.AreEqual(4883, body.estimatedvalue);
            body.mapped = System.DateTime.UtcNow;
            Assert.AreEqual(16278, body.estimatedvalue);
        }