Beispiel #1
0
        public void ShowWebPageTest()
        {
            IXamarinWrapper xamarinWrapper = new XamarinWrapperStub();
            AboutViewModel  aboutViewModel = new AboutViewModel(xamarinWrapper);

            aboutViewModel.ShowWebPageCommand.Execute(null);
        }
        public void Tests()
        {
            IXamarinWrapper xamarinWrapper = new XamarinWrapperStub();

            int  thisThreadId = Thread.CurrentThread.ManagedThreadId;
            int  counter      = 0;
            bool sameThread   = false;

            xamarinWrapper.MainSynchronizationContext.Post(o =>
            {
                counter++;
                sameThread = (thisThreadId == Thread.CurrentThread.ManagedThreadId);
            }, null);

            Assert.AreEqual(1, counter);
            Assert.IsTrue(sameThread);

            xamarinWrapper.MainSynchronizationContext.Send(o =>
            {
                counter++;
                sameThread = (thisThreadId == Thread.CurrentThread.ManagedThreadId);
            }, null);

            Assert.AreEqual(2, counter);
            Assert.IsTrue(sameThread);
        }
Beispiel #3
0
        private static ResultsService CreateScoresService(int countError)
        {
            IXamarinWrapper xamarinWrapper = new XamarinWrapperStub();
            IFileHelper     fileHelper     = new FileHelperStub(countError);
            ResultsService  resultsService = new ResultsService(xamarinWrapper, fileHelper);

            return(resultsService);
        }
Beispiel #4
0
 public void Constructor_Test()
 {
     IXamarinWrapper xamarinWrapper = new XamarinWrapperStub();
     IFileHelper     fileHelper     = new FileHelperStub();
     ManualTimer     manualTimer    = new ManualTimer();
     ResultsService  resultsService = new ResultsService(xamarinWrapper, fileHelper);
     GameService     gameService    = new GameService(xamarinWrapper, fileHelper, manualTimer, resultsService);
 }
Beispiel #5
0
        public void BuildDateTextTest()
        {
            IXamarinWrapper xamarinWrapper = new XamarinWrapperStub();
            AboutViewModel  aboutViewModel = new AboutViewModel(xamarinWrapper);

            string s = aboutViewModel.BuildDateText;

            Assert.False(string.IsNullOrWhiteSpace(s));
        }
        public void Tests()
        {
            XamarinWrapperStub xamarinWrapperStub = new XamarinWrapperStub();

            Assert.False(string.IsNullOrWhiteSpace(xamarinWrapperStub.AppDataDirectory));

            Assert.IsTrue(xamarinWrapperStub.IsMainThread);

            Assert.AreSame(SynchronizationContext.Current, xamarinWrapperStub.MainSynchronizationContext);
        }
        private static ResultsViewModel CreateResultsViewModel()
        {
            IXamarinWrapper xamarinWrapper = new XamarinWrapperStub();
            IFileHelper     fileHelper     = new FileHelperStub();
            ResultsService  resultsService = new ResultsService(xamarinWrapper, fileHelper);

            ResultsViewModel resultsViewModel = new ResultsViewModel(xamarinWrapper, resultsService);

            return(resultsViewModel);
        }
        private static GameViewModel CreateGameViewModel(ManualTimer manualTimer = null)
        {
            IXamarinWrapper xamarinWrapper = new XamarinWrapperStub();
            IFileHelper     fileHelper     = new FileHelperStub(0);

            manualTimer = manualTimer ?? new ManualTimer();
            ResultsService resultsService = new ResultsService(xamarinWrapper, fileHelper);
            GameService    gameService    = new GameService(xamarinWrapper, fileHelper, manualTimer, resultsService);

            GameViewModel gameViewModel = new GameViewModel(xamarinWrapper, gameService);

            return(gameViewModel);
        }
Beispiel #9
0
        public void GameDurationTextTest()
        {
            IXamarinWrapper xamarinWrapper = new XamarinWrapperStub();
            AboutViewModel  aboutViewModel = new AboutViewModel(xamarinWrapper);

            string s = aboutViewModel.GameDurationText;

            Assert.False(string.IsNullOrWhiteSpace(s));

            bool isInt = int.TryParse(s, out int i);

            Assert.True(isInt);
        }
        public void NewResultsTests()
        {
            // ToDo: This duplicates CreateResultsViewModel because we need access to _resultsService.

            IXamarinWrapper xamarinWrapper = new XamarinWrapperStub();
            IFileHelper     fileHelper     = new FileHelperStub();
            ResultsService  resultsService = new ResultsService(xamarinWrapper, fileHelper);

            ResultsViewModel resultsViewModel = new ResultsViewModel(xamarinWrapper, resultsService);

            IEnumerable <Result> bestResults   = resultsViewModel.BestResults;
            IEnumerable <Result> latestResults = resultsViewModel.LatestResults;

            Result result = new Result(default, 1, 0);
Beispiel #11
0
        public void ConstructorTest()
        {
            IXamarinWrapper xamarinWrapper = new XamarinWrapperStub();

            _ = new AboutViewModel(xamarinWrapper);
        }