public void DefaultConstructor() { var command = new NavigationRequestCommand <string>(); var actionMock = new Mock <INavigationAction>(); command.NavigationAction = actionMock.Object; var parameter = "Hello, Parameter!"; Assert.True(command.CanExecute()); Assert.True(command.CanExecute(parameter)); Assert.True(command.CanExecute((object)parameter)); Assert.True(command.CanExecute(new object())); command.Execute(); actionMock.Verify(m => m.Navigate <string>(null), Times.Once); command.Execute(new object()); actionMock.Verify(m => m.Navigate <string>(null), Times.Exactly(2)); command.Execute(parameter); actionMock.Verify(m => m.Navigate(parameter), Times.Once); command.Execute((object)parameter); actionMock.Verify(m => m.Navigate(parameter), Times.Exactly(2)); }
public void DefaultConstructor() { var command = new NavigationRequestCommand(); var actionMock = new Mock <INavigationAction>(); command.NavigationAction = actionMock.Object; Assert.True(command.CanExecute(new object())); command.Execute(new object()); actionMock.Verify(m => m.Navigate <object>(null), Times.Once); }
public void Constructor_WithActionAndFunc() { string funcParameter = null; var command = new NavigationRequestCommand <string>(_ => { }, args => { funcParameter = args; return(false); }); var parameter = "Hello, Parameter!"; Assert.False(command.CanExecute(parameter)); Assert.Equal(parameter, funcParameter); }
public void Constructor_WithNonParameterActionAndFunc() { var called = false; var command = new NavigationRequestCommand <string>(() => called = true, () => true); var actionMock = new Mock <INavigationAction>(); command.NavigationAction = actionMock.Object; Assert.True(command.CanExecute()); command.Execute(); actionMock.Verify(m => m.Navigate((object)null), Times.Once); Assert.True(called); }
public void Constructor_WithAction() { string actionParameter = null; var command = new NavigationRequestCommand <string>(args => actionParameter = args); var actionMock = new Mock <INavigationAction>(); command.NavigationAction = actionMock.Object; Assert.True(command.CanExecute()); var parameter = "Hello, Parameter!"; command.Execute(parameter); actionMock.Verify(m => m.Navigate(parameter), Times.Once); Assert.Equal(parameter, actionParameter); }
public void Constructor_WithAction() { var called = false; var command = new NavigationRequestCommand(() => called = true); var actionMock = new Mock <INavigationAction>(); command.NavigationAction = actionMock.Object; Assert.True(command.CanExecute(new object())); var parameter = new object(); command.Execute(parameter); actionMock.Verify(m => m.Navigate((object)null), Times.Once); Assert.True(called); }
public void Constructor_WithActionAndFunc() { var command = new NavigationRequestCommand(() => { }, () => false); Assert.False(command.CanExecute(new object())); }