public void ShouldDeleteChangedFields()
		{
			ICategoryRepository categoryRepository;
			IPostRepository postRepository;
			IMemento newState;
			IMemento oldState;
			const string categoryName = "category";

			using (Mocks.Record())
			{
				oldState = Mocks.StrictMock<IMemento>();
				Expect.Call(oldState.CategoryName).Return(categoryName);
				Expect.Call(oldState.Fields).Repeat.AtLeastOnce().Return(new Dictionary<Guid, FieldInfo>
				                                                         {
				                                                         	{
				                                                         		new Guid("{28E2469B-E568-4406-832D-3AD3F1EBE214}"),
				                                                         		new FieldInfo("oldFieldName",
				                                                         		              FieldType.TextBox,
				                                                         		              "Description")
				                                                         		}
				                                                         });

				newState = Mocks.StrictMock<IMemento>();
				Expect.Call(newState.CategoryName).Return(categoryName);
				Expect.Call(newState.Fields).Repeat.AtLeastOnce().Return(new Dictionary<Guid, FieldInfo>
				                                                         {
				                                                         	{
				                                                         		new Guid("{28E2469B-E568-4406-832D-3AD3F1EBE214}"),
				                                                         		new FieldInfo("newFieldName",
				                                                         		              FieldType.TextBox,
				                                                         		              "Description")
				                                                         		}
				                                                         });

				categoryRepository = Mocks.StrictMock<ICategoryRepository>();
				Category targetCategory = new Category { Id = int.MaxValue, Name = categoryName };
				Expect.Call(categoryRepository.GetCategory(categoryName)).Repeat.AtLeastOnce().Return(targetCategory);

				CustomFormSettings formSettings = new CustomFormSettings();
				formSettings.Fields = new List<CustomField>();
				Expect.Call(categoryRepository.GetFormSettings(categoryName)).Repeat.AtLeastOnce().Return(formSettings);

				categoryRepository.AddField(null, null);
				LastCall.Constraints(Is.Same(formSettings), Is.Matching((CustomField f) => f.Name == "newFieldName"));

				categoryRepository.DeleteField(null, null);
				LastCall.Constraints(Is.Same(formSettings), Is.Equal("oldFieldName"));

				// No posts to migrate.
				postRepository = Mocks.StrictMock<IPostRepository>();
				Expect.Call(postRepository.GetByCategory(categoryName)).Return(new PostCollection());
			}

			using (Mocks.Playback())
			{
				Migrator fm = new Migrator(categoryRepository, postRepository);
				fm.Migrate(new MigrationInfo(oldState, newState));
			}
		}
		public void CreatesNewCategoryAndDeletesOldCategoryIfCategoryNameChanges()
		{
			ICategoryRepository categoryRepository;
			IPostRepository postRepository;
			IMemento newState;
			IMemento oldState;
			const string sourceCategoryName = "old";
			const string targetCategoryName = "new";

			using (Mocks.Record())
			{
				oldState = Mocks.StrictMock<IMemento>();
				Expect.Call(oldState.CategoryName).Return(sourceCategoryName);
				Expect.Call(oldState.Fields).Return(new Dictionary<Guid, FieldInfo>());

				newState = Mocks.StrictMock<IMemento>();
				Expect.Call(newState.CategoryName).Return(targetCategoryName);
				Expect.Call(newState.Fields).Return(new Dictionary<Guid, FieldInfo>());

				categoryRepository = Mocks.StrictMock<ICategoryRepository>();
				Expect.Call(categoryRepository.GetCategory(targetCategoryName)).Return(null);

				Category targetCategory = new Category { Id = int.MaxValue, Name = targetCategoryName };
				Expect.Call(categoryRepository.GetCategory(targetCategoryName)).Return(targetCategory);

				categoryRepository.AddCategory(null);
				LastCall.Constraints(Is.Matching((Category category) => category.Name == targetCategoryName));

				categoryRepository.DeleteCategory(null);
				LastCall.Constraints(Is.Equal(sourceCategoryName));

				// No posts to migrate.
				postRepository = Mocks.StrictMock<IPostRepository>();
				Expect.Call(postRepository.GetByCategory(sourceCategoryName)).Return(new PostCollection());
			}

			using (Mocks.Playback())
			{
				Migrator fm = new Migrator(categoryRepository, postRepository);
				fm.Migrate(new MigrationInfo(oldState, newState));
			}
		}