protected override void Establish_context()
		{
			var categoryRepository = MockRepository.GenerateMock<ICategoryRepository>();
			_sut = new SettingsValidator(categoryRepository);

			categoryRepository.Stub(x => x.Exists(null))
				.IgnoreArguments()
				.Return(false);

			_settings = new Settings
			            {
			            	CategoryName = "talk category",
			            	YearQueryString = "year query string",
			            	DefaultMaximumNumberOfRegistrations = "100",
			            	CreateTargetCategoryAndFields = false
			            };
		}
		protected override void Because()
		{
			Settings = new Settings
			           {
			           	CategoryName = "talk category",
			           	YearQueryString = "year query string",
			           	DefaultMaximumNumberOfRegistrations = "42",
			           	CreateTargetCategoryAndFields = false,
			           	MigrateFieldValues = false,
						EarliestRegistration = "earliest",
						LatestRegistration = "latest"
			           };
			// TODO
			//					DateFormat = "dateFormat";
			//					DefaultLocation = "defaultLocation";
			//					DefaultRegistrationRecipient = "defaultRegistrationRecipient";
			//					EndDate = "endDateField";
			//					Location = "locationField";
			//					LocationUnknown = "locationUnknown";
			//					MaximumNumberOfRegistrations = "maximumNumberOfRegistrations";
			//					RegistrationList = "numberOfRegistrations";
			//					RegistrationMailSubject = "registrationMailSubject";
			//					RegistrationNeeded = "registrationNeeded";
			//					RegistrationRecipient = "registrationRecipient";
			//					ShortEndDateFormat = "shortDateFormat";
			//					Speaker = "speakerField";
			//					StartDate = "startDateField";
			//					UnknownText = "unknownText";
		}
		public override StatusType SetValues(HttpContext context, NameValueCollection nvc)
		{
			IMemento oldState;
			IMemento newState;

			Settings settings = new Settings();
			_settingsMapper.Map(nvc, settings);

			try
			{
				var validation = _settingsValidator.Validate(settings).Interpret();
				if (validation.Failed)
				{
					SetMessage(context, validation.Message);
					return validation.StatusType;
				}

				// Write back.
				oldState = CreateMemento();

				CategoryName = settings.CategoryName;
				StartDateField = settings.StartDate;
				EndDateField = settings.EndDate;
				SpeakerField = settings.Speaker;
				DateFormat = settings.DateFormat;
				ShortEndDateFormat = settings.ShortEndDateFormat;
				LocationField = settings.Location;
				UnknownText = settings.UnknownText;
				LocationUnknownField = settings.LocationUnknown;
				YearQueryString = settings.YearQueryString;
				DefaultLocation = settings.DefaultLocation;
				RegistrationNeededField = settings.RegistrationNeeded;
				RegistrationRecipientField = settings.RegistrationRecipient;
				DefaultRegistrationRecipient = settings.DefaultRegistrationRecipient;
				MaximumNumberOfRegistrationsField = settings.MaximumNumberOfRegistrations;
				DefaultMaximumNumberOfRegistrations = settings.DefaultMaximumNumberOfRegistrations;
				RegistrationListField = settings.RegistrationList;
				RegistrationMailSubject = settings.RegistrationMailSubject;
				EarliestRegistrationField = settings.EarliestRegistration;
				LatestRegistrationField = settings.LatestRegistration;

				newState = CreateMemento();
			}
			catch (Exception ex)
			{
				SetMessage(context, String.Format("Error: {0}", ex.Message));
				return StatusType.Error;
			}

			try
			{
				EnableEventHandlers = false;

				PluginMigrator.MigrateSettings(settings.CreateTargetCategoryAndFields,
				                               settings.MigrateFieldValues,
				                               newState,
				                               oldState);
				return StatusType.Success;
			}
			catch (Exception ex)
			{
				SetMessage(context, String.Format("Error while migrating category and fields: {0}", ex.Message));
				return StatusType.Error;
			}
			finally
			{
				EnableEventHandlers = true;
			}
		}