public void When_we_come_back_to_home_page_name_should_be_there()
        {
            var fakePageService      = new FakePageService();
            var _mockLocationService = Substitute.For <ILocationService>();
            var locationdumyService  = Substitute.For <ILocationService>();
            var dataStoreService     = Substitute.For <IDataStore>();
            var userName             = "******";

            dataStoreService.IsDataAvailable("LoggedInUserName").Returns(false);
            dataStoreService.When(x => x.Put <string>("LoggedInUserName", userName)).Do(x =>
            {
                dataStoreService.IsDataAvailable("LoggedInUserName").Returns(true);
                dataStoreService.Get <string>("LoggedInUserName").Returns(userName);
            });
            var unitTestFactory = new UnitTestFactory((r) =>
            {
                r.RegisterSingleton <IPageService>(fakePageService);
                r.RegisterSingleton <ILocationService>(locationdumyService);
                r.RegisterSingleton <IDataStore>(dataStoreService);
            });
            var homePageViewModel = new HomePageViewModel(fakePageService, unitTestFactory, dataStoreService);

            homePageViewModel.Name = userName;
            homePageViewModel.GoToNextCommand.Execute(null);

            var productPageViewModel = new LocationViewModel(fakePageService, _mockLocationService, unitTestFactory, dataStoreService);
            var canGoBack            = productPageViewModel.GoBackCommand.CanExecute(null);

            productPageViewModel.GoBackCommand.Execute(null);

            Assert.AreEqual(userName, homePageViewModel.Name);
        }
 public void Setup()
 {
     fakePageService      = new FakePageService();
     _datastore           = Substitute.For <IDataStore>();
     _mockLocationService = Substitute.For <ILocationService>();
     unitTestFactory      = new UnitTestFactory(r =>
     {
         r.RegisterSingleton <IPageService>(fakePageService);
         r.RegisterSingleton <ILocationService>(_mockLocationService);
         r.RegisterSingleton <IDataStore>(_datastore);
     });
     productPageViewModel = new LocationViewModel(fakePageService, _mockLocationService, unitTestFactory, _datastore);
 }
        public void When_app_load_first_time_name_field_should_be_empty()
        {
            var fakePageService = new FakePageService();

            var locationdumyService = Substitute.For <ILocationService>();
            var dataStoreService    = Substitute.For <IDataStore>();
            var unitTestFactory     = new UnitTestFactory((r) =>
            {
                r.RegisterSingleton <IPageService>(fakePageService);
                r.RegisterSingleton <ILocationService>(locationdumyService);
                r.RegisterSingleton <IDataStore>(dataStoreService);
            });
            var homePageViewModel = new HomePageViewModel(fakePageService, unitTestFactory, dataStoreService);

            Assert.IsTrue(string.IsNullOrEmpty(homePageViewModel.Name));
        }
 public void Setup()
 {
     fakePageService  = new FakePageService();
     _datastore       = Substitute.For <IDataStore>();
     locationService  = Substitute.For <ILocationService>();
     gpsSensorService = Substitute.For <IGpsSensorService>();
     gpsSensorService.IsGpsEnabled().Returns(false);
     unitTestFactory = new UnitTestFactory(r =>
     {
         r.RegisterSingleton <IPageService>(fakePageService);
         r.RegisterSingleton <ILocationService>(locationService);
         r.RegisterSingleton <IGpsSensorService>(gpsSensorService);
         r.RegisterSingleton <IDataStore>(_datastore);
     });
     gpsStatusViewModel = new GpsStatusViewModel(fakePageService, gpsSensorService, unitTestFactory, _datastore);
 }
        public void When_we_hit_next_then_we_go_to_location_page()
        {
            var fakePageService = new FakePageService();

            var locationdumyService = Substitute.For <ILocationService>();
            var dataStoreService    = Substitute.For <IDataStore>();
            var unitTestFactory     = new UnitTestFactory((r) =>
            {
                r.RegisterSingleton <IPageService>(fakePageService);
                r.RegisterSingleton <ILocationService>(locationdumyService);
                r.RegisterSingleton <IDataStore>(dataStoreService);
            });
            var homePageViewModel = new HomePageViewModel(fakePageService, unitTestFactory, dataStoreService);

            homePageViewModel.Name = "arun";
            var canGoNext = homePageViewModel.GoToNextCommand.CanExecute(null);

            homePageViewModel.GoToNextCommand.Execute(null);

            Assert.AreEqual(true, canGoNext);
            Assert.AreEqual(typeof(LocationViewModel), fakePageService.GetViewModelPageType());
        }