public void SelectParentWillSelectAllChildrenExceptTheDisabledOnes() { // Arrange ProjectNode[] children = new ProjectNode[3]; // make two children enabled, one disabled for (int i = 0; i < 3; i++) { var project = MockProjectUtility.CreateMockProject("p" + i); var node = new ProjectNode(project) { IsEnabled = i % 2 == 0 }; children[i] = node; } var folder = new FolderNode(null, "A", children); // Act folder.IsSelected = true; // Assert Assert.True(children[0].IsSelected == true); Assert.True(children[1].IsSelected == false); Assert.True(children[2].IsSelected == true); }
public void ParentFolderDoNotPropagateStateBackToChildrenWhenTheyAreFirstAddedToFolder() { // Arrange ProjectNode[] children = new ProjectNode[3]; // make two children selected, one unselected for (int i = 0; i < 3; i++) { var project = MockProjectUtility.CreateMockProject("p" + i); var node = new ProjectNode(project) { IsSelected = i % 2 == 0 }; children[i] = node; } var folder = new FolderNode(null, "A", children); // Act var root = new FolderNode(null, "Root", new[] { folder }); // Assert Assert.Null(folder.IsSelected); for (int i = 0; i < 3; i++) { Assert.True(children[0].IsSelected == true); Assert.True(children[1].IsSelected == false); Assert.True(children[2].IsSelected == true); } }
public void ParentPropertyIsNullByDefault() { // Arrange var project = MockProjectUtility.CreateMockProject("A"); var node = new ProjectNode(project); // Act && Assert Assert.Null(node.Parent); }
public void NamePropertyIsCorrect() { // Arrange var project = MockProjectUtility.CreateMockProject("A"); var node = new ProjectNode(project); // Act & Assert Assert.Equal("A", node.Name); }
public void ProjectPropertyIsCorrect() { // Arrange var project = MockProjectUtility.CreateMockProject("A"); var node = new ProjectNode(project); // Act & Assert Assert.Same(project, node.Project); }
public void IsSelectedFalseByDefault() { // Arrange var project = MockProjectUtility.CreateMockProject("A"); var node = new ProjectNode(project); // Act & Assert Assert.True(node.IsSelected == false); }
public void GetSelectedProjectReturnsEmptyIfIsSelectedIsFalse() { // Arrange var project = MockProjectUtility.CreateMockProject("A"); var node = new ProjectNode(project); // Act node.IsSelected = false; // Assert Assert.False(node.GetSelectedProjects().Any()); }
public void GetSelectedProjectReturnsProjectIfIsSelectedIsTrueAndIsEnabledIsTrue() { // Arrange var project = MockProjectUtility.CreateMockProject("A"); var node = new ProjectNode(project); // Act node.IsSelected = true; node.IsEnabled = true; // Assert Assert.Same(project, node.GetSelectedProjects().Single()); }
private FolderNode CreateFolderNode(string name = "A", ICollection <ProjectNodeBase> children = null) { if (children == null) { children = new List <ProjectNodeBase>(); for (int i = 0; i < 3; i++) { var project = MockProjectUtility.CreateMockProject("p" + i); var node = new ProjectNode(project); children.Add(node); } } return(new FolderNode(null, name, children)); }
public void ChangingIsSelectedPropertyRaisePropertyChangedEvent() { // Arrange var project = MockProjectUtility.CreateMockProject("A"); var node = new ProjectNode(project); bool called = false; node.PropertyChanged += (o, e) => { if (e.PropertyName == "IsSelected") { called = true; } }; // Act node.IsSelected = true; // Assert Assert.True(called); }
public void ParentNodeIsEnabledIfAtLeastOneChildrenIsEnabled() { // Arrange var children = new ProjectNode[3]; // make two children enabled, one disabled for (int i = 0; i < 3; i++) { var project = MockProjectUtility.CreateMockProject("p" + i); var node = new ProjectNode(project) { IsEnabled = i % 2 == 0 }; children[i] = node; } // Act var folder = new FolderNode(null, "A", children); // Assert Assert.True(folder.IsEnabled); }
public void ParentNodeIsDisabledIfAllChildrenAreDisabled() { // Arrange var children = new ProjectNode[3]; // disable all children for (int i = 0; i < 3; i++) { var project = MockProjectUtility.CreateMockProject("p" + i); var node = new ProjectNode(project) { IsEnabled = false }; children[i] = node; } // Act var folder = new FolderNode(null, "A", children); // Assert Assert.False(folder.IsEnabled); }
public void GetSelectedProjectReturnsEmptyIfIsSelectedIsFalseOrIsEnabledIsFalse() { // Arrange var project = MockProjectUtility.CreateMockProject("A"); var node = new ProjectNode(project); // Act node.IsSelected = false; node.IsEnabled = false; var result1 = node.GetSelectedProjects(); node.IsSelected = true; node.IsEnabled = false; var result2 = node.GetSelectedProjects(); node.IsSelected = false; node.IsEnabled = true; var result3 = node.GetSelectedProjects(); // Assert Assert.False(result1.Any()); Assert.False(result2.Any()); Assert.False(result3.Any()); }