public void LunarEclipse()
        {
            //Deserialize
            using (StreamReader streamReader = new StreamReader("CelestialData\\LunarEclipse.txt"))
            {
                BinaryFormatter binaryFormatter = new BinaryFormatter();
                LunarEclipse    ev = (LunarEclipse)binaryFormatter.Deserialize(streamReader.BaseStream);

                LunarEclipseDetails lE1 = ev.LastEclipse;
                LunarEclipseDetails nE1 = ev.NextEclipse;
                LunarEclipseDetails lE2 = data.LunarEclispe.LastEclipse;
                LunarEclipseDetails nE2 = data.LunarEclispe.NextEclipse;

                PropertyInfo[] properties = typeof(LunarEclipseDetails).GetProperties();
                foreach (PropertyInfo property in properties)
                {
                    var l1 = property.GetValue(lE1);
                    var l2 = property.GetValue(lE2);
                    var n1 = property.GetValue(nE1);
                    var n2 = property.GetValue(nE2);

                    Assert.AreEqual(l1.ToString(), l2.ToString(), "Last Eclipse data does not match.");
                    Assert.AreEqual(n1.ToString(), n2.ToString(), "Next Eclipse data does not match.");
                }
            }
        }
예제 #2
0
        public bool Check_Lunar_Eclipse()
        {
            IFormatter formatter = new BinaryFormatter();

            //Deserialize
            using (StreamReader streamReader = new StreamReader("CelestialData\\LunarEclipse.txt"))
            {
                BinaryFormatter binaryFormatter = new BinaryFormatter();
                LunarEclipse    ev = (LunarEclipse)binaryFormatter.Deserialize(streamReader.BaseStream);

                LunarEclipseDetails lE1 = ev.LastEclipse;
                LunarEclipseDetails nE1 = ev.NextEclipse;
                LunarEclipseDetails lE2 = this.LunarEclispe.LastEclipse;
                LunarEclipseDetails nE2 = this.LunarEclispe.NextEclipse;

                PropertyInfo[] properties = typeof(LunarEclipseDetails).GetProperties();
                foreach (PropertyInfo property in properties)
                {
                    var l1 = property.GetValue(lE1);
                    var l2 = property.GetValue(lE2);
                    var n1 = property.GetValue(nE1);
                    var n2 = property.GetValue(nE2);

                    if (l1.ToString() != l2.ToString())
                    {
                        return(false);
                    }

                    if (n1.ToString() != n2.ToString())
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }