public void TestConnectionCommandExecute_DataProviderSuccessfullyOpensConnection_SaveCommandCanExecute() { var dataProviderStub = new Mock <IDataProvider>(); dataProviderStub .SetupGet(dp => dp.IsConnectedToServer) .Returns(true); var databaseConnectorStub = new Mock <IDatabaseConnector>(); databaseConnectorStub .SetupGet(dc => dc.DataProvider) .Returns(dataProviderStub.Object); _container .RegisterInstance(dataProviderStub.Object) .RegisterInstance(databaseConnectorStub.Object); ConfigureDataProviderViewModelMock sut = _container .Resolve <ConfigureDataProviderViewModelMock>() .InitializeServerNameUserNameAndPasswordToValidValues(); sut.TestConnectionCommand.Execute(null); Assert.That(sut.SaveCommand.CanExecute(null), Is.True); }
public void TestConnectionCommandCanExecute_ServerNameUserNameAndPasswordValid_ReturnsTrue() { ConfigureDataProviderViewModelMock sut = _container .Resolve <ConfigureDataProviderViewModelMock>() .InitializeServerNameUserNameAndPasswordToValidValues(); Assert.That(sut.TestConnectionCommand.CanExecute(null), Is.True); }
public void TestConnectionCommandExecute_DataProviderDoesNotThrowError_ObtainsServerConnectString() { ConfigureDataProviderViewModelMock sut = _container .Resolve <ConfigureDataProviderViewModelMock>() .InitializeServerNameUserNameAndPasswordToValidValues(); sut.TestConnectionCommand.Execute(null); Assert.That(sut.ServerConnectString, Is.Not.EqualTo(string.Empty)); }
public void TestConnectionCommandCanExecute_UserNameEmpty_ReturnsFalse() { ConfigureDataProviderViewModelMock sut = _container .Resolve <ConfigureDataProviderViewModelMock>() .InitializeServerNameUserNameAndPasswordToValidValues(); sut.UserName = string.Empty; Assert.That(sut.TestConnectionCommand.CanExecute(null), Is.False); }
public void SaveCommandExecute_ValidSetupValues_SavesServerConnectStringToDatabaseSettings() { var settingsMock = new Mock <IDatabaseSettings>(); _container .RegisterInstance(settingsMock.Object); ConfigureDataProviderViewModelMock sut = _container .Resolve <ConfigureDataProviderViewModelMock>() .InitializeServerNameUserNameAndPasswordToValidValues(); sut.SaveCommand.Execute(null); settingsMock.Verify(ds => ds.SetServerConnectStringFor(sut.DataProviderInfoMock, It.IsAny <string>())); }