public async Task CanGetDatabaseNames() { var util = Substitute.For <ISqlServerUtil>(); util.GetDatabaseNames(Arg.Any <string>()).Returns(DbNames); var vm = new SqlInstancesVm(util, _progressBarProvider, _userPrefPersist); await vm.RetrieveDbNamesAsync("MSSQLServer"); CollectionAssert.AreEqual(DbNames, vm.DbNames); }
public void Setup() { _sqlServerUtil = Substitute.For <ISqlServerUtil>(); _sqlServerUtil.GetSqlInstances().Returns(Instances); _progressBarProvider = Substitute.For <IProgressBarProvider>(); _userPrefPersist = Substitute.For <IUserPreferencePersist>(); _userPrefPersist.LoadPreference().Returns(new UserPreference()); _vm = new SqlInstancesVm(_sqlServerUtil, _progressBarProvider, _userPrefPersist); }
public async Task GiveAnEmptyInstance_NothingWillHappen() { var util = Substitute.For <ISqlServerUtil>(); var vm = new SqlInstancesVm(util, _progressBarProvider, _userPrefPersist); vm.PropertyChanged += (sender, args) => { Assert.Fail("Should not raise any property change event"); }; await vm.RetrieveDbNamesAsync(null); await vm.RetrieveDbNamesAsync(""); CollectionAssert.IsEmpty(vm.DbNames); }
public async Task ShouldUpdateTheProgressProperly() { var util = Substitute.For <ISqlServerUtil>(); util.GetDatabaseNames(Arg.Any <string>()).Returns(DbNames); var vm = new SqlInstancesVm(util, _progressBarProvider, _userPrefPersist); await vm.RetrieveDbNamesAsync("MSSQLServer"); _progressBarProvider.Received(1).Start(false, SqlInstancesVm.RetrivingDbNames); _progressBarProvider.Received(1).OnCompleted(Arg.Any <string>()); }
public async Task ShouldExcludeSystemDatabases_CaseInsensative() { var util = Substitute.For <ISqlServerUtil>(); var dbsWithSystemTables = new List <string>(DbNames); dbsWithSystemTables.AddRange(ISqlServerUtil.SystemDatabases.Select(r => r.ToUpperInvariant())); util.GetDatabaseNames(Arg.Any <string>()).Returns(dbsWithSystemTables); var vm = new SqlInstancesVm(util, _progressBarProvider, _userPrefPersist); await vm.RetrieveDbNamesAsync("MSSQLServer"); CollectionAssert.AreEqual(DbNames, vm.DbNames); }