public void ConnectionInformationDialog_CreateConnectionInformation_ValidModel_ReturnsConnectionInformation() { // Arrange var serverUrl = "https://localhost"; var username = "******"; var inputPlaintextPassword = "******"; var securePassword = inputPlaintextPassword.ToSecureString(); ConnectionInfoDialogViewModel viewModel = ConnectionInformationDialog.CreateViewModel(null); viewModel.ServerUrlRaw = serverUrl; viewModel.Username = username; viewModel.ValidateCredentials(securePassword); // Act ConnectionInformation connInfo = ConnectionInformationDialog.CreateConnectionInformation(viewModel, securePassword); // Assert connInfo.Should().NotBeNull("ConnectionInformation should be returned"); connInfo.ServerUri.Should().Be(new Uri(serverUrl), "Server URI returned was different"); connInfo.UserName.Should().Be(username, "Username returned was different"); string outputPlaintextPassword = connInfo.Password.ToUnsecureString(); outputPlaintextPassword.Should().Be(inputPlaintextPassword, "Password returned was different"); }
ConnectionInformation IConnectionInformationProvider.GetConnectionInformation(ConnectionInformation currentConnection) { if (this.ExpectExistingConnection) { currentConnection.Should().NotBeNull("No existing connection provided"); } return(this.ConnectionInformationToReturn); }
private void AssertExpectedConnection(ConnectionInformation connection) { connection.Should().NotBeNull("The API requires a connection information"); if (this.ExpectedConnection != null) { connection.ServerUri.Should().Be(this.ExpectedConnection?.ServerUri, "The connection is not as expected"); } }
void IConnectionWorkflowExecutor.EstablishConnection(ConnectionInformation information) { this.NumberOfCalls++; information.Should().NotBeNull("Should not request to establish to a null connection"); // Simulate the expected behavior in product if (!this.sonarQubeService.TryGetProjects(information, CancellationToken.None, out this.lastConnectedProjects)) { FluentAssertions.Execution.Execute.Assertion.FailWith("Failed to establish connection"); } }
void IConnectionWorkflowExecutor.EstablishConnection(ConnectionInformation information) { this.NumberOfCalls++; information.Should().NotBeNull("Should not request to establish to a null connection"); // Simulate the expected behavior in product this.sonarQubeService.ConnectAsync(information, CancellationToken.None).GetAwaiter().GetResult(); this.lastConnectedProjects = this.sonarQubeService .GetAllProjectsAsync(information.Organization.Key, CancellationToken.None) .GetAwaiter() .GetResult(); }
public void ConnectionWorkflow_ConnectionStep_ConnectedServerCanBeGetAndSet() { // Arrange var connectionInfo = new ConnectionInformation(new Uri("http://server")); ConnectionWorkflow testSubject = new ConnectionWorkflow(this.host, new RelayCommand(() => { })); // Act testSubject.ConnectedServer = connectionInfo; // Assert connectionInfo.Should().Be(testSubject.ConnectedServer); }
public void ConnectionWorkflow_ConnectionStep_ConnectedServerCanBeGetAndSet() { // Arrange var connectionInfo = new ConnectionInformation(new Uri("http://server")); #pragma warning disable IDE0017 // Simplify object initialization ConnectionWorkflow testSubject = new ConnectionWorkflow(this.host, new RelayCommand(() => { })); #pragma warning restore IDE0017 // Simplify object initialization // Act testSubject.ConnectedServer = connectionInfo; // Assert connectionInfo.Should().Be(testSubject.ConnectedServer); }