Beispiel #1
0
        public void StarNotEqualCatalogueTest()
        {
            TestStellarMap map = new TestStellarMap();
            Star           sol = new Star("Sol");

            map.Add <Star>(sol);
            sol.BasicProperties.Add(Constants.PropertyNames.Designation, "Sol");
            sol.BasicProperties.Add(Constants.PropertyNames.StellarClass, "G2V");
            var catalogue = new Dictionary <string, string>();

            catalogue.Add("HabHyg", "0");
            catalogue.Add("Hip", "0");
            sol.Properties.AddGroup("Catalogue", catalogue);

            TestStellarMap map2 = new TestStellarMap();
            Star           sol2 = new Star("Sol");

            map2.Add <Star>(sol2);
            sol2.BasicProperties.Add(Constants.PropertyNames.Designation, "Sol");
            sol2.BasicProperties.Add(Constants.PropertyNames.StellarClass, "G2V");
            catalogue = new Dictionary <string, string>();
            catalogue.Add("HabHyg", "1");
            catalogue.Add("Hip", "1");
            sol2.Properties.AddGroup("Catalogue", catalogue);

            Assert.IsFalse(StarEqualityComparer.Comparer.Equals(sol, sol2));
        }
        public void CreateSol(TestStellarMap map)
        {
            Star sol = new Star("Sol");

            map.Add <Star>(sol);
            sol.Add(new Planet("Mercury"));
            sol.Add(new Planet("Venus"));

            Planet earth = new Planet("Earth");

            map.Add <Planet>(earth);

            Satellite moon = new Satellite("Moon");

            earth.Add(moon);

            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 DwarfPlanet("Ceres"));
            sol.Add(new DwarfPlanet("Pluto"));

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

            sol.Add(new Comet("Haley's"));
            sol.Add(new Comet("Caeser's"));
        }
