PageRenderTime 40ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/V4/PrismLibrary/Desktop/Prism.Tests/Mocks/MockCommand.cs

#
C# | 51 lines | 30 code | 5 blank | 16 comment | 2 complexity | f40daa8eca4384cfad0ade932ffbb326 MD5 | raw file
  1. //===================================================================================
  2. // Microsoft patterns & practices
  3. // Composite Application Guidance for Windows Presentation Foundation and Silverlight
  4. //===================================================================================
  5. // Copyright (c) Microsoft Corporation. All rights reserved.
  6. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
  7. // OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
  8. // LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  9. // FITNESS FOR A PARTICULAR PURPOSE.
  10. //===================================================================================
  11. // The example companies, organizations, products, domain names,
  12. // e-mail addresses, logos, people, places, and events depicted
  13. // herein are fictitious. No association with any real company,
  14. // organization, product, domain name, email address, logo, person,
  15. // places, or events is intended or should be inferred.
  16. //===================================================================================
  17. using System;
  18. using System.Windows.Input;
  19. namespace Microsoft.Practices.Prism.Tests.Mocks
  20. {
  21. internal class MockCommand : ICommand
  22. {
  23. public bool ExecuteCalled { get; set; }
  24. public bool CanExecuteReturnValue = true;
  25. public object ExecuteParameter;
  26. public object CanExecuteParameter;
  27. public int CanExecuteTimesCalled;
  28. public event EventHandler CanExecuteChanged;
  29. public void Execute(object parameter)
  30. {
  31. ExecuteCalled = true;
  32. ExecuteParameter = parameter;
  33. }
  34. public bool CanExecute(object parameter)
  35. {
  36. CanExecuteTimesCalled++;
  37. CanExecuteParameter = parameter;
  38. return CanExecuteReturnValue;
  39. }
  40. public void RaiseCanExecuteChanged()
  41. {
  42. if (this.CanExecuteChanged != null)
  43. this.CanExecuteChanged(this, EventArgs.Empty);
  44. }
  45. }
  46. }