[tasque] Fix and enable libtasque tests



commit 8b71d2b57047efb4a5c6e5528ea639dcafabfab9
Author: Antonius Riha <antoniusriha gmail com>
Date:   Wed Mar 20 17:29:50 2013 +0100

    Fix and enable libtasque tests

 tests/libtasque.Test/Core/Impl/TaskTest.cs         |    4 +-
 .../Core/Impl/TasqueContainerObject.cs             |   39 ++++++++++++++++++++
 .../Core/Impl/TasqueObjectCollectionSharingTest.cs |    9 ++---
 .../Core/Impl/TasqueObjectCollectionTest.cs        |   22 +++++------
 tests/libtasque.Test/Core/Impl/TasqueObjectTest.cs |   21 +++++------
 tests/libtasque.Test/libtasque.Test.csproj         |   15 ++++----
 6 files changed, 71 insertions(+), 39 deletions(-)
---
diff --git a/tests/libtasque.Test/Core/Impl/TaskTest.cs b/tests/libtasque.Test/Core/Impl/TaskTest.cs
index 53be56c..ed29450 100644
--- a/tests/libtasque.Test/Core/Impl/TaskTest.cs
+++ b/tests/libtasque.Test/Core/Impl/TaskTest.cs
@@ -64,9 +64,9 @@ namespace Tasque.Core.Impl
                        Assert.AreEqual (TaskRepoMock.Object, Task.Repository, "#A1");
                        Assert.IsNull (Task.Id, "#A2");
                        Assert.AreEqual (InitialText, Task.Text, "#A3");
