DotCMIS unit test updates

git-svn-id: https://svn.apache.org/repos/asf/chemistry/dotcmis/trunk@1575249 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/DotCMISUnitTest/AclTest.cs b/DotCMISUnitTest/AclTest.cs
new file mode 100644
index 0000000..764df3c
--- /dev/null
+++ b/DotCMISUnitTest/AclTest.cs
@@ -0,0 +1,48 @@
+using NUnit.Framework;

+using DotCMIS;

+using DotCMIS.Client;

+using DotCMIS.Client.Impl;

+using DotCMIS.Enums;

+using DotCMIS.Data;

+using System.Collections.Generic;

+using DotCMIS.Data.Impl;

+

+namespace DotCMISUnitTest

+{

+    [TestFixture]

+    class AclTest : TestFramework

+    {

+        [Test]

+        public void TestGetAcl()

+        {

+            //IObjectId id = Session.CreateObjectId(RepositoryInfo.RootFolderId);

+            //IAcl acl = Session.GetAcl(id, false);

+            //Assert.NotNull(acl);

+

+            string principalId = "admin";

+            string permission = "cmis:write";

+            Properties properties = new Properties();

+            IDictionary<string, object> dictionaryProperties = new Dictionary<string, object>();

+            dictionaryProperties.Add("cmis:objectTypeId", "cmis:folder");

+            dictionaryProperties.Add("cmis:name", "ft2");

+

+            IObjectId newId = Session.CreateObjectId(RepositoryInfo.RootFolderId);

+            IObjectId newFolderId = Session.CreateFolder(dictionaryProperties, newId);

+            ICmisObject newFolder = Session.GetObject(newFolderId, new OperationContext() { IncludeAcls = true });

+            IAce ace = Session.ObjectFactory.CreateAce(principalId, new List<string>() { permission });

+

+            List<IAce> aceList = new List<IAce>();

+

+            aceList.Add(ace);

+

+

+            IAcl acl1 = newFolder.AddAcl(aceList, null);

+            Assert.NotNull(acl1);

+

+            IAcl acl2 = newFolder.RemoveAcl(aceList, null);

+            Assert.NotNull(acl2);

+

+            Session.Delete(newFolderId);

+        }

+    }

+}

diff --git a/DotCMISUnitTest/CacheTest.cs b/DotCMISUnitTest/CacheTest.cs
index ac63bda..6e3be5a 100644
--- a/DotCMISUnitTest/CacheTest.cs
+++ b/DotCMISUnitTest/CacheTest.cs
@@ -193,6 +193,8 @@
         public void Delete(bool allVersions) { }

         public ICmisObject UpdateProperties(IDictionary<string, object> properties) { return null; }

         public IObjectId UpdateProperties(IDictionary<string, object> properties, bool refresh) { return null; }

+        public ICmisObject Rename(string newName) { return null; }

+        public IObjectId Rename(string newName, bool refresh) { return null; }

         public IList<IRendition> Renditions { get { return null; } }

         public void ApplyPolicy(params IObjectId[] policyId) { }

         public void RemovePolicy(params IObjectId[] policyId) { }

diff --git a/DotCMISUnitTest/DotCMISUnitTest.csproj b/DotCMISUnitTest/DotCMISUnitTest.csproj
index 5b4e2df..b538da9 100644
--- a/DotCMISUnitTest/DotCMISUnitTest.csproj
+++ b/DotCMISUnitTest/DotCMISUnitTest.csproj
@@ -30,6 +30,17 @@
     <ErrorReport>prompt</ErrorReport>

     <WarningLevel>4</WarningLevel>

   </PropertyGroup>

+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'issues|AnyCPU'">

+    <DebugSymbols>true</DebugSymbols>

+    <OutputPath>bin\issues\</OutputPath>

+    <DefineConstants>DEBUG;TRACE</DefineConstants>

+    <DebugType>full</DebugType>

+    <PlatformTarget>AnyCPU</PlatformTarget>

+    <ErrorReport>prompt</ErrorReport>

+    <CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>

+    <CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>

