コード例 #1
0
        public void Convert_ValidProjecModel_ReturnsBindingArgs()
        {
            // Arrange
            var expectedUri      = new Uri("http://localhost:9000");
            var expectedPassword = new SecureString();

            expectedPassword.AppendChar('x');
            var serverViewModel  = new ServerViewModel(new ConnectionInformation(expectedUri, "user1", expectedPassword));
            var project          = new SonarQubeProject("key1", "name1");
            var projectViewModel = new ProjectViewModel(serverViewModel, project);

            var converter = new ProjectViewModelToBindingArgsConverter();

            // Act
            var convertedObj = converter.Convert(projectViewModel, null, null, null);

            convertedObj.Should().NotBeNull();
            convertedObj.Should().BeOfType <BindCommandArgs>();

            var bindCommandArgs = (BindCommandArgs)convertedObj;

            bindCommandArgs.ProjectKey.Should().Be("key1");
            bindCommandArgs.ProjectName.Should().Be("name1");
            bindCommandArgs.Connection.Should().NotBeNull();
            bindCommandArgs.Connection.ServerUri.Should().BeSameAs(expectedUri);
            bindCommandArgs.Connection.UserName.Should().Be("user1");
            bindCommandArgs.Connection.Password.Length.Should().Be(1);
        }
コード例 #2
0
        public void Convert_NotProjectViewModel_ReturnsNull()
        {
            // Arrange
            var converter = new ProjectViewModelToBindingArgsConverter();

            // Act && Assert
            converter.Convert(null, null, null, null).Should().BeNull();
            converter.Convert("a string", typeof(object), null, CultureInfo.CurrentCulture).Should().BeNull();
        }