public void UserStartsUpInternetNotConnectedAndUserExistsDontCreateUserData()
 {
     Internet.SetConnected(false);
     OfflineDataService.SetUserDataExists(true, DateTime.Now);;
     Target.Startup(UserName);
     Assert.IsFalse(OfflineDataService.CreateUserDataCalled);
 }
        public void UserStartsUpInternetNotConnectedTryLoadOfflineData()
        {
            Internet.SetConnected(false);
            OfflineDataService.SetUserDataExists(true, DateTime.Now);
            Target.Startup(UserName);

            Assert.IsTrue(OfflineDataService.LoadUserDataCalled);
        }
        public void ShouldSaveLocalDataWhenNewUser()
        {
            Internet.SetConnected(false);

            OfflineDataService.SetUserDataExists(false, null);
            Target.Startup(UserName);
            var entity = new TestEntity();

            Target.PerformDataUpdateAction(dataService => dataService.Insert(entity), entity, now);
            Assert.IsTrue(OfflineDataService.LocalDataSaved);
        }
        public void UserNotConnectedOnStartsUpThenConnectsUserNotExistsOnlineShouldSyncData()
        {
            Internet.SetConnected(false);
            OfflineDataService.SetUserDataExists(true, DateTime.Now);
            Target.Startup(UserName);
            _onlineDataService.SetUserDataExists(false, null);
            Internet.SetConnected(true);
            var entity = new TestEntity();

            Target.PerformDataUpdateAction(dataService => dataService.Insert(entity), entity, now);
            Assert.IsTrue(SyncManager.UpdateTargetDataCalled);
        }
        public void UserNotConnectedOnStartsUpThenConnectsUserExistsOnlineShouldSaveLocalData()
        {
            Internet.SetConnected(false);
            OfflineDataService.SetUserDataExists(true, DateTime.Now);
            Target.Startup(UserName);
            _onlineDataService.SetUserDataExists(true, DateTime.Now.AddDays(-1));
            Internet.SetConnected(true);
            var entity = new TestEntity();

            Target.PerformDataUpdateAction(dataService => dataService.Insert(entity), entity, now);
            Assert.IsTrue(OfflineDataService.LocalDataSaved);
        }
        public void UserConnectedOnStartsUpThenDisconnectsUserNotExistsOfflineShouldCreateOffLineData()
        {
            Internet.SetConnected(true);
            _onlineDataService.SetUserDataExists(true, DateTime.Now.AddDays(-1));
            OfflineDataService.SetUserDataExists(false, null);
            Target.Startup(UserName);

            Internet.SetConnected(false);
            var entity = new TestEntity();

            Target.PerformDataUpdateAction(dataService => dataService.Insert(entity), entity, now);
            Assert.IsTrue(OfflineDataService.CreateUserDataCalled);
        }