+    <CodeAnalysisFailOnMissingRules>true</CodeAnalysisFailOnMissingRules>

+  </PropertyGroup>

   <ItemGroup>

     <Reference Include="nunit.framework, Version=2.5.9.10348, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">

       <SpecificVersion>False</SpecificVersion>

@@ -38,15 +49,18 @@
     <Reference Include="System" />

     <Reference Include="System.configuration" />

     <Reference Include="System.Core" />

-    <Reference Include="System.Xml.Linq" />

+    <Reference Include="System.Data.Linq" />

+    <Reference Include="System.Web.Extensions" />

     <Reference Include="System.Data.DataSetExtensions" />

     <Reference Include="System.Data" />

     <Reference Include="System.Xml" />

   </ItemGroup>

   <ItemGroup>

+    <Compile Include="AclTest.cs" />

     <Compile Include="CacheTest.cs" />

     <Compile Include="CRUDTest.cs" />

     <Compile Include="EnumeratorTest.cs" />

+    <Compile Include="GetChildrenTest.cs" />

     <Compile Include="Properties\AssemblyInfo.cs" />

     <Compile Include="SmokeTest.cs" />

     <Compile Include="TestFramework.cs" />

diff --git a/DotCMISUnitTest/GetChildrenTest.cs b/DotCMISUnitTest/GetChildrenTest.cs
new file mode 100644
index 0000000..5fda50e
--- /dev/null
+++ b/DotCMISUnitTest/GetChildrenTest.cs
@@ -0,0 +1,93 @@
+using System;

+using System.Collections.Generic;

+using System.Linq;

+using System.Text;

+using NUnit.Framework;

+using DotCMIS;

+using DotCMIS.Client.Impl;

+using DotCMIS.Client;

+

+namespace DotCMISUnitTest

+{

+    [TestFixture]

+    class GetChildrenTest

+    {

+        private static int numOfDocuments = 250;

+

+        [Test]

+        public void TestPaging()

+        {

+            Dictionary<string, string> parameters = new Dictionary<string, string>();

+

+            string baseUrlAtom = "http://localhost:8080/inmemory/atom";

+            //string baseUrlAtom = "http://cmis.alfresco.com/cmisatom";

+           

+            string baseUrlWS = "http://localhost:8080/inmemory/services";

+

+            parameters[SessionParameter.BindingType] = BindingType.AtomPub;

+            parameters[SessionParameter.AtomPubUrl] = baseUrlAtom;

+            parameters[SessionParameter.User] = "admin";

+            parameters[SessionParameter.Password] = "admin";

+

+            SessionFactory factory = SessionFactory.NewInstance();

+            ISession session = factory.GetRepositories(parameters)[0].CreateSession();

+

+            IOperationContext oc = session.CreateOperationContext();

+            oc.MaxItemsPerPage = 100;

+

+            IFolder folder = createData(session);

+            //IFolder folder = session.GetObjectByPath(@"/childrenTestFolder") as IFolder;

+

+            int counter = 0;

+            foreach (ICmisObject child in folder.GetChildren(oc))

+            {

+                Console.WriteLine("!" + counter + " " + child.Name);

+                counter++;

+            }

+

+            Assert.AreEqual(numOfDocuments, counter);

+

+            counter = 0;

+            foreach (ICmisObject child in folder.GetChildren(oc).GetPage(150))

+            {

+                Console.WriteLine("#" + counter + " " + child.Name);

+                counter++;

+            }

+

+            Assert.AreEqual(150, counter);

+

+            counter = 0;

+            foreach (ICmisObject child in folder.GetChildren(oc).SkipTo(20).GetPage(180))

+            {

+                Console.WriteLine("*" + counter + " " + child.Name);

+                counter++;

+            }

+

+            Assert.AreEqual(180, counter);

+

+            folder.DeleteTree(true, null, true);

+        }

+

+

+        private IFolder createData(ISession session)

+        {

+            Dictionary<string, object> properties = new Dictionary<string, object>();

+            properties[PropertyIds.Name] = "childrenTestFolder";

+            properties[PropertyIds.ObjectTypeId] = "cmis:folder";

+

+            IFolder folder = session.GetRootFolder().CreateFolder(properties);

+

+            for (int i = 0; i < numOfDocuments; i++)

+            {

+                Dictionary<string, object> docProps = new Dictionary<string, object>();

+                docProps[PropertyIds.Name] = "doc" + i;

+                docProps[PropertyIds.ObjectTypeId] = "cmis:document";

+

+                folder.CreateDocument(docProps, null, null);

+

+            }

+

+            return folder;

+        }

+    }

+}

