Ejemplo n.º 1
0
        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");
        }
        public void ConnectionInformationDialog_CreateConnectionInformation_ValidModel_ReturnsConnectionInformation()
        {
            // Setup
            var serverUrl = "https://localhost";
            var username  = "******";
            var inputPlaintextPassword = "******";
            var securePassword         = inputPlaintextPassword.ConvertToSecureString();

            ConnectionInfoDialogViewModel viewModel = ConnectionInformationDialog.CreateViewModel(null);

            viewModel.ServerUrlRaw = serverUrl;
            viewModel.Username     = username;
            viewModel.ValidateCredentials(securePassword);

            // Act
            ConnectionInformation connInfo = ConnectionInformationDialog.CreateConnectionInformation(viewModel, securePassword);

            // Verify
            Assert.IsNotNull(connInfo, "ConnectionInformation should be returned");
            Assert.AreEqual(new Uri(serverUrl), connInfo.ServerUri, "Server URI returned was different");
            Assert.AreEqual(username, connInfo.UserName, "Username returned was different");

            string outputPlaintextPassword = connInfo.Password.ConvertToUnsecureString();

            Assert.AreEqual(inputPlaintextPassword, outputPlaintextPassword, "Password returned was different");
        }