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); }
public void SetUp() { var screenReader = Substitute.For<INMZPointsScreenReader>(); screenReader.ScreenToNMZPoints().ReturnsForAnyArgs("1231"); dream = new Dream { Calculator = Substitute.For<IPointsCalculator>(), NMZPointsScreenReader = screenReader, }; }
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); }
private void MonksterKilled(Dream m, EventArgs e) { var eM = (MonsterKilledArgs) e; UpdatePoints(eM.Points.ToString()); }