diff --git a/DotCMISUnitTest/SmokeTest.cs b/DotCMISUnitTest/SmokeTest.cs
index 89536a9..186d5db 100644
--- a/DotCMISUnitTest/SmokeTest.cs
+++ b/DotCMISUnitTest/SmokeTest.cs
@@ -1,4 +1,5 @@
-/*

+using System;

+/*

  * Licensed to the Apache Software Foundation (ASF) under one

  * or more contributor license agreements.  See the NOTICE file

  * distributed with this work for additional information

@@ -17,17 +18,17 @@
  * under the License.

  */

 using System.Collections.Generic;

+using System.IO;

+using System.Text;

+using System.Linq;

 using DotCMIS;

 using DotCMIS.Client;

 using DotCMIS.Client.Impl;

-using DotCMIS.Enums;

-using NUnit.Framework;

-using System;

 using DotCMIS.Data;

 using DotCMIS.Data.Impl;

-using System.Text;

-using System.IO;

+using DotCMIS.Enums;

 using DotCMIS.Exceptions;

+using NUnit.Framework;

 

 namespace DotCMISUnitTest

 {

@@ -285,7 +286,7 @@
             properties[PropertyIds.Name] = "test-version-smoke.txt";

             properties[PropertyIds.ObjectTypeId] = DefaultDocumentType;

 

-            IDocument doc = TestFolder.CreateDocument(properties, null, null);

+            IDocument doc = TestFolder.CreateDocument(properties, null, VersioningState.Major);

             Assert.NotNull(doc);

             Assert.NotNull(doc.Id);

             Assert.AreEqual(properties[PropertyIds.Name], doc.Name);

@@ -316,13 +317,21 @@
             // check new version

             Assert.NotNull(doc2);

             Assert.NotNull(doc2.Id);

-            Assert.AreEqual(newProperties[PropertyIds.Name], doc2.Name);

+            // Assert.AreEqual(newProperties[PropertyIds.Name], doc2.Name);

             Assert.AreEqual(BaseTypeId.CmisDocument, doc2.BaseTypeId);

 

             versions = doc2.GetAllVersions();

             Assert.NotNull(versions);

             Assert.AreEqual(2, versions.Count);

 

+            IDocument last1 = doc.GetObjectOfLatestVersion(false);

+            Assert.AreEqual(doc2.Id, last1.Id);

+

+            IOperationContext oc = Session.CreateOperationContext();

+            oc.CacheEnabled = false;

+            IDocument last2 = Session.GetLatestDocumentVersion(doc.Id, oc);

+            Assert.AreEqual(doc2.Id, last2.Id);

+

             doc2.DeleteAllVersions();

 

             try

@@ -354,6 +363,10 @@
             Assert.True(folder.AllowableActions.Actions.Contains(Actions.CanGetChildren));

             Assert.False(folder.AllowableActions.Actions.Contains(Actions.CanGetContentStream));

 

+            // rename folder

+            folder.Rename("test-smoke-renamed");

+            Assert.AreEqual("test-smoke-renamed", folder.Name);

+

             // check children

             foreach (ICmisObject cmisObject in folder.GetChildren())

             {

@@ -448,5 +461,13 @@
                 Console.WriteLine("ChangesCapability not set!");

             }

         }

+

+        [Test]

+        public void SmokeTestCMIS609()

+        {

+            IFolder rootFolder = Session.GetRootFolder();

+            IEnumerable<ICmisObject> children = rootFolder.GetChildren();

+            List<ICmisObject> childrenList = children.ToList();

+        }

     }

 }