Ejemplo n.º 1
0
        public void SolarSystemDeSerialization()
        {
            if (!File.Exists(filename))
            {
                SolarSystemSerialize();
            }

            string json = string.Empty;

            using (StreamReader reader = new StreamReader(filename))
            {
                json = reader.ReadToEnd();
            }

            BaseStellarMap map = JsonConvert.DeserializeObject <BaseStellarMap>(json);
        }
Ejemplo n.º 2
0
        public void SolarSystemDeSerialization()
        {
            if (!File.Exists(filename))
            {
                SolarSystemSerialize();
            }

            DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(BaseStellarMap));
            BaseStellarMap             map = null;

            using (FileStream fs = new FileStream(filename, FileMode.Open))
            {
                object obj = ser.ReadObject(fs);
                map = obj as BaseStellarMap;
            }
        }
Ejemplo n.º 3
0
        public static void StoreSolarSystem()
        {
            IStellarMap map = new BaseStellarMap("SolarSystem");

            PhysicalSolarSystemCreator.CreateSolarSystem(map);

            IMapStorage store = MapStorageFactory.GetStorage(MapStorageFactory.JsonStorage);

            string filename = Path.Combine(dataDir, "SolarSystem.json");

            if (File.Exists(filename))
            {
                File.Delete(filename);
            }

            using StreamWriter writer = new StreamWriter(filename);
            store.Store(map, writer);
        }
        public void SolarSystemDeSerialization()
        {
            if (!File.Exists(filename))
            {
                SolarSystemSerialize();
            }
            else
            {
                HandleInheritance();
            }

            BaseStellarMap map = null;

            using (FileStream fs = new FileStream(filename, FileMode.Open))
            {
                object obj = Serializer.Deserialize <BaseStellarMap>(fs);
                map = obj as BaseStellarMap;
            }
        }
Ejemplo n.º 5
0
        public void LoadCatalogue()
        {
            HabHygCatalogue catalogue = new HabHygCatalogue();

            catalogue.Location = Path.Combine(TestingUtilities.Config["DataPath"], "HabHYG.csv");

            BaseStellarMap map = new BaseStellarMap("HabHyg All");

            catalogue.Get(map);

            map = new BaseStellarMap("HabHyg within 5ly");
            catalogue.GetWithin(map, 5);

            map = new BaseStellarMap("HabHyg within 10ly");
            catalogue.GetWithin(map, 10);

            map = new BaseStellarMap("HabHyg within 15ly");
            catalogue.GetWithin(map, 15);

            map = new BaseStellarMap("HabHyg within 20ly");
            catalogue.GetWithin(map, 20);

            map = new BaseStellarMap("HabHyg within 30ly");
            catalogue.GetWithin(map, 30);

            map = new BaseStellarMap("HabHyg within 40ly");
            catalogue.GetWithin(map, 40);

            map = new BaseStellarMap("HabHyg within 50ly");
            catalogue.GetWithin(map, 50);

            map = new BaseStellarMap("HabHyg within 75ly");
            catalogue.GetWithin(map, 75);

            map = new BaseStellarMap("HabHyg within 100ly");
            catalogue.GetWithin(map, 100);

            map = new BaseStellarMap("HabHyg higher than magnitude 4");
            catalogue.GetMagnitude(map, 4);

            map = new BaseStellarMap("HabHyg within 10ly higher that magnitude 4");
            catalogue.GetWithin(map, 10, 4);
        }
Ejemplo n.º 6
0
        public void PlanetNotEqualMoonNameTest()
        {
            TestStellarMap map   = new TestStellarMap();
            Planet         earth = new Planet("Earth");

            map.Add <Planet>(earth);
            Satellite moon = new Satellite("Moon");

            earth.Add(moon);

            BaseStellarMap map2   = new BaseStellarMap();
            Planet         earth2 = new Planet("Earth");

            map2.Add <Planet>(earth2);
            Satellite moon2 = new Satellite("NotMoon");

            earth2.Add(moon2);

            Assert.IsFalse(PlanetEqualityComparer.Comparer.Equals(earth, earth2));
        }
Ejemplo n.º 7
0
        public void PlanetNotEqualMissingPropertyTest()
        {
            TestStellarMap map   = new TestStellarMap();
            Planet         earth = new Planet("Earth");

            map.Add <Planet>(earth);
            Satellite moon = new Satellite("Moon");

            earth.Add(moon);

            BaseStellarMap map2   = new BaseStellarMap();
            Planet         earth2 = new Planet("Earth");

            map2.Add <Planet>(earth2);
            earth2.BasicProperties.Add("Description", "No signs of intelligent life");
            Satellite moon2 = new Satellite("Moon");

            earth2.Add(moon2);

            Assert.IsFalse(PlanetEqualityComparer.Comparer.Equals(earth, earth2));
        }
Ejemplo n.º 8
0
        public static Star CreateSolSystem()
        {
            BaseStellarMap sm = new BaseStellarMap("SolarSystem");

            Star sol = new Star("Sol");

            sol.BasicProperties.Add(Constants.PropertyNames.StellarClass, "G2V");
            sm.Add(sol);

            sol.Add(new Planet("Mercury"));
            sol.Add(new Planet("Venus"));

            Planet earth = new Planet("Earth")
            {
                Map = sm
            };

            Satellite moon = new Satellite("Moon");

            earth.Add(moon);
            sol.Add(earth);

            sol.Add(new Planet("Mars"));
            sol.Add(new Planet("Jupiter"));
            sol.Add(new Planet("Saturn"));
            sol.Add(new Planet("Uranus"));
            sol.Add(new Planet("Neptune"));
            sol.Add(new Planet("Pluto"));

            sol.Add(new Asteroid("Ceres"));
            sol.Add(new Asteroid("Pallas"));
            sol.Add(new Asteroid("Juno"));

            sol.Add(new Comet("Haley's"));
            sol.Add(new Comet("Caeser's"));

            sol.GetPlanets();

            return(sol);
        }