public void EditCommandTest_NoSelectedDevice( ) { SUTest viewModel = new SUTest( ); viewModel.SelectedDevice = null; Microsoft.VisualStudio.TestPlatform.UnitTestFramework.Assert.IsFalse(viewModel.EditCommand.CanExecute(null)); }
public void EditCommandTest_SelectedDevice( ) { SUTest viewModel = new SUTest( ); var mockContext = new MockContext <DeviceViewModel>( ); var mockLabContext = new MockContext <Laboratory>( ); var device = new DeviceViewModelMock(mockContext, mockLabContext); viewModel.SelectedDevice = device; Microsoft.VisualStudio.TestPlatform.UnitTestFramework.Assert.IsTrue(viewModel.EditCommand.CanExecute(null)); }
public void SelectedDeviceChangedTest_ToNull( ) { SUTest viewModel = new SUTest( ); bool canExecuteChanged = false; viewModel.EditCommand.CanExecuteChanged += (object sender, EventArgs e) => { canExecuteChanged = true; }; viewModel.SelectedDevice = null; Microsoft.VisualStudio.TestPlatform.UnitTestFramework.Assert.IsFalse(canExecuteChanged); }
public void CreateRouterCommandTest( ) { SUTest viewModel = new SUTest( ); bool collectionChanged = false; viewModel.Lab.Devices.CollectionChanged += (object sender, NotifyCollectionChangedEventArgs e) => { Microsoft.VisualStudio.TestPlatform.UnitTestFramework.Assert.AreEqual(NotifyCollectionChangedAction.Add, e.Action); Microsoft.VisualStudio.TestPlatform.UnitTestFramework.Assert.AreEqual(1, e.NewItems.Count); Microsoft.VisualStudio.TestPlatform.UnitTestFramework.Assert.IsInstanceOfType(e.NewItems[0], typeof(RouterViewModel)); collectionChanged = true; }; viewModel.CreateRouterCommand.Execute(null); Microsoft.VisualStudio.TestPlatform.UnitTestFramework.Assert.IsTrue(collectionChanged); }
public void CreateEthernetLinkCommandTest( ) { SUTest viewModel = new SUTest( ); bool collectionChanged = false; viewModel.Lab.Links.CollectionChanged += (object sender, NotifyCollectionChangedEventArgs e) => { Microsoft.VisualStudio.TestPlatform.UnitTestFramework.Assert.AreEqual(NotifyCollectionChangedAction.Add, e.Action); Microsoft.VisualStudio.TestPlatform.UnitTestFramework.Assert.AreEqual(1, e.NewItems.Count); Microsoft.VisualStudio.TestPlatform.UnitTestFramework.Assert.IsInstanceOfType(e.NewItems[0], typeof(EthernetLinkViewModel)); collectionChanged = true; }; viewModel.CreateEthernetLinkCommand.Execute(null); Microsoft.VisualStudio.TestPlatform.UnitTestFramework.Assert.IsTrue(collectionChanged); }
public void SelectedDeviceChangedTest_ToObject( ) { SUTest viewModel = new SUTest( ); bool canExecuteChanged = false; viewModel.EditCommand.CanExecuteChanged += (object sender, EventArgs e) => { canExecuteChanged = true; }; var mockContext = new MockContext <DeviceViewModel>( ); var mockLabContext = new MockContext <Laboratory>( ); var device = new DeviceViewModelMock(mockContext, mockLabContext); viewModel.SelectedDevice = device; Microsoft.VisualStudio.TestPlatform.UnitTestFramework.Assert.IsTrue(canExecuteChanged); }
public void SelectedDeviceChangedTest_ToObject( ) { SUTest viewModel = new SUTest( ); bool canExecuteChanged = false; viewModel.EditCommand.CanExecuteChanged += (object sender, EventArgs e) => { canExecuteChanged = true; }; var mockContext = new MockContext<DeviceViewModel>( ); var mockLabContext = new MockContext<Laboratory>( ); var device = new DeviceViewModelMock(mockContext, mockLabContext); viewModel.SelectedDevice = device; Microsoft.VisualStudio.TestPlatform.UnitTestFramework.Assert.IsTrue(canExecuteChanged); }
public void EditCommandTest_SelectedDevice( ) { SUTest viewModel = new SUTest( ); var mockContext = new MockContext<DeviceViewModel>( ); var mockLabContext = new MockContext<Laboratory>( ); var device = new DeviceViewModelMock(mockContext, mockLabContext); viewModel.SelectedDevice = device; Microsoft.VisualStudio.TestPlatform.UnitTestFramework.Assert.IsTrue(viewModel.EditCommand.CanExecute(null)); }