Convert() public method

public Convert ( object values, Type targetType, object parameter, CultureInfo culture ) : object
values object
targetType System.Type
parameter object
culture System.Globalization.CultureInfo
return object
        public void ProjectViewModelVisibilityConverter_Convert_WhenGivenFourValuesButFirstValueIsNotStringOrIsNull_ExpectsDependencyProperyUnsetValue()
        {
            // Arrange
            var converter = new ProjectViewModelVisibilityConverter();
            var values = new object[4];

            // Act
            values[0] = 5;
            var result1 = converter.Convert(values, null, null, null);
            values[0] = null;
            var result2 = converter.Convert(values, null, null, null);

            // Assert
            Assert.AreEqual(result1, DependencyProperty.UnsetValue);
            Assert.AreEqual(result2, DependencyProperty.UnsetValue);
        }
        public void ProjectViewModelVisibilityConverter_Convert_WhenNotGivenFourValues_ExpectsDependencyProperyUnsetValue()
        {
            // Arrange
            var converter = new ProjectViewModelVisibilityConverter();

            // Act
            var result0 = converter.Convert(new object[0], null, null, null);
            var result1 = converter.Convert(new object[1], null, null, null);
            var result2 = converter.Convert(new object[2], null, null, null);
            var result3 = converter.Convert(new object[3], null, null, null);
            var result5 = converter.Convert(new object[5], null, null, null);

            // Assert
            Assert.AreEqual(result0, DependencyProperty.UnsetValue);
            Assert.AreEqual(result1, DependencyProperty.UnsetValue);
            Assert.AreEqual(result2, DependencyProperty.UnsetValue);
            Assert.AreEqual(result3, DependencyProperty.UnsetValue);
            Assert.AreEqual(result5, DependencyProperty.UnsetValue);
        }
        public void ProjectViewModelVisibilityConverter_Convert_WhenGivenANullValue_ExpectsDependencyProperyUnsetValue()
        {
            // Arrange
            var converter = new ProjectViewModelVisibilityConverter();

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

            // Assert
            Assert.AreEqual(result, DependencyProperty.UnsetValue);
        }
        public void ProjectViewModelVisibilityConverter_Convert_WhenShowAllProjectsIsFalseAndIsBoundIsFalse_ReturnsCollapsed()
        {
            // Arrange
            var converter = new ProjectViewModelVisibilityConverter();
            var projectName = "";
            var isShowingAllProjects = false;
            var isBound = false;
            var filterText = "";
            var values = new object[] { projectName, isShowingAllProjects, isBound, filterText };

            // Act
            var result = converter.Convert(values, null, null, null);

            // Assert
            Assert.IsInstanceOfType(result, typeof(Visibility));
            Assert.AreEqual(result, Visibility.Collapsed);
        }
        public void ProjectViewModelVisibilityConverter_Convert_WhenShowAllProjectsIsTrueAndProjectNameContainsFilterText_ReturnsVisible()
        {
            // Arrange
            var converter = new ProjectViewModelVisibilityConverter();
            var projectName = "foobar";
            var isShowingAllProjects = true;
            var isBound = false;
            var filterText = "bar";
            var values = new object[] { projectName, isShowingAllProjects, isBound, filterText };

            // Act
            var result = converter.Convert(values, null, null, null);

            // Assert
            Assert.IsInstanceOfType(result, typeof(Visibility));
            Assert.AreEqual(result, Visibility.Visible);
        }