Exemplo n.º 1
0
        public void SetupTest()
        {
            GlobalPathInfo.GlobalSettingsDirectory = Data.AzureSdkAppDir;
            CmdletSubscriptionExtensions.SessionManager = new InMemorySessionManager();
            mockCommandRuntime = new MockCommandRuntime();

            enableCacheCmdlet = new EnableAzureMemcacheRoleCommand();
            addCacheRoleCmdlet = new AddAzureCacheWorkerRoleCommand();

            addCacheRoleCmdlet.CommandRuntime = mockCommandRuntime;
            enableCacheCmdlet.CommandRuntime = mockCommandRuntime;
        }
        public void ThrowsErrorForInvalidCacheVersion()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                files.CreateAzureSdkDirectoryAndImportPublishSettings();
                files.CreateNewService("NEW_SERVICE");
                string rootPath = Path.Combine(files.RootPath, "NEW_SERVICE");
                string packagePath = Path.Combine(rootPath, Resources.CloudPackageFileName);
                string cacheRoleName = "WorkerRole1";
                AddAzureCacheWorkerRoleCommand addCacheWorkerCmdlet = new AddAzureCacheWorkerRoleCommand()
                {
                    CommandRuntime = mockCommandRuntime
                };
                EnableAzureMemcacheRoleCommand enableCacheCmdlet = new EnableAzureMemcacheRoleCommand()
                {
                    CacheRuntimeVersion = "1.8.0",
                    CommandRuntime = mockCommandRuntime
                };

                CloudServiceProject service = new CloudServiceProject(rootPath, null);
                service.AddWebRole(Data.NodeWebRoleScaffoldingPath);
                addCacheWorkerCmdlet.AddAzureCacheWorkerRoleProcess(cacheRoleName, 1, rootPath);
                enableCacheCmdlet.EnableAzureMemcacheRoleProcess("WebRole1", cacheRoleName, rootPath);

                Testing.AssertThrows<Exception>(
                    () => cmdlet.ExecuteCmdlet(),
                    string.Format(Resources.CacheMismatchMessage, "WebRole1", "2.0.0"));
            }
        }