Esempio n. 1
0
        public void CanSaveDream()
        {
            int pointsActual;
            int durationActual;
            DateTime date;
            var dream = new Dream {Duration = 12345, Points = 12312};

            new DreamDb().SaveDream(dream);

            using (SQLiteConnection c = new SQLiteConnection(ConfigurationManager.ConnectionStrings["sqllite"].ConnectionString))
            {
                c.Open();
                using (SQLiteCommand cmd = new SQLiteCommand("select * from Dream", c))
                {
                    using (SQLiteDataReader r = cmd.ExecuteReader())
                    {
                        r.Read();
                        pointsActual = Convert.ToInt32(r["Points"]);
                        durationActual = Convert.ToInt32(r["DurationMs"]);
                        date = Convert.ToDateTime(r["Date"]);
                    }
                }
            }

            Assert.AreEqual(dream.Points, pointsActual);
            Assert.AreEqual(dream.Duration, durationActual);
            Assert.AreEqual(date.Day, DateTime.Now.Day);

            Assert.AreEqual(date.Month, DateTime.Now.Month);
            Assert.AreEqual(date.Year, DateTime.Now.Year);
            Assert.AreEqual(date.Hour, DateTime.Now.Hour);
            Assert.AreEqual(date.Minute, DateTime.Now.Minute);
        }
Esempio n. 2
0
        public void SetUp()
        {
            var screenReader = Substitute.For<INMZPointsScreenReader>();

            screenReader.ScreenToNMZPoints().ReturnsForAnyArgs("1231");

            dream = new Dream {
                Calculator = Substitute.For<IPointsCalculator>(), 
                NMZPointsScreenReader = screenReader,
            };
        }
Esempio n. 3
0
        public async void EndingADreamSavesItsDuration()
        {
            dream = new Dream();
            var screenReader = Substitute.For<INMZPointsScreenReader>();
            screenReader.ScreenToNMZPoints().ReturnsForAnyArgs("1048576");
            dream.NMZPointsScreenReader = screenReader;

            dream.Start();
            await Task.Delay(100);
            dream.End();

            Assert.That(Math.Abs(dream.Duration - 100) < 50, "Expected 100, was actually " + dream.Duration);
        }
Esempio n. 4
0
        private void MonksterKilled(Dream m, EventArgs e)
        {
            var eM = (MonsterKilledArgs) e;

            UpdatePoints(eM.Points.ToString());
        }