-                       Assert.IsEmpty (((IInternalContainee<TaskList>)Task)
+                       Assert.IsEmpty (((IInternalContainee<TaskList, Task>)Task)
                                        .InternalContainers, "#A4");
-                       Assert.IsEmpty (((IInternalContainee<Task>)Task)
+                       Assert.IsEmpty (((IInternalContainee<Task, Task>)Task)
                                        .InternalContainers, "#A5");
                        Assert.IsTrue (Task.IsBackendDetached, "#A6");
                        Assert.AreEqual (DateTime.MinValue, Task.DueDate, "#A7");
diff --git a/tests/libtasque.Test/Core/Impl/TasqueContainerObject.cs 
b/tests/libtasque.Test/Core/Impl/TasqueContainerObject.cs
new file mode 100644
index 0000000..dcd5a7b
--- /dev/null
+++ b/tests/libtasque.Test/Core/Impl/TasqueContainerObject.cs
@@ -0,0 +1,39 @@
+//
+// TasqueContainerObject.cs
+//
+// Author:
+//       Antonius Riha <antoniusriha gmail com>
+//
+// Copyright (c) 2013 Antonius Riha
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System.Collections.Generic;
+using Tasque.Data;
+
+namespace Tasque.Core.Impl
+{
+       using IContainerRepo = ICollectionRepository<ITasqueCore, ITasqueCore>;
+
+       public abstract class TasqueContainerObject
+               : TasqueObject<IContainerRepo>, IContainer<ITasqueObject>
+       {
+               public TasqueContainerObject (IContainerRepo repo) : base (repo) {}
+               public abstract IEnumerable<ITasqueObject> Items { get; }
+       }
+}
diff --git a/tests/libtasque.Test/Core/Impl/TasqueObjectCollectionSharingTest.cs 
b/tests/libtasque.Test/Core/Impl/TasqueObjectCollectionSharingTest.cs
index b252012..bff6240 100644
--- a/tests/libtasque.Test/Core/Impl/TasqueObjectCollectionSharingTest.cs
+++ b/tests/libtasque.Test/Core/Impl/TasqueObjectCollectionSharingTest.cs
@@ -31,11 +31,8 @@ using Tasque.Data;
 namespace Tasque.Core.Impl
 {
        using IContainerRepo = ICollectionRepository<ITasqueCore, ITasqueCore>;
-       using Container =
-               TasqueObject<ICollectionRepository<ITasqueCore, ITasqueCore>>;
-       using TasqueCollection = TasqueObjectCollection<ITasqueCore,
-       TasqueObject<ICollectionRepository<ITasqueCore, ITasqueCore>>,
-       ICollectionRepository<ITasqueCore, ITasqueCore>>;
+       using TasqueCollection = TasqueObjectCollection<ITasqueCore, ITasqueObject,
+               TasqueContainerObject, ICollectionRepository<ITasqueCore, ITasqueCore>>;
 
        [TestFixture]
        public class TasqueObjectCollectionSharingTest
@@ -58,7 +55,7 @@ namespace Tasque.Core.Impl
 
                }
 
-               Mock<Container> container;
+               Mock<TasqueContainerObject> container;
                Mock<IContainerRepo> containerRepo;
                TasqueCollection collection;
        }
diff --git a/tests/libtasque.Test/Core/Impl/TasqueObjectCollectionTest.cs 
b/tests/libtasque.Test/Core/Impl/TasqueObjectCollectionTest.cs
index a0a8d03..9524de8 100644
--- a/tests/libtasque.Test/Core/Impl/TasqueObjectCollectionTest.cs
+++ b/tests/libtasque.Test/Core/Impl/TasqueObjectCollectionTest.cs
@@ -31,11 +31,8 @@ using Tasque.Data;
 namespace Tasque.Core.Impl
 {
        using IContainerRepo = ICollectionRepository<ITasqueCore, ITasqueCore>;
-       using Container =
-               TasqueObject<ICollectionRepository<ITasqueCore, ITasqueCore>>;
-       using TasqueCollection = TasqueObjectCollection<ITasqueCore,
-               TasqueObject<ICollectionRepository<ITasqueCore, ITasqueCore>>,
-               ICollectionRepository<ITasqueCore, ITasqueCore>>;
+       using TasqueCollection = TasqueObjectCollection<ITasqueObject, ITasqueCore,
+               TasqueContainerObject, ICollectionRepository<ITasqueCore, ITasqueCore>>;
 
        [TestFixture]
        public class TasqueObjectCollectionTest
@@ -43,19 +40,20 @@ namespace Tasque.Core.Impl
                [SetUp]
                public void Setup ()
                {
-                       containerRepo = new Mock<IContainerRepo> ();
-                       container = new Mock<Container> (containerRepo.Object) {
+                       containerRepoMock = new Mock<IContainerRepo> ();
+                       containerMock = new Mock<TasqueContainerObject> (
+                               containerRepoMock.Object) {
                                CallBase = true
                        };
-                       collection = new TasqueCollection (container.Object);
+                       collection = new TasqueCollection (containerMock.Object);
                }
 
                [Test]
                public void Add_CannotShareItemsWithOtherCollections ()
                {
-                       containerRepo.SetupGet (r => r
+                       containerRepoMock.SetupGet (r => r
                                .SupportsSharingItemsWithOtherCollections).Returns (false);
-                       var tasqueCoreMock = new Mock<ITasqueCore> ();
+                       var tasqueCoreMock = new Mock<ITasqueObject> ();
                        Assert.Throws<NotSupportedException> (delegate {
                                collection.Add (tasqueCoreMock.Object);
                        });
@@ -77,8 +75,8 @@ namespace Tasque.Core.Impl
 
                }
 
-               Mock<Container> container;
-               Mock<IContainerRepo> containerRepo;
+               Mock<TasqueContainerObject> containerMock;
+               Mock<IContainerRepo> containerRepoMock;
                TasqueCollection collection;
        }
 }
diff --git a/tests/libtasque.Test/Core/Impl/TasqueObjectTest.cs 
b/tests/libtasque.Test/Core/Impl/TasqueObjectTest.cs
index 0f6912a..d3122af 100644
--- a/tests/libtasque.Test/Core/Impl/TasqueObjectTest.cs
+++ b/tests/libtasque.Test/Core/Impl/TasqueObjectTest.cs
@@ -30,7 +30,6 @@ using Tasque.Data;
 
 namespace Tasque.Core.Impl
 {
-       using TasqueObject = TasqueObject<IRepository>;
        using TasqueObjectMock = Mock<TasqueObject<IRepository>>;
 
        [TestFixture]
@@ -73,7 +72,7 @@ namespace Tasque.Core.Impl
                        var curValue = "oldValue";
                        var repoMock = new Mock<IRepo> ();
                        Action<string> setVal = x => curValue = x;
-                       Func<TasqueObject, string, string> update
+                       Func<TasqueObject<IRepository>, string, string> update
                                = repoMock.Object.Update;
 
                        SetupNotifyEventsTest (tasqueObject, propertyName, "#A");
@@ -81,7 +80,7 @@ namespace Tasque.Core.Impl
                        var value = "newValue";
                        repoMock.Setup (r => r.Update (tasqueObject, value))
                                .Returns (value);
-                       tasqueObject.SetProperty<string, TasqueObject> (
+                       tasqueObject.SetProperty<string, TasqueObject<IRepository>> (
                                propertyName, value, curValue, setVal, update);
                        repoMock.Verify (r => r.Update (tasqueObject, value),
                                         Times.Once (), "#B0");
@@ -90,7 +89,7 @@ namespace Tasque.Core.Impl
                        Assert.AreEqual (1, propChangedCount, "#B3");
 
                        // try setting the same value again
-                       tasqueObject.SetProperty<string, TasqueObject> (
+                       tasqueObject.SetProperty<string, TasqueObject<IRepository>> (
                                propertyName, value, curValue, setVal, update);
                        repoMock.Verify (r => r.Update (tasqueObject, value),
                                         Times.Once (), "#C0");
@@ -109,7 +108,7 @@ namespace Tasque.Core.Impl
                        var curValue = "oldValue";
                        var repoMock = new Mock<IRepo> ();
                        Action<string> setVal = x => curValue = x;
-                       Func<TasqueObject, string, string> update
+                       Func<TasqueObject<IRepository>, string, string> update
                                = repoMock.Object.Update;
 
                        SetupNotifyEventsTest (tasqueObject, propertyName, "#A");
@@ -119,7 +118,7 @@ namespace Tasque.Core.Impl
                        var changedNewValue = newValue.Replace ("'", "\\'");
                        repoMock.Setup (r => r.Update (tasqueObject, newValue))
                                .Returns (changedNewValue);
-                       tasqueObject.SetProperty<string, TasqueObject> (
+                       tasqueObject.SetProperty<string, TasqueObject<IRepository>> (
                                propertyName, newValue, curValue, setVal, update);
                        repoMock.Verify (r => r.Update (tasqueObject, newValue),
                                         Times.Once (), "#B0");
@@ -128,7 +127,7 @@ namespace Tasque.Core.Impl
                        Assert.AreEqual (1, propChangedCount, "#B3");
                        
                        // setting a new value that is changed to the old value by the repo
-                       tasqueObject.SetProperty<string, TasqueObject> (
+                       tasqueObject.SetProperty<string, TasqueObject<IRepository>> (
                                propertyName, newValue, curValue, setVal, update);
                        repoMock.Verify (r => r.Update (tasqueObject, newValue),
                                         Times.Exactly (2), "#C0");
@@ -147,14 +146,14 @@ namespace Tasque.Core.Impl
                        var curValue = "oldValue";
                        var repoMock = new Mock<IRepo> ();
                        Action<string> setVal = x => curValue = x;
-                       Func<TasqueObject, string, string> update
+                       Func<TasqueObject<IRepository>, string, string> update
                                = repoMock.Object.Update;
                        
                        SetupNotifyEventsTest (tasqueObject, propertyName, "#A");
 
                        var newValue = "value 378";
                        repoMock.Setup (r => r.Update (tasqueObject, newValue));
-                       tasqueObject.SetProperty<string, TasqueObject> (
+                       tasqueObject.SetProperty<string, TasqueObject<IRepository>> (
                                propertyName, newValue, curValue, setVal, update);
                        repoMock.Verify (r => r.Update (tasqueObject, newValue),
                                         Times.Never (), "#B0");
@@ -163,7 +162,7 @@ namespace Tasque.Core.Impl
                        Assert.AreEqual (1, propChangedCount, "#B3");
                }
 
-               void SetupNotifyEventsTest (TasqueObject tasqueObject,
+               void SetupNotifyEventsTest (TasqueObject<IRepository> tasqueObject,
                        string propertyName, string msgPrefix)
                {
                        tasqueObject.PropertyChanging += (sender, e) => {
@@ -186,7 +185,7 @@ namespace Tasque.Core.Impl
 
                public interface IRepo
                {
-                       string Update (TasqueObject obj, string value);
+                       string Update (TasqueObject<IRepository> obj, string value);
                }
        }
 }
diff --git a/tests/libtasque.Test/libtasque.Test.csproj b/tests/libtasque.Test/libtasque.Test.csproj
index 718413a..1f84a2f 100644
--- a/tests/libtasque.Test/libtasque.Test.csproj
+++ b/tests/libtasque.Test/libtasque.Test.csproj
@@ -32,7 +32,14 @@
     <Reference Include="System.Core" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="Core\Impl\TasqueObjectTest.cs" />
     <Compile Include="Core\Impl\NoteTest.cs" />
+    <Compile Include="Core\Impl\TasqueObjectCollectionTest.cs" />
+    <Compile Include="Core\Impl\TasqueObjectCollectionSharingTest.cs" />
+    <Compile Include="Core\Impl\TasqueContainerObject.cs" />
+    <Compile Include="Core\Impl\TaskTest.cs" />
+    <Compile Include="Core\Impl\TaskBackendDetachedTest.cs" />
+    <Compile Include="Core\Impl\TaskBackendAttachedTest.cs" />
   </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
   <ItemGroup>
@@ -46,12 +53,4 @@
     <Folder Include="Core\Impl\" />
     <Folder Include="Data\" />
   </ItemGroup>
-  <ItemGroup>
-    <None Include="Core\Impl\TaskBackendAttachedTest.cs" />
-    <None Include="Core\Impl\TaskBackendDetachedTest.cs" />
-    <None Include="Core\Impl\TaskTest.cs" />
-    <None Include="Core\Impl\TasqueObjectTest.cs" />
-    <None Include="Core\Impl\TasqueObjectCollectionTest.cs" />
-    <None Include="Core\Impl\TasqueObjectCollectionSharingTest.cs" />
-  </ItemGroup>
 </Project>
\ No newline at end of file


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]