public void Test_CanExecuteChanged_CollectionCleared() { // Arrange. var parent = new TestParent(); var child1 = new TestItem(); var child2 = new TestItem(); var command = Command.For(parent) .DependsOnCollection(p => p.Items) .Where(p => p.DependentBoolValue) .DependsOn(c => c.BoolValue) .Executes(() => { }); parent.Items.Add(child1); parent.Items.Add(child2); // Act/Assert. parent.Items.Clear(); foreach (var child in new [] { child1, child2 }) { var localChild = child; AssertThat.DoesNotRaise(command, c => c.CanExecuteChanged += null, () => localChild.BoolValue = true); } }
public void Test_CanExecuteChanged_DifferentProperty() { // Arrange. var propertyOwner = new TestClass(); var command = Command.For(propertyOwner) .DependsOn(p => p.BoolValue) .Executes(() => { }); // Act/Assert. AssertThat.DoesNotRaise(command, c => c.CanExecuteChanged += null, () => propertyOwner.BoolValue2 = true); }
public void Test_OnAfterOpenSolution() { // Act/Assert. int result = Int32.MinValue; AssertThat.DoesNotRaise <ISolutionMonitor>( monitor, sm => sm.SolutionChanged += null, () => result = monitor.OnAfterOpenSolution(null, 0)); Assert.Equal(VSConstants.S_OK, result); }
public void Test_PropertyNotChanged_CustomEquals() { // Arrange. var property = new Property <CustomEquals>("property", OnPropertyChanged) { Value = new CustomEquals(2) }; // Act/Assert. AssertThat.DoesNotRaise <INotifyPropertyChanged>( this, p => p.PropertyChanged += null, () => property.Value = new CustomEquals(0)); Assert.Equal(2, property.Value.Value); }
public void Test_PropertyNotChanged() { // Arrange. var property = new Property <int>("property", OnPropertyChanged) { Value = 5 }; // Act/Assert. AssertThat.DoesNotRaise <INotifyPropertyChanged>( this, p => p.PropertyChanged += null, () => property.Value = 5); Assert.Equal(5, property.Value); }
public void Test_CanExecuteChanged_ItemRemoved() { // Arrange. var parent = new TestParent(); var child = new TestItem(); parent.Items.Add(child); var command = Command.For(parent) .DependsOnCollection(p => p.Items) .When(c => c.Any(p => p.BoolValue)) .Executes(() => { }); // Act/Assert. parent.Items.Remove(child); AssertThat.DoesNotRaise(command, c => c.CanExecuteChanged += null, () => child.BoolValue = true); }
public void Test_File_Changed_When_File_Not_In_Solution() { // Arrange. var project = Mock.Of <IVsProject>(); var projectInfo = Mock.Of <IProjectInfo>(p => p.GetProjectItems() == new[] { @"C:\test1.ps1", @"C:\test2.ps1" } && p.IsPhysicalProject == true); InitializeWith(Proj(project, projectInfo)); // Act. AssertThat.DoesNotRaise <ITestContainerDiscoverer>(discoverer, d => d.TestContainersUpdated += null, () => fileWatcher.Raise(fw => fw.Changed += null, new FileSystemEventArgs(WatcherChangeTypes.Changed, @"C:\", "test3.ps1"))); var containers = discoverer.TestContainers.OrderBy(t => t.Source).ToList(); // Assert. Assert.Equal(2, containers.Count); Assert.Equal(@"C:\test1.ps1", containers[0].Source); Assert.Equal(@"C:\test2.ps1", containers[1].Source); }