User: mzywitza
Date: 2010/01/05 10:12 AM
Added:
/ActiveRecord/trunk/src/Castle.ActiveRecord.Tests/PropertyAccessTests/
Project.cs, Task.cs, TestCases.cs
Modified:
/ActiveRecord/trunk/src/
Changes.txt
/ActiveRecord/trunk/src/Castle.ActiveRecord.Framework.Internal.Tests/Model/
PropertyAccessHelperTests.cs
/ActiveRecord/trunk/src/Castle.ActiveRecord.Tests/
Castle.ActiveRecord.Tests-vs2008.csproj
/ActiveRecord/trunk/src/Castle.ActiveRecord/Attributes/
PropertyAccess.cs
Log:
Added support for access="backfield" and access="readonly". Idea and
implementation by xtoff.
File Changes:
Directory: /ActiveRecord/trunk/src/Castle.ActiveRecord/Attributes/
==================================================================
File [modified]: PropertyAccess.cs
Delta lines: +12 -0
===================================================================
---
ActiveRecord/trunk/src/Castle.ActiveRecord.Framework.Internal.Tests/Model/PropertyAccessHelperTests.cs
2010-01-05 12:45:14 UTC (rev 6575)
+++
ActiveRecord/trunk/src/Castle.ActiveRecord.Framework.Internal.Tests/Model/PropertyAccessHelperTests.cs
2010-01-05 17:12:08 UTC (rev 6576)
@@ -32,6 +32,18 @@
}
[Test]
+ public void ReadOnly()
+ {
+ Assert.AreEqual("readonly",
PropertyAccessHelper.ToString(PropertyAccess.ReadOnly));
+ }
+
+ [Test]
+ public void AutomaticProperty()
+ {
+ Assert.AreEqual("backfield",
PropertyAccessHelper.ToString(PropertyAccess.AutomaticProperty));
+ }
+
+ [Test]
public void FieldCamelCase()
{
Directory: /ActiveRecord/trunk/src/Castle.ActiveRecord.Tests/
=============================================================
File [modified]: Castle.ActiveRecord.Tests-vs2008.csproj
Delta lines: +31 -0
===================================================================
---
ActiveRecord/trunk/src/Castle.ActiveRecord.Tests/PropertyAccessTests/Project.cs
(rev 0)
+++
ActiveRecord/trunk/src/Castle.ActiveRecord.Tests/PropertyAccessTests/Project.cs
2010-01-05 17:12:08 UTC (rev 6576)
@@ -0,0 +1,31 @@
+// Copyright 2004-2009 Castle Project - http://www.castleproject.org/
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace Castle.ActiveRecord.Tests.PropertyAccessTests
+{
+ using System.Collections.Generic;
+
+ [ActiveRecord]
+ public class Project : ActiveRecordBase<Project>
+ {
+ [PrimaryKey]
+ public int Id { get; protected set; }
+
+ [HasMany(Access = PropertyAccess.AutomaticProperty)]
+ public IList<Task> Tasks { get; set; }
+
+ [Property]
+ public string Name { get; set; }
+ }
+}
Directory:
/ActiveRecord/trunk/src/Castle.ActiveRecord.Framework.Internal.Tests/Model/
======================================================================================
File [modified]: PropertyAccessHelperTests.cs
Delta lines: +3 -0
===================================================================
---
ActiveRecord/trunk/src/Castle.ActiveRecord.Tests/Castle.ActiveRecord.Tests-vs2008.csproj
2010-01-05 12:45:14 UTC (rev 6575)
+++
ActiveRecord/trunk/src/Castle.ActiveRecord.Tests/Castle.ActiveRecord.Tests-vs2008.csproj
2010-01-05 17:12:08 UTC (rev 6576)
@@ -337,6 +337,9 @@
<Compile Include="Model\SimplePost.cs" />
<Compile Include="Model\SSAFEntity.cs" />
<Compile Include="NUnitInMemoryTest.cs" />
+ <Compile Include="PropertyAccessTests\Project.cs" />
+ <Compile Include="PropertyAccessTests\Task.cs" />
+ <Compile Include="PropertyAccessTests\TestCases.cs" />
<Compile Include="SimpleQueryWithParameterTypesTestCase.cs" />
<Compile Include="StatelessSessionScopeTestCase.cs" />
Directory:
/ActiveRecord/trunk/src/Castle.ActiveRecord.Tests/PropertyAccessTests/
=================================================================================
File [added]: Project.cs
Delta lines: +37 -0
===================================================================
---
ActiveRecord/trunk/src/Castle.ActiveRecord.Tests/PropertyAccessTests/Task.cs
(rev 0)
+++
ActiveRecord/trunk/src/Castle.ActiveRecord.Tests/PropertyAccessTests/Task.cs
2010-01-05 17:12:08 UTC (rev 6576)
@@ -0,0 +1,37 @@
+// Copyright 2004-2009 Castle Project - http://www.castleproject.org/
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace Castle.ActiveRecord.Tests.PropertyAccessTests
+{
+ using System;
+
+ [ActiveRecord]
+ public class Task : ActiveRecordBase<Task>
+ {
+ [PrimaryKey]
+ public int Id { get; protected set; }
+
+ [BelongsTo]
+ public Project Project { get; set; }
+
+ [Property]
+ public string Name { get; set; }
+
+ [Property]
+ public DateTime? ScheduledDate { get; set; }
+
+ [Property(Access=PropertyAccess.ReadOnly)]
+ public bool IsScheduled { get { return ScheduledDate != null; }
}
+ }
+}
File [added]: Task.cs
Delta lines: +59 -0
===================================================================
---
ActiveRecord/trunk/src/Castle.ActiveRecord.Tests/PropertyAccessTests/TestCases.cs
(rev 0)
+++
ActiveRecord/trunk/src/Castle.ActiveRecord.Tests/PropertyAccessTests/TestCases.cs
2010-01-05 17:12:08 UTC (rev 6576)
@@ -0,0 +1,60 @@
+// Copyright 2004-2009 Castle Project - http://www.castleproject.org/
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace Castle.ActiveRecord.Tests.PropertyAccessTests
+{
+ using System;
+ using NUnit.Framework;
+
+ [TestFixture]
+ class TestCases : NUnitInMemoryTest
+ {
+ public override Type[] GetTypes()
+ {
+ return new [] {typeof(Project), typeof(Task)};
+ }
+
+ [Test]
+ public void TasksCollectionIsCreated()
+ {
+ createSampleProject();
+
+ var project = Project.FindFirst();
+ Assert.That(project.Tasks, Is.Not.Null);
+ Assert.That(project.Tasks, Is.Not.Empty);
+ }
+
+ [Test]
+ public void IsScheduledIsSetInDatabase()
+ {
+ createSampleProject();
+ var tasks = Task.FindAllByProperty("IsScheduled", true);
+
+ Assert.That(tasks, Is.Not.Null);
+ Assert.That(tasks.Length, Is.EqualTo(1));
+ }
+
+ private void createSampleProject()
+ {
+ var project = new Project() {Name="Release AR"};
+ project.Save();
+
+ var task1 = new Task() {Name = "Create Tag", Project =
project};
+ var task2 = new Task() { Name = "Upload Zip", Project =
project, ScheduledDate = DateTime.Today.AddDays(7)};
+
+ task1.Save();
+ task2.Save();
+ }
+ }
File [added]: TestCases.cs
Delta lines: +1 -0
===================================================================
--- ActiveRecord/trunk/src/Changes.txt 2010-01-05 12:45:14 UTC (rev 6575)
+++ ActiveRecord/trunk/src/Changes.txt 2010-01-05 17:12:08 UTC (rev 6576)
@@ -3,6 +3,7 @@
- Updated NHibernate to to 2.1.4
- Updated Castle Core to 1.2
- Updated Castle DynamicProcy to 2.2
+- Added support for NHibernate's new access methods "readonly" and "backfield".
- Bugs fixed:
Directory: /ActiveRecord/trunk/src/
===================================
File [modified]: Changes.txt
Delta lines: +0 -0
===================================================================
--
You received this message because you are subscribed to the Google Groups
"Castle Project Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/castle-project-commits?hl=en.