Skip to content
This repository
Browse code

run unit tests in visual studio

  • Loading branch information...
commit d3f847c94b94d6ccff600fc3ff55682eb1e89087 1 parent 05304c3
Yao authored March 05, 2013
31  WindowsAzurePowershell/src/CLITest/BVT/CLICommonBVT.cs
@@ -105,16 +105,30 @@ public static void CLICommonBVTInitialize(TestContext testContext)
105 105
             EnvKey = Test.Data.Get("EnvContextKey");
106 106
             SaveAndCleanSubScriptionAndEnvConnectionString();
107 107
 
108  
-            //init the blob helper for blob related operations
109  
-            CommonBlobHelper = new CloudBlobHelper(CommonStorageAccount);
110  
-
111 108
             //Clean Storage Context
112 109
             Test.Info("Clean storage context in PowerShell");
113 110
             PowerShellAgent.CleanStorageContext();
114 111
 
  112
+            PowerShellAgent.ImportModule(@".\Microsoft.WindowsAzure.Management.Storage.dll");
  113
+            string ConnectionString = Test.Data.Get("StorageConnectionString");
  114
+            
  115
+            if (String.IsNullOrEmpty(ConnectionString))
  116
+            {
  117
+                throw new ArgumentException("Please set the StorageConnectionString element of TestData.xml");
  118
+            }
  119
+            
  120
+            CommonStorageAccount = CloudStorageAccount.Parse(ConnectionString);
  121
+            PowerShellAgent.SetStorageContext(ConnectionString);
  122
+
  123
+            //init the blob helper for blob related operations
  124
+            CommonBlobHelper = new CloudBlobHelper(CommonStorageAccount);
  125
+
  126
+            
  127
+
115 128
             // import module
116 129
             string moduleFilePath = Test.Data.Get("ModuleFilePath");
117 130
             PowerShellAgent.ImportModule(moduleFilePath);
  131
+
118 132
             GenerateBvtTempFiles();
119 133
         }
120 134
 
@@ -156,11 +170,22 @@ private static void GenerateBvtTempFiles()
156 170
             CommonBlockFilePath = Test.Data.Get("BlockFilePath");
157 171
             CommonPageFilePath = Test.Data.Get("PageFilePath");
158 172
 
  173
+            CreateDirIfNotExits(Path.GetDirectoryName(CommonBlockFilePath));
  174
+            CreateDirIfNotExits(Path.GetDirectoryName(CommonPageFilePath));
  175
+
159 176
             // Generate block file and page file which are used for uploading
160 177
             Helper.GenerateMediumFile(CommonBlockFilePath, 1);
161 178
             Helper.GenerateMediumFile(CommonPageFilePath, 1);
162 179
         }
163 180
 
  181
+        private static void CreateDirIfNotExits(string dirPath)
  182
+        {
  183
+            if (!Directory.Exists(dirPath))
  184
+            {
  185
+                Directory.CreateDirectory(dirPath);
  186
+            }
  187
+        }
  188
+
164 189
         /// <summary>
165 190
         /// Clean up test resources of  bvt class
166 191
         /// </summary>
7  WindowsAzurePowershell/src/CLITest/CLITest.csproj
@@ -71,6 +71,10 @@
71 71
     </Content>
72 72
   </ItemGroup>
73 73
   <ItemGroup>
  74
+    <ProjectReference Include="..\Management.Storage\Management.Storage.csproj">
  75
+      <Project>{08cf7da7-0392-4a19-b79b-e1ff67cdb81a}</Project>
  76
+      <Name>Management.Storage</Name>
  77
+    </ProjectReference>
74 78
     <ProjectReference Include="..\MsTestLib\MsTestLib.csproj">
75 79
       <Project>{ce97967b-7479-43b9-9561-776232ac5d47}</Project>
76 80
       <Name>MsTestLib</Name>
@@ -80,6 +84,9 @@
80 84
       <Name>StorageTestLib</Name>
81 85
     </ProjectReference>
82 86
   </ItemGroup>
  87
+  <ItemGroup>
  88
+    <None Include="deploy.cmd" />
  89
+  </ItemGroup>
83 90
   <Choose>
84 91
     <When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
85 92
       <ItemGroup>
17  WindowsAzurePowershell/src/CLITest/TestData.xml
... ...
@@ -1,4 +1,19 @@
1 1
 <?xml version="1.0" encoding="utf-8"?>
2 2
 <TestConfig>
3  
- 
  3
+  <consolelogger>true</consolelogger>
  4
+  <filelogger>true</filelogger>
  5
+  <logfilename>storage__PowerShellBVT__</logfilename>
  6
+  <loginfo>true</loginfo>
  7
+  <logverbose>true</logverbose>
  8
+  <logwarning>true</logwarning>
  9
+  <logerror>true</logerror>
  10
+  <AzureSubscriptionName>SubscriptionName</AzureSubscriptionName>
  11
+  <StorageConnectionString></StorageConnectionString>
  12
+  <ModuleFilePath></ModuleFilePath>
  13
+  <BlockFilePath>Data\upload\中文路径path\Windows Azure是微软基于云计算的操作系统.txt</BlockFilePath>
  14
+  <PageFilePath>Data\upload\page.bin</PageFilePath>
  15
+  <DownloadDirPath>Data\download</DownloadDirPath>
  16
+  <DownloadDir>.\Data\download\getblobcontent\</DownloadDir>
  17
+  <UploadDir>.\Data\upload\setblobcontent\</UploadDir>
  18
+  <EnvContextKey>AZURE_STORAGE_CONNECTION_STRING</EnvContextKey>
4 19
 </TestConfig>
36  WindowsAzurePowershell/src/CLITest/deploy.cmd
... ...
@@ -0,0 +1,36 @@
  1
+@echo off
  2
+setlocal
  3
+ 
  4
+if "%~1" == "" (
  5
+    echo Usage: deploy [Destination Directory]
  6
+    echo Example: copies test files into test run folder :
  7
+    echo   deploy "C:\test"
  8
+    exit /b 1
  9
+)
  10
+ 
  11
+set dest=%~1
  12
+if %dest:~-1%==\ set dest=%dest:~0,-1%
  13
+ 
  14
+  rem %~d0 expands the drive letter
  15
+  rem %~p0 expands the path to this file
  16
+set localdir=%~d0%~p0
  17
+
  18
+set commonPath=..\..\..\common
  19
+set binPath=..\..\..\..\bin
  20
+set symbolPath=..\..\..\Symbols.pri
  21
+ 
  22
+mkdir "%dest%"
  23
+
  24
+rem deploy the test cases
  25
+xcopy /y /e /c "%localdir%*"  "%dest%"\
  26
+mkdir "%dest%"\Data\Upload
  27
+mkdir "%dest%"\Data\Download
  28
+
  29
+rem deploy pdb files
  30
+xcopy /y /e /c "%localdir%"%symbolPath%\tests\dll\StorageTestLib.pdb "%dest%"\
  31
+xcopy /y /e /c "%localdir%"%symbolPath%\tests\dll\PowerShellTest.pdb "%dest%"\
  32
+xcopy /y /e /c "%localdir%"%symbolPath%\tests\dll\MsTest.pdb "%dest%"\
  33
+xcopy /y /e /c "%localdir%"%symbolPath%\tests\dll\MsTestLib.pdb "%dest%"\
  34
+xcopy /y /e /c "%localdir%"%symbolPath%\tests\exe\MsTest2.pdb "%dest%"\
  35
+
  36
+endlocal
3  WindowsAzurePowershell/src/Local.testsettings
@@ -2,7 +2,6 @@
2 2
 <TestSettings name="Local" id="cdbdc350-d4c9-4e43-a4f9-37455108ceaa" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
3 3
   <Description>These are default test settings for a local test run.</Description>
4 4
   <Deployment>
5  
-    <DeploymentItem filename="..\..\Package\Debug" />
6 5
     <DeploymentItem filename="Management.SqlDatabase.Test\Resources\" />
7 6
     <DeploymentItem filename="Management.CloudService.Test\Resources\" />
8 7
     <DeploymentItem filename="Management.ServiceManagement.Test\VhdFiles\dynamic_50_child02.vhd" />
@@ -14,6 +13,8 @@
14 13
     <DeploymentItem filename="Management.SqlDatabase.Test\TestScripts\" />
15 14
     <DeploymentItem filename="Management.ServiceManagement.Test\VhdFiles\fixed_50_child02.vhd" />
16 15
     <DeploymentItem filename="Management.ServiceManagement.Test\VhdFiles\fixed_50.vhd" />
  16
+    <DeploymentItem filename="..\..\Package\Debug" />
  17
+    <DeploymentItem filename="CLITest\TestData.xml" />
17 18
     <DeploymentItem filename="Management.ServiceManagement.Test\VhdFiles\dynamic_50.vhd" />
18 19
     <DeploymentItem filename="Management.ScenarioTest\Resources\" />
19 20
     <DeploymentItem filename="Management.ServiceManagement.Test\VhdFiles\fixed_50_child01.vhd" />
4  WindowsAzurePowershell/src/Management.Storage/Model/ResourceModel/AzureStorageContainer.cs
@@ -33,7 +33,7 @@ public class AzureStorageContainer : AzureStorageBase
33 33
         /// <summary>
34 34
         /// the permission of CloudBlobContainer
35 35
         /// </summary>
36  
-        public BlobContainerPermissions Permissions { get; private set; }
  36
+        public BlobContainerPermissions Permission { get; private set; }
37 37
 
38 38
         /// <summary>
39 39
         /// the public accesss level of CloudBlobContainer
@@ -53,7 +53,7 @@ public class AzureStorageContainer : AzureStorageBase
53 53
         public AzureStorageContainer(CloudBlobContainer container, BlobContainerPermissions permissions)
54 54
         {
55 55
             CloudBlobContainer = container;
56  
-            Permissions = permissions;
  56
+            Permission = permissions;
57 57
             Name = container.Name;
58 58
             PublicAccess = permissions.PublicAccess;
59 59
             LastModified = container.Properties.LastModified;

0 notes on commit d3f847c

Please sign in to comment.
Something went wrong with that request. Please try again.