Click here to Skip to main content
15,885,546 members
Articles / Desktop Programming / WPF

Catel - Part 4 of n: Unit testing with Catel

Rate me:
Please Sign up or sign in to vote.
4.55/5 (10 votes)
28 Jan 2011CPOL11 min read 48.9K   572   11  
This article explains how to write unit tests for MVVM using Catel.
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="DataCommands.cs" company="Catel development team">
//   Copyright (c) 2008 - 2011 Catel development team. All rights reserved.
// </copyright>
// <summary>
//   Data commands class.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

using System.Windows.Input;

namespace Catel.Windows.Input
{
	/// <summary>
	/// Data commands class.
	/// </summary>
	public static class DataCommands
	{
		/// <summary>
		/// Constructor that initializes the commands.
		/// </summary>
		static DataCommands()
		{
			// Add
			InputGestureCollection addActionGestures = new InputGestureCollection();
			addActionGestures.Add(new KeyGesture(Key.Insert, ModifierKeys.Shift));
			Add = new RoutedUICommand(Properties.Resources.CommandDataAdd, "Add", typeof(DataCommands), addActionGestures);

			// AddAll
			AddAll = new RoutedUICommand(Properties.Resources.CommandDataAddAll, "AddAll", typeof(DataCommands));

			// Edit
			InputGestureCollection editActionGestures = new InputGestureCollection();
			editActionGestures.Add(new KeyGesture(Key.Enter, ModifierKeys.Alt));
			Edit = new RoutedUICommand(Properties.Resources.CommandDataEdit, "Edit", typeof(DataCommands), editActionGestures);

			// Remove
			InputGestureCollection removeActionGestures = new InputGestureCollection();
			removeActionGestures.Add(new KeyGesture(Key.Delete, ModifierKeys.Shift));
			Remove = new RoutedUICommand(Properties.Resources.CommandDataRemove, "Remove", typeof(DataCommands), removeActionGestures);

			// RemoveAll
			RemoveAll = new RoutedUICommand(Properties.Resources.CommandDataRemoveAll, "Submit", typeof(DataCommands));

			// Sort
			Sort = new RoutedUICommand(Properties.Resources.CommandDataSort, "Sort", typeof(DataCommands));

			// Synchronize
			Synchronize = new RoutedUICommand(Properties.Resources.CommandDataSynchronize, "Synchronize", typeof(DataCommands));

			// Revert
			Revert = new RoutedUICommand(Properties.Resources.CommandDataRevert, "Revert", typeof(DataCommands));

			// Submit
			InputGestureCollection submitActionGestures = new InputGestureCollection();
			submitActionGestures.Add(new KeyGesture(Key.Enter, ModifierKeys.Alt | ModifierKeys.Control));
			Submit = new RoutedUICommand(Properties.Resources.CommandDataSubmit, "Submit", typeof(DataCommands), submitActionGestures);
		}

		/// <summary>
		/// Start adding a new item or reference.
		/// </summary>
		public static RoutedUICommand Add { get; private set; }

		/// <summary>
		/// Start adding a new item or reference.
		/// </summary>
		public static RoutedUICommand AddAll { get; private set; }

		/// <summary>
		/// Remove a item or reference.
		/// </summary>
		public static RoutedUICommand Remove { get; private set; }

		/// <summary>
		/// Edit a item or change reference.
		/// </summary>
		public static RoutedUICommand RemoveAll { get; private set; }

		/// <summary>
		/// Edit a item or change reference.
		/// </summary>
		public static RoutedUICommand Edit { get; private set; }

		/// <summary>
		/// Sort.
		/// </summary>
		public static RoutedUICommand Sort { get; private set; }

		/// <summary>
		/// Synchronize data.
		/// </summary>
		public static RoutedUICommand Synchronize { get; private set; }

		/// <summary>
		/// Revert data.
		/// </summary>
		public static RoutedUICommand Revert { get; private set; }

		/// <summary>
		/// Submit.
		/// </summary>
		public static RoutedUICommand Submit { get; private set; }
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Netherlands Netherlands
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions