public void DoesNotRecreateExistingCategory()
        {
            ICategoryRepository categoryRepository;
            const string        categoryName = "existing";

            using (Mocks.Record())
            {
                categoryRepository = Mocks.StrictMock <ICategoryRepository>();
                Expect.Call(categoryRepository.GetCategory(categoryName)).Return(new Category());
            }

            using (Mocks.Playback())
            {
                Migrator fm = new Migrator(categoryRepository, new PostRepository());
                fm.EnsureTargetCategory(categoryName);
            }
        }
		public static void MigrateSettings(bool createTargetCategoryAndFields,
		                                   bool migrateFieldValues,
		                                   IMemento newState,
		                                   IMemento oldState)
		{
			Migrator migrator = new Migrator();

			if (createTargetCategoryAndFields)
			{
				migrator.EnsureTargetCategory(newState.CategoryName);
				migrator.EnsureFields(newState.CategoryName, new MigrationInfo(oldState, newState).AllFields);
			}

			if (migrateFieldValues)
			{
				migrator.Migrate(new MigrationInfo(oldState, newState));
			}
		}
Beispiel #3
0
        public static void MigrateSettings(bool createTargetCategoryAndFields,
                                           bool migrateFieldValues,
                                           IMemento newState,
                                           IMemento oldState)
        {
            Migrator migrator = new Migrator();

            if (createTargetCategoryAndFields)
            {
                migrator.EnsureTargetCategory(newState.CategoryName);
                migrator.EnsureFields(newState.CategoryName, new MigrationInfo(oldState, newState).AllFields);
            }

            if (migrateFieldValues)
            {
                migrator.Migrate(new MigrationInfo(oldState, newState));
            }
        }
        public void CreatesNewCategory()
        {
            ICategoryRepository categoryRepository;
            const string        categoryName = "new";

            using (Mocks.Record())
            {
                categoryRepository = Mocks.StrictMock <ICategoryRepository>();
                Expect.Call(categoryRepository.GetCategory(categoryName)).Return(null);

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

            using (Mocks.Playback())
            {
                Migrator fm = new Migrator(categoryRepository, new PostRepository());
                fm.EnsureTargetCategory(categoryName);
            }
        }