Beispiel #3
0
        public void StellarMapNotEqualProxCentCTest()
        {
            TestStellarMap map = new TestStellarMap("TestMap");
            Star           sol = new Star("Sol");

            map.Add <Star>(sol);
            sol.Add(new Planet("Mercury"));
            sol.Add(new Planet("Venus"));
            sol.Add(new Planet("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 DwarfPlanet("Ceres"));
            sol.Add(new DwarfPlanet("Pluto"));

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

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

            Star proximaCent = new Star("Proxima Centauri");

            map.Add <Star>(proximaCent);
            proximaCent.Add(new Planet("b"));

            TestStellarMap map2 = new TestStellarMap("TestMap");
            Star           sol2 = new Star("Sol");

            map2.Add <Star>(sol2);
            sol2.Add(new Planet("Mercury"));
            sol2.Add(new Planet("Venus"));
            sol2.Add(new Planet("Earth"));
            sol2.Add(new Planet("Mars"));
            sol2.Add(new Planet("Jupiter"));
            sol2.Add(new Planet("Saturn"));
            sol2.Add(new Planet("Uranus"));
            sol2.Add(new Planet("Neptune"));

            sol2.Add(new DwarfPlanet("Ceres"));
            sol2.Add(new DwarfPlanet("Pluto"));

            sol2.Add(new Asteroid("Pallas"));
            sol2.Add(new Asteroid("Juno"));

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

            proximaCent = new Star("Proxima Centauri");
            map2.Add <Star>(proximaCent);
            proximaCent.Add(new Planet("b"));
            proximaCent.Add(new Planet("c"));

            Assert.IsFalse(BaseStellarMapEqualityComparer.Comparer.Equals(map, map2));
        }
        public void CreateEarth(TestStellarMap map)
        {
            Planet earth = new Planet("Earth");

            map.Add <Planet>(earth);

            Satellite moon = new Satellite("Moon");

            earth.Add(moon);
        }
        public TestStellarMap DeSerializeMap(StreamReader reader)
        {
            string json = string.Empty;

            json = reader.ReadToEnd();

            TestStellarMap map = JsonConvert.DeserializeObject <TestStellarMap>(json);

            map.SetMap();

            return(map);
        }
Beispiel #6
0
        public void StarNotEqualSolarSystemMissingPlutoTest()
        {
            TestStellarMap map = new TestStellarMap();
            Star           sol = new Star("Sol");

            map.Add <Star>(sol);
            sol.Add(new Planet("Mercury"));
            sol.Add(new Planet("Venus"));
            sol.Add(new Planet("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 DwarfPlanet("Ceres"));
            sol.Add(new DwarfPlanet("Pluto"));

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

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

            TestStellarMap map2 = new TestStellarMap();
            Star           sol2 = new Star("Sol");

            //sol2.Identifier = sol.Identifier; // have to do this since BaseStellarMap's default identifier generation is GUIDs which can't be compared
            map2.Add <Star>(sol2);
            sol2.Add(new Planet("Mercury"));
            sol2.Add(new Planet("Venus"));
            sol2.Add(new Planet("Earth"));
            sol2.Add(new Planet("Mars"));
            sol2.Add(new Planet("Jupiter"));
            sol2.Add(new Planet("Saturn"));
            sol2.Add(new Planet("Uranus"));
            sol2.Add(new Planet("Neptune"));

            // Pluto is a planet once again
            sol2.Add(new Planet("Pluto"));

            // Ceres is back to an asteroid
            sol2.Add(new Asteroid("Ceres"));
            sol2.Add(new Asteroid("Pallas"));
            sol2.Add(new Asteroid("Juno"));

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

            Assert.IsFalse(StarEqualityComparer.Comparer.Equals(sol, sol2));
        }
Beispiel #7
0
        public void PlanetReferenceEqualTest()
        {
            TestStellarMap map = new TestStellarMap();

            Planet earth = new Planet("Earth");

            map.Add <Planet>(earth);

            Satellite moon = new Satellite("Moon");

            earth.Add(moon);

            Assert.IsTrue(PlanetEqualityComparer.Comparer.Equals(earth, earth));
        }
Beispiel #8
0
        public void StarEqualSolarSystemTest()
        {
            TestStellarMap map = new TestStellarMap();
            Star           sol = new Star("Sol");

            map.Add <Star>(sol);
            sol.Add(new Planet("Mercury"));
            sol.Add(new Planet("Venus"));
            sol.Add(new Planet("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 DwarfPlanet("Ceres"));
            sol.Add(new DwarfPlanet("Pluto"));

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

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

            TestStellarMap map2 = new TestStellarMap();
            Star           sol2 = new Star("Sol");

            map2.Add <Star>(sol2);
            sol2.Add(new Planet("Mercury"));
            sol2.Add(new Planet("Venus"));
            sol2.Add(new Planet("Earth"));
            sol2.Add(new Planet("Mars"));
            sol2.Add(new Planet("Jupiter"));
            sol2.Add(new Planet("Saturn"));
            sol2.Add(new Planet("Uranus"));
            sol2.Add(new Planet("Neptune"));

            sol2.Add(new DwarfPlanet("Ceres"));
            sol2.Add(new DwarfPlanet("Pluto"));

            sol2.Add(new Asteroid("Pallas"));
            sol2.Add(new Asteroid("Juno"));

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

            Assert.IsTrue(StarEqualityComparer.Comparer.Equals(sol, sol2));
        }
        public void SerializeFileSol()
        {
            TestStellarMap map = new TestStellarMap("Sol");

            CreateSol(map);

            string filename = Path.Combine(TestingUtilities.Config["DataPath"], "BaseSol.json");

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

            using StreamWriter writer = new StreamWriter(filename);
            SerializeMap(map, writer);
        }
Beispiel #10
0
        public void PlanetNotEqualMoonMissingTest()
        {
            TestStellarMap map   = new TestStellarMap();
            Planet         earth = new Planet("Earth");

            map.Add <Planet>(earth);

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

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

            earth2.Add(moon2);

            Assert.IsFalse(PlanetEqualityComparer.Comparer.Equals(earth, earth2));
        }
        public void CompareEarthTest()
        {
            TestStellarMap originalMap = new TestStellarMap("Earth");

            CreateEarth(originalMap);
            TestStellarMap finalMap;

            using MemoryStream memory = new MemoryStream();
            using StreamWriter writer = new StreamWriter(memory, Encoding.Unicode, 1024, true);
            SerializeMap(originalMap, writer);
            writer.Flush();

            memory.Position = 0;

            using StreamReader reader = new StreamReader(memory);
            finalMap = DeSerializeMap(reader);

            Assert.IsTrue(BaseStellarMapEqualityComparer.Comparer.Equals(originalMap, finalMap));
        }
Beispiel #12
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));
        }
        public void SerializeMap(TestStellarMap map, StreamWriter writer)
        {
            string json = JsonConvert.SerializeObject(map, Newtonsoft.Json.Formatting.Indented);

            writer.Write(json);
        }