Changed to use Authenticate asp.net event instead of Authorize
[castle.git] / ActiveRecord / Castle.ActiveRecord.Tests / VerifyModelsAgainstDBSchemaTestCase.cs
bloba7ab4cf022a6c912b9d82420c7a0cfbb59dc9368
1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle.ActiveRecord.Tests
17 using Castle.ActiveRecord.Framework.Config;
18 using Framework;
19 using Model;
20 using NUnit.Framework;
22 [TestFixture]
23 public class VerifyModelsAgainstDBSchemaTestCase : AbstractActiveRecordTest
25 [Test, ExpectedExceptionAttribute(typeof(ActiveRecordException), "Error verifying the schema for model Post")]
26 public void VerificationOnWithMissingTableError()
28 XmlConfigurationSource config = (XmlConfigurationSource) GetConfigSource();
29 config.VerifyModelsAgainstDBSchema = true;
31 ActiveRecordStarter.Initialize(config, typeof(Post));
34 [Test,
35 ExpectedExceptionAttribute(typeof(ActiveRecordException),
36 "Error verifying the schema for model ModelClassWithBrokenField")]
37 public void VerificationOnWithMissingFieldError()
39 // Create the tables first
40 XmlConfigurationSource config = (XmlConfigurationSource) GetConfigSource();
41 config.VerifyModelsAgainstDBSchema = false;
42 ActiveRecordStarter.Initialize(config, typeof(ModelClassUsedToCreateTableForClassWithBrokenField));
43 Recreate();
45 // Then test Broken field
46 config.VerifyModelsAgainstDBSchema = true;
48 ActiveRecordStarter.ResetInitializationFlag();
49 ActiveRecordStarter.Initialize(config, typeof(ModelClassWithBrokenField));
52 [Test]
53 public void VerificationOnWithNoError()
55 // Create the tables first
56 XmlConfigurationSource config = (XmlConfigurationSource) GetConfigSource();
57 config.VerifyModelsAgainstDBSchema = false;
58 ActiveRecordStarter.Initialize(config, typeof(Blog), typeof(Post));
59 Recreate();
61 // Then run again with verification
62 config.VerifyModelsAgainstDBSchema = true;
63 ActiveRecordStarter.ResetInitializationFlag();
64 ActiveRecordStarter.Initialize(config, typeof(Blog), typeof(Post));
67 [Test]
68 public void VerificationOffWithMissingTableError()
70 XmlConfigurationSource config = (XmlConfigurationSource) GetConfigSource();
71 config.VerifyModelsAgainstDBSchema = false;
73 ActiveRecordStarter.Initialize(config, typeof(Post));
76 [Test]
77 public void VerificationOffWithMissingFieldError()
79 // Create the tables first
80 XmlConfigurationSource config = (XmlConfigurationSource) GetConfigSource();
81 config.VerifyModelsAgainstDBSchema = false;
82 ActiveRecordStarter.Initialize(config, typeof(ModelClassUsedToCreateTableForClassWithBrokenField));
83 Recreate();
85 // Then test Broken field
86 ActiveRecordStarter.ResetInitializationFlag();
87 ActiveRecordStarter.Initialize(config, typeof(ModelClassWithBrokenField));