Changed to use Authenticate asp.net event instead of Authorize
[castle.git] / ActiveRecord / Castle.ActiveRecord.Framework.Internal.Tests / SemanticCheckTestCase.cs
blob12ac833f7251d1bf2f5e2f877d52976eb77896b3
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.Framework.Internal.Tests
17 using NUnit.Framework;
19 using Castle.ActiveRecord.Framework.Internal.Tests.Model;
22 [TestFixture]
23 public class SemanticCheckTestCase : AbstractActiveRecordTest
25 [Test,Ignore("meta-type is optional")]
26 [ExpectedException(typeof(ActiveRecordException), "MetaType is a required attribute of AnyAttribute on Castle.ActiveRecord.Framework.Internal.Tests.Model.BadClassWithAnyAttribute.PaymentMethod.")]
27 public void UsingAnyWithoutSpecifyingTheMetaType()
29 ActiveRecordModelBuilder builder = new ActiveRecordModelBuilder();
30 ActiveRecordModel model = builder.Create(typeof(BadClassWithAnyAttribute));
31 Assert.IsNotNull(model);
33 Assert.IsNotNull(model);
35 SemanticVerifierVisitor semanticVisitor = new SemanticVerifierVisitor(builder.Models);
36 semanticVisitor.VisitNode(model);
39 [Test]
40 [ExpectedException( typeof(ActiveRecordException), "Unfortunatelly you can't have a discriminator class and a joined subclass at the same time - check type Castle.ActiveRecord.Framework.Internal.Tests.Model.Company" )]
41 public void JoinedAndDiscriminatorClass()
43 ActiveRecordStarter.Initialize( GetConfigSource(), typeof(Company) );
46 [Test]
47 [ExpectedException( typeof(ActiveRecordException) )]
48 public void VersionedTimestampedClass()
50 ActiveRecordStarter.Initialize( GetConfigSource(), typeof(VersionedTimestampedClass) );
53 [Test]
54 [ExpectedException( typeof(ActiveRecordException), "A type must declare a primary key. Check type Castle.ActiveRecord.Framework.Internal.Tests.Model.ClassWithoutPrimaryKey" )]
55 public void ClassWithoutPrimaryKey()
57 ActiveRecordStarter.Initialize( GetConfigSource(), typeof(ClassWithoutPrimaryKey) );
60 [Test]
61 [ExpectedException(typeof(ActiveRecordException), "Property Clazz must be virtual because class LazyClassWithoutVirtualPropertyOnBelongsTo support lazy loading [ActiveRecord(Lazy=true)]")]
62 public void LazyClassWithoutVirtualPropertyOnBelongsTo()
64 ActiveRecordStarter.Initialize(GetConfigSource(), typeof(LazyClassWithoutVirtualPropertyOnBelongsTo));
67 [Test]
68 [ExpectedException(typeof(ActiveRecordException), "You can't use [Property] on ClassWithBadMapping.ClassA because Castle.ActiveRecord.Framework.Internal.Tests.Model.ClassA is an active record class, did you mean to use BelongTo?")]
69 public void ClassThatMapAnotherActiveRecordClassAsAPropertyInsteadOfBelongsTo()
71 ActiveRecordStarter.Initialize(GetConfigSource(), typeof(ClassWithBadMapping), typeof(ClassA));
74 [Test]
75 [ExpectedException(typeof(ActiveRecordException), "To use type 'BadCompositeKey' as a composite id, you must implement Equals and GetHashCode.")]
76 public void ClassWithBadCompositeKey()
78 ActiveRecordStarter.Initialize(GetConfigSource(), typeof(ClassWithBadCompositeKey));
81 [Test]
82 [ExpectedException(typeof(ActiveRecordException), "You can't specify a PrimaryKeyAttribute in a joined subclass. Check type Castle.ActiveRecord.Framework.Internal.Tests.Model.JoinedSubClassWithPrimaryKey")]
83 public void JoinedClassWithPrimaryKey()
85 ActiveRecordStarter.Initialize(GetConfigSource(), typeof(BaseJoinedClass), typeof(JoinedSubClassWithPrimaryKey));