コード例 #1
0
        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);
        }
コード例 #2
0
        public void TestConnectionCommandCanExecute_ServerNameUserNameAndPasswordValid_ReturnsTrue()
        {
            ConfigureDataProviderViewModelMock sut = _container
                                                     .Resolve <ConfigureDataProviderViewModelMock>()
                                                     .InitializeServerNameUserNameAndPasswordToValidValues();

            Assert.That(sut.TestConnectionCommand.CanExecute(null), Is.True);
        }
コード例 #3
0
        public void TestConnectionCommandExecute_DataProviderDoesNotThrowError_ObtainsServerConnectString()
        {
            ConfigureDataProviderViewModelMock sut = _container
                                                     .Resolve <ConfigureDataProviderViewModelMock>()
                                                     .InitializeServerNameUserNameAndPasswordToValidValues();

            sut.TestConnectionCommand.Execute(null);

            Assert.That(sut.ServerConnectString, Is.Not.EqualTo(string.Empty));
        }
コード例 #4
0
        public void TestConnectionCommandCanExecute_UserNameEmpty_ReturnsFalse()
        {
            ConfigureDataProviderViewModelMock sut = _container
                                                     .Resolve <ConfigureDataProviderViewModelMock>()
                                                     .InitializeServerNameUserNameAndPasswordToValidValues();

            sut.UserName = string.Empty;

            Assert.That(sut.TestConnectionCommand.CanExecute(null), Is.False);
        }
コード例 #5
0
        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>()));
        }