Validate() 공개 메소드

public Validate ( IEnumerable reporters, string &errors, string &warnings ) : void
reporters IEnumerable
errors string
warnings string
리턴 void
예제 #1
0
        public void Execute()
        {
            // validate all steps
            var validator = new Validator(_options);
            string errors;
            string warnings;
            // ReSharper disable RedundantEnumerableCastCall
            validator.Validate(_downMigrations.Concat(_upMigrations).Cast<IMigrationReporter>(), out errors, out warnings); // .Cast<IMigrationReporter>() is required for .NET 3.5
            // ReSharper restore RedundantEnumerableCastCall
            if (!string.IsNullOrEmpty(errors))
            {
                throw new InvalidOperationException("Cannot execute the migration(s) as there are validation errors:" + Environment.NewLine + errors);
            }
            if (!string.IsNullOrEmpty(warnings))
            {
                Log.Warning(warnings);
            }

            // execute all steps
            foreach (IMigrationStep step in _downMigrations)
            {
                ExecuteStep(step);
            }
            foreach (IMigrationStep step in _upMigrations)
            {
                ExecuteStep(step);
            }
        }
예제 #2
0
        public void Execute()
        {
            if (IsExecuted) throw new InvalidOperationException("Cannot execute the same batch twice.");
            IsExecuted = true;

            // validate all steps
            var validator = new Validator(_options);
            string errors;
            string warnings;
            // ReSharper disable RedundantEnumerableCastCall
            validator.Validate(_migrations.Cast<IMigrationReporter>(), out errors, out warnings); // .Cast<IMigrationReporter>() is required for .NET 3.5
            // ReSharper restore RedundantEnumerableCastCall
            if (!string.IsNullOrEmpty(errors))
            {
                throw new InvalidOperationException("Cannot execute the migration(s) as there are validation errors:" + Environment.NewLine + errors);
            }
            if (!string.IsNullOrEmpty(warnings))
            {
                Log.Warning(warnings);
            }

            // execute all steps
            foreach (IMigrationStep step in _migrations)
            {
                ExecuteStep(step);
            }

            Debug.Assert(IsExecuted, "At the end of this method _isExecuted must be true.");
        }
예제 #3
0
 private static void Validate(MigrationOptions options, IMigrationReport report, out string errors, out string warnings)
 {
     var validator = new Validator(options);
     IMigrationReporter reporter = MockRepository.GenerateStub<IMigrationReporter>();
     reporter.Expect(r => r.Report(null)).IgnoreArguments().Return(report);
     IMigrationReporter[] reporters = new[] { reporter };
     validator.Validate(reporters, out errors, out warnings);
 }
예제 #4
0
 private static void Validate(IEnumerable<ProviderInfo> providerInfos, MigrationOptions options, IMigrationReport report, out string errors, out string warnings)
 {
     var validator = new Validator(providerInfos, options);
     IMigrationReporter reporter = A.Fake<IMigrationReporter>();
     A.CallTo(() => reporter.Report(A<IMigrationContext>._)).Returns(report);
     IMigrationReporter[] reporters = new[] { reporter };
     validator.Validate(reporters, out errors, out warnings);
 }