public void UpdateGameData001_DateTimeWhenGameConcluded() { Mock <ISettings> settingsMock = new Mock <ISettings>(); DateTime timeConcluded = new DateTime(2016, 12, 12, 23, 45, 5); Mock <ITrackerFactory> trackerFactory = new Mock <ITrackerFactory>(); trackerFactory.Setup(tf => tf.GetDateTimeNow()).Returns(timeConcluded); trackerFactory.Setup(tf => tf.GetService <IMessenger>()).Returns(new Mock <IMessenger>().Object); trackerFactory.Setup(tf => tf.GetService <IDeckService>()).Returns(new DeckService(trackerFactory.Object)); Mock <ITracker> tracker = new Mock <ITracker>(); tracker.Setup(t => t.Games).Returns(new ObservableCollection <DataModel.Game>()); tracker.Setup(t => t.ActiveDeck).Returns(Deck.CreateNewDeck(trackerFactory.Object)); trackerFactory.Setup(tf => tf.GetTracker()).Returns(tracker.Object); Mock <IWinAPI> winApi = new Mock <IWinAPI>(); winApi.Setup(w => w.GetEslFileVersionInfo()).Returns <FileVersionInfo>(null); trackerFactory.Setup(tf => tf.GetService <IWinAPI>()).Returns(winApi.Object); EditGameViewModel model = new EditGameViewModel(trackerFactory.Object); PopulateObject(model.Game, StartProp); Assert.AreNotEqual(timeConcluded, model.Game.Date); model.UpdateGameData(GameOutcome.Victory); Assert.AreEqual(timeConcluded, model.Game.Date); }
public void CommandButtonCreateExecuteTest004_CheckIfESLFileVersionAdded() { Mock <ITrackerFactory> trackerFactory = new Mock <ITrackerFactory>(); Mock <IMessenger> messanger = new Mock <IMessenger>(); trackerFactory.Setup(tf => tf.GetService <IMessenger>()).Returns(messanger.Object); Mock <ISettings> settings = new Mock <ISettings>(); trackerFactory.Setup(tf => tf.GetService <ISettings>()).Returns(settings.Object); Mock <ITracker> tracker = new Mock <ITracker>(); tracker.Setup(t => t.Games).Returns(new ObservableCollection <DataModel.Game>()); tracker.Setup(t => t.ActiveDeck).Returns(new Deck(trackerFactory.Object)); trackerFactory.Setup(tf => tf.GetTracker()).Returns(tracker.Object); FileVersionInfo expected = FileVersionInfo.GetVersionInfo(Assembly.GetAssembly(this.GetType()).Location); Mock <IWinAPI> winApi = new Mock <IWinAPI>(); winApi.Setup(w => w.GetEslFileVersionInfo()).Returns(expected); trackerFactory.Setup(tf => tf.GetService <IWinAPI>()).Returns(winApi.Object); EditGameViewModel model = new EditGameViewModel(trackerFactory.Object); GameOutcome param = GameOutcome.Victory; model.UpdateGameData(param); Assert.IsNotNull(model.Game.ESLVersion); Assert.AreEqual(expected.ProductVersion, model.Game.ESLVersion.ToString()); }
public void CommandButtonCreateExecuteTest005_CheckIfESLFileVersionAddedWhenESLNOtRunning() { Mock <ITrackerFactory> trackerFactory = new Mock <ITrackerFactory>(); Mock <IMessenger> messanger = new Mock <IMessenger>(); trackerFactory.Setup(tf => tf.GetService <IMessenger>()).Returns(messanger.Object); Mock <ISettings> settings = new Mock <ISettings>(); trackerFactory.Setup(tf => tf.GetService <ISettings>()).Returns(settings.Object); FileVersionInfo expected = FileVersionInfo.GetVersionInfo(Assembly.GetAssembly(this.GetType()).Location); Mock <ITracker> tracker = new Mock <ITracker>(); //add two games wit hdiff version - ensure correct is copied tracker.Setup(t => t.Games).Returns(new ObservableCollection <DataModel.Game>() { new DataModel.Game() { Date = DateTime.Now, ESLVersion = new SerializableVersion(new Version(expected.ProductVersion.ToString())) }, new DataModel.Game() { Date = DateTime.Now.AddDays(-7), ESLVersion = new SerializableVersion(2, 3) }, new DataModel.Game() { Date = DateTime.Now, ESLVersion = null }, }); tracker.Setup(t => t.ActiveDeck).Returns(new Deck(trackerFactory.Object)); trackerFactory.Setup(tf => tf.GetTracker()).Returns(tracker.Object); Mock <IWinAPI> winApi = new Mock <IWinAPI>(); //ensure not running winApi.Setup(w => w.GetEslFileVersionInfo()).Returns <FileVersionInfo>(null); trackerFactory.Setup(tf => tf.GetService <IWinAPI>()).Returns(winApi.Object); EditGameViewModel model = new EditGameViewModel(trackerFactory.Object); GameOutcome param = GameOutcome.Victory; model.UpdateGameData(param); Assert.IsNotNull(model.Game.ESLVersion); Assert.AreEqual(expected.ProductVersion, model.Game.ESLVersion.ToString()); }