private void AssertPlaybackSubmitAndNewGame(AnagramModel model) { model.Setup(); Assert.AreEqual(null, model.state); Assert.AreEqual(true, model.isNewGameVisible); model.Update(1.0f / 60.0f); model.Update(1.0f / 60.0f); model.Update(1.0f / 60.0f); Assert.AreEqual("newGame", model.journal.action); Assert.AreEqual("newGame", model.journal.actionNow); Assert.AreEqual("newGame", model.journal.commandNow); Assert.AreEqual(50, model.journal.milliseconds); Assert.AreEqual(false, model.isNewGameVisible); model.Update(1.0f / 60.0f); Assert.AreEqual(null, model.journal.actionNow); model.Update(1.0f / 60.0f); Assert.AreEqual("wrong", model.state); Assert.AreEqual("submit", model.journal.action); Assert.AreEqual("submit", model.journal.actionNow); Assert.AreEqual("submit", model.journal.commandNow); Assert.AreEqual(33, model.journal.milliseconds); }
private void AssertPlaybackActionEqualsCommand( AnagramModel model, string filePath) { string historyTsv = File.ReadAllText(filePath); model.Setup(); model.journal.ReadAndPlay(historyTsv); float time = 0.0f; float step = 1.0f / 60.0f; float recorded = (float)( model.journal.playbackDelays.Sum()) / 1000.0f; string message = "file " + filePath; while (model.journal.IsPlaying()) { time += step; model.Update(step); message = "file " + filePath + " playback index " + model.journal.playbackIndex + " word " + model.text; Assert.AreEqual(model.journal.commandNow, model.journal.actionNow, message); } float difference = Mathf.Abs(time - recorded); message = "file " + filePath + " playback " + time.ToString() + " record " + recorded.ToString() + " difference " + difference; Assert.AreEqual(true, difference < 0.01f, message); }
public void UpdateIsHelpByPosition() { AnagramModel model = new AnagramModel(); model.helpLevel = 100; model.helpPosition = 0.9f; model.width = 720.0f; model.Setup(); model.progress.level = model.tutorLevel + 1; var parameters = new Dictionary<string, object>(); parameters["text"] = "TALE"; model.StartTrial(parameters); model.Update(0.5f); Assert.AreEqual("", model.helpTextNow.next); model.Update(0.5f); Assert.AreEqual(null, model.helpTextNow.next); model.Update(16.0f); string message = model.wordPositionMinNormal.ToString(); Assert.AreEqual(model.shorterWordHelp, model.helpTextNow.next, message); }
public void UpdateHelpStateNowRepeat() { AnagramModel model = new AnagramModel(); model.Update(0.0f); Assert.AreEqual(null, model.helpStateNow); model.helpTextNow.next = "WORD REPEATED"; model.helpState.next = "repeat"; model.Update(0.0f); Assert.AreEqual("beginNow", model.helpStateNow); model.Update(0.0f); Assert.AreEqual(null, model.helpStateNow); model.helpTextNow.next = ""; model.helpState.next = ""; model.Update(0.0f); Assert.AreEqual("endNow", model.helpStateNow); model.Update(0.0f); Assert.AreEqual(null, model.helpStateNow); }
public void UpdateHelpStateNowEndOnce() { AnagramModel model = new AnagramModel(); model.helpTextNow.next = "WORD REPEATED"; model.helpState.next = "repeat"; model.Update(0.0f); model.helpTextNow.next = ""; model.helpState.next = ""; model.Update(0.0f); Assert.AreEqual("endNow", model.helpStateNow); model.helpTextNow.next = ""; model.helpState.next = "none"; model.Update(0.0f); Assert.AreEqual("endNow", model.helpStateNow, "state from '' to 'none'"); }