Added integration test
authorpkanavos <pkanavos@gmail.com>
Thu, 7 Jun 2012 19:48:30 +0000 (22:48 +0300)
committerpkanavos <pkanavos@gmail.com>
Thu, 7 Jun 2012 19:48:30 +0000 (22:48 +0300)
trunk/Pithos.IntegrationTests/FileCreationTest.cs [new file with mode: 0644]
trunk/Pithos.IntegrationTests/ObjectUtil.cs [new file with mode: 0644]
trunk/Pithos.IntegrationTests/Pithos.IntegrationTests.csproj [new file with mode: 0644]
trunk/Pithos.IntegrationTests/Properties/AssemblyInfo.cs [new file with mode: 0644]
trunk/Pithos.IntegrationTests/packages.config [new file with mode: 0644]
trunk/Pithos.sln
trunk/packages/repositories.config

diff --git a/trunk/Pithos.IntegrationTests/FileCreationTest.cs b/trunk/Pithos.IntegrationTests/FileCreationTest.cs
new file mode 100644 (file)
index 0000000..1365cfd
--- /dev/null
@@ -0,0 +1,103 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using NUnit.Framework;
+using Pithos.Network;
+
+namespace Pithos.IntegrationTests
+{
+    [TestFixture]
+    public class FileCreationTest
+    {
+        private const string RootPath = @"c:\p1\";
+        private const string PithosContainer = "pithos";
+        private DirectoryInfo _rootDir;
+        private CloudFilesClient _client;
+        private string _account = "";
+        private string _apiKey = "";
+
+        [SetUp]
+        public void Initialize()
+        {
+
+            var standardPaths = new[] {"pithos"};
+            _rootDir = new DirectoryInfo(RootPath);
+            _rootDir.EnumerateDirectories()
+                .Where(d=>!standardPaths.Contains(d.Name))
+                .All(d => { d.Delete(true); return true; });
+            _rootDir.EnumerateFiles().All(d => { d.Delete(); return true; });
+            _client = new CloudFilesClient(_account, _apiKey);
+        }
+
+        [Test]
+        public async void TestFileCreation()
+        {
+            var path=Path.Combine(RootPath,PithosContainer,"File1.txt");
+            File.WriteAllText(path,"TestContents");
+
+            await TaskEx.Delay(TimeSpan.FromSeconds(20));
+
+            var exists=_client.ObjectExists(_account, PithosContainer, "File1.txt");
+
+            Assert.That(exists,Is.True);
+
+
+        }
+
+        [Test]
+        public async void TestFileDeletion()
+        {
+            
+            var path=Path.Combine(RootPath,PithosContainer,"File1.txt");
+            if (!File.Exists(path))
+                File.WriteAllText(path,"TestContents");
+
+            await TaskEx.Delay(TimeSpan.FromSeconds(20));
+
+            var exists=_client.ObjectExists(_account, PithosContainer, "File1.txt");
+            Assert.That(exists,Is.True);
+
+            File.Delete(path);
+            
+            await TaskEx.Delay(TimeSpan.FromSeconds(20));
+            
+            var deleted= !_client.ObjectExists(_account, PithosContainer, "File1.txt");
+            Assert.That(deleted, Is.True);
+            _client.DeleteObject(_account, PithosContainer, "File1.txt");
+        }
+        
+        [Test]
+        public async void TestFileMove()
+        {
+            
+            var path=Path.Combine(RootPath,PithosContainer,"File1.txt");
+            var path2=Path.Combine(RootPath,PithosContainer,"File2.txt");
+            if (!File.Exists(path))
+                File.WriteAllText(path,"TestContents");
+
+            await TaskEx.Delay(TimeSpan.FromSeconds(20));
+
+            var exists=_client.ObjectExists(_account, PithosContainer, "File1.txt");
+            Assert.That(exists,Is.True);
+
+            File.Move(path,path2);
+            
+            await TaskEx.Delay(TimeSpan.FromSeconds(20));
+            
+            var sourceExists = _client.ObjectExists(_account, PithosContainer, "File1.txt");
+            Assert.That(sourceExists, Is.False);
+            
+            var targetExists = _client.ObjectExists(_account, PithosContainer, "File2.txt");
+            Assert.That(targetExists, Is.True);
+            
+            _client.DeleteObject(_account,PithosContainer,"File2.txt");
+            
+            var deleted= !_client.ObjectExists(_account, PithosContainer, "File2.txt");
+            Assert.That(deleted, Is.True);
+        }
+
+    }
+}
diff --git a/trunk/Pithos.IntegrationTests/ObjectUtil.cs b/trunk/Pithos.IntegrationTests/ObjectUtil.cs
new file mode 100644 (file)
index 0000000..1d0dfc8
--- /dev/null
@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Pithos.Network;
+
+namespace Pithos.IntegrationTests
+{
+    class ObjectUtil
+    {
+        public string Account { get; set; }
+        public string ApiKey { get; set; }
+        public string Container { get; set; }
+
+        public CloudFilesClient Client { get; private set; }
+
+        public ObjectUtil(string account,string container,string apiKey)
+        {
+            Account = account;
+            Container = container;
+            ApiKey = apiKey;
+            Client = new CloudFilesClient(Account, ApiKey);
+        }
+
+        public bool ObjectExists(string name)
+        {            
+            var exists=Client.ObjectExists(Account, Container, name);
+            return exists;
+        }
+
+        public bool ContainerExists(string name)
+        {
+            var exists=Client.ObjectExists(Account, Container, name);            
+            return exists;
+        }
+    }
+}
diff --git a/trunk/Pithos.IntegrationTests/Pithos.IntegrationTests.csproj b/trunk/Pithos.IntegrationTests/Pithos.IntegrationTests.csproj
new file mode 100644 (file)
index 0000000..abe9669
--- /dev/null
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>8.0.30703</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{86524E19-7C1C-4A90-93AA-2316A150DC52}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Pithos.IntegrationTests</RootNamespace>
+    <AssemblyName>Pithos.IntegrationTests</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="AsyncCtpLibrary">
+      <HintPath>..\Libraries\AsyncCtpLibrary.dll</HintPath>
+    </Reference>
+    <Reference Include="nunit.framework">
+      <HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll</HintPath>
+    </Reference>
+    <Reference Include="nunit.mocks">
+      <HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.mocks.dll</HintPath>
+    </Reference>
+    <Reference Include="pnunit.framework">
+      <HintPath>..\packages\NUnit.2.5.10.11092\lib\pnunit.framework.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="FileCreationTest.cs" />
+    <Compile Include="ObjectUtil.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="packages.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\Pithos.Network\Pithos.Network.csproj">
+      <Project>{C8E2BC8B-C7F1-4222-855C-4B04A57FFDFD}</Project>
+      <Name>Pithos.Network</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file
diff --git a/trunk/Pithos.IntegrationTests/Properties/AssemblyInfo.cs b/trunk/Pithos.IntegrationTests/Properties/AssemblyInfo.cs
new file mode 100644 (file)
index 0000000..b7cc025
--- /dev/null
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Pithos.IntegrationTests")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("HP")]
+[assembly: AssemblyProduct("Pithos.IntegrationTests")]
+[assembly: AssemblyCopyright("Copyright © HP 2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("562c74d7-4df5-42c9-92fc-ce5f833d66a2")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/trunk/Pithos.IntegrationTests/packages.config b/trunk/Pithos.IntegrationTests/packages.config
new file mode 100644 (file)
index 0000000..0c82178
--- /dev/null
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="NUnit" version="2.5.10.11092" />
+</packages>
\ No newline at end of file
index 7a456ce..c0e21e2 100644 (file)
@@ -45,6 +45,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pithos.Client.WPF.Test", "P
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pithos.Interfaces.Test", "Pithos.Interfaces.Test\Pithos.Interfaces.Test.csproj", "{881F7260-CA40-40FD-AEEC-860B346DC2DC}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pithos.IntegrationTests", "Pithos.IntegrationTests\Pithos.IntegrationTests.csproj", "{86524E19-7C1C-4A90-93AA-2316A150DC52}"
+EndProject
 Global
        GlobalSection(SolutionConfigurationPlatforms) = preSolution
                Debug All|Any CPU = Debug All|Any CPU
@@ -614,6 +616,37 @@ Global
                {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Test|Mixed Platforms.Build.0 = Release|Any CPU
                {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Test|x64.ActiveCfg = Release|Any CPU
                {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Test|x86.ActiveCfg = Release|Any CPU
+               {86524E19-7C1C-4A90-93AA-2316A150DC52}.Debug All|Any CPU.ActiveCfg = Debug|Any CPU
+               {86524E19-7C1C-4A90-93AA-2316A150DC52}.Debug All|Any CPU.Build.0 = Debug|Any CPU
+               {86524E19-7C1C-4A90-93AA-2316A150DC52}.Debug All|Mixed Platforms.ActiveCfg = Debug|Any CPU
+               {86524E19-7C1C-4A90-93AA-2316A150DC52}.Debug All|Mixed Platforms.Build.0 = Debug|Any CPU
+               {86524E19-7C1C-4A90-93AA-2316A150DC52}.Debug All|x64.ActiveCfg = Debug|Any CPU
+               {86524E19-7C1C-4A90-93AA-2316A150DC52}.Debug All|x86.ActiveCfg = Debug|Any CPU
+               {86524E19-7C1C-4A90-93AA-2316A150DC52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+               {86524E19-7C1C-4A90-93AA-2316A150DC52}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {86524E19-7C1C-4A90-93AA-2316A150DC52}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+               {86524E19-7C1C-4A90-93AA-2316A150DC52}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+               {86524E19-7C1C-4A90-93AA-2316A150DC52}.Debug|x64.ActiveCfg = Debug|Any CPU
+               {86524E19-7C1C-4A90-93AA-2316A150DC52}.Debug|x64.Build.0 = Debug|Any CPU
+               {86524E19-7C1C-4A90-93AA-2316A150DC52}.Debug|x86.ActiveCfg = Debug|Any CPU
+               {86524E19-7C1C-4A90-93AA-2316A150DC52}.Premium Debug|Any CPU.ActiveCfg = Debug|Any CPU
+               {86524E19-7C1C-4A90-93AA-2316A150DC52}.Premium Debug|Any CPU.Build.0 = Debug|Any CPU
+               {86524E19-7C1C-4A90-93AA-2316A150DC52}.Premium Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+               {86524E19-7C1C-4A90-93AA-2316A150DC52}.Premium Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+               {86524E19-7C1C-4A90-93AA-2316A150DC52}.Premium Debug|x64.ActiveCfg = Debug|Any CPU
+               {86524E19-7C1C-4A90-93AA-2316A150DC52}.Premium Debug|x86.ActiveCfg = Debug|Any CPU
+               {86524E19-7C1C-4A90-93AA-2316A150DC52}.Release|Any CPU.ActiveCfg = Release|Any CPU
+               {86524E19-7C1C-4A90-93AA-2316A150DC52}.Release|Any CPU.Build.0 = Release|Any CPU
+               {86524E19-7C1C-4A90-93AA-2316A150DC52}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+               {86524E19-7C1C-4A90-93AA-2316A150DC52}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+               {86524E19-7C1C-4A90-93AA-2316A150DC52}.Release|x64.ActiveCfg = Release|Any CPU
+               {86524E19-7C1C-4A90-93AA-2316A150DC52}.Release|x86.ActiveCfg = Release|Any CPU
+               {86524E19-7C1C-4A90-93AA-2316A150DC52}.Test|Any CPU.ActiveCfg = Release|Any CPU
+               {86524E19-7C1C-4A90-93AA-2316A150DC52}.Test|Any CPU.Build.0 = Release|Any CPU
+               {86524E19-7C1C-4A90-93AA-2316A150DC52}.Test|Mixed Platforms.ActiveCfg = Release|Any CPU
+               {86524E19-7C1C-4A90-93AA-2316A150DC52}.Test|Mixed Platforms.Build.0 = Release|Any CPU
+               {86524E19-7C1C-4A90-93AA-2316A150DC52}.Test|x64.ActiveCfg = Release|Any CPU
+               {86524E19-7C1C-4A90-93AA-2316A150DC52}.Test|x86.ActiveCfg = Release|Any CPU
        EndGlobalSection
        GlobalSection(SolutionProperties) = preSolution
                HideSolutionNode = FALSE
@@ -625,5 +658,6 @@ Global
                {F9AF3E97-BCB7-46B7-8014-7FC858AEE9BA} = {B5DD7C4D-D396-4C55-A8D5-DCFE865AA095}
                {7B5BFE77-FC4D-43B3-84A0-9CB457238951} = {B5DD7C4D-D396-4C55-A8D5-DCFE865AA095}
                {881F7260-CA40-40FD-AEEC-860B346DC2DC} = {B5DD7C4D-D396-4C55-A8D5-DCFE865AA095}
+               {86524E19-7C1C-4A90-93AA-2316A150DC52} = {B5DD7C4D-D396-4C55-A8D5-DCFE865AA095}
        EndGlobalSection
 EndGlobal
index 9abaa04..5aaaf7c 100644 (file)
@@ -6,6 +6,7 @@
   <repository path="..\Pithos.Client\packages.config" />
   <repository path="..\Pithos.Core.Test\packages.config" />
   <repository path="..\Pithos.Core\packages.config" />
+  <repository path="..\Pithos.IntegrationTests\packages.config" />
   <repository path="..\Pithos.Network.Test\packages.config" />
   <repository path="..\Pithos.ShellExtensions.Test\packages.config" />
 </repositories>
\ No newline at end of file