Beispiel #1
0
        public void NewDrive_WhereCredentialsAreSpecified_CreatesDrive()
        {
            var gatewayMock = new Mock <ICloudGateway>(MockBehavior.Strict).Object;

            compositionFixture.ExportGateway(gatewayMock);

            var pipelineFixture = new PipelineFixture();

            pipelineFixture.SetVariable("credential", PipelineFixture.GetCredential("TestUser", "TestPassword"));
            var result = pipelineFixture.Invoke(new string[] {
                string.Format(CultureInfo.InvariantCulture,
                              "New-PSDrive -PSProvider {0} -Name Y -Root '{1}' -Description '{2}' -Credential $credential -ApiKey {3} -EncryptionKey {4}",
                              CloudProvider.PROVIDER_NAME, CompositionFixture.MOCKGATEWAY_NAME + "|" + root, description, apiKey, encryptionKey),
                string.Format(CultureInfo.InvariantCulture,
                              "Get-PSDrive -PSProvider {0}", CloudProvider.PROVIDER_NAME)
            });

            Assert.AreEqual(1, result.Count, "Unexpected number of results");
            Assert.IsInstanceOfType(result[0].BaseObject, typeof(PSDriveInfo), "Results is not of type PSDriveInfo");

            var driveInfo = result[0].BaseObject as PSDriveInfo;

            Assert.AreEqual("Y:", driveInfo.Root, "Unexpected root");
            Assert.AreEqual(CompositionFixture.MOCKGATEWAY_NAME + "@TestUser", ((CloudDrive)driveInfo).DisplayRoot, "Unexpected display root");
            Assert.AreEqual(description, driveInfo.Description, "Unexpected description");
        }
        public void GetChildItemAsync_WherePathIsRootAndCredentialsAreSpecified_CallsGatewayCorrectly()
        {
            var rootName           = FileSystemFixture.GetRootName("@TestUser");
            var rootDirectoryItems = fileSystemFixture.RootDirectoryItems;

            var gatewayMock = mockingFixture.InitializeGetChildItemsAsync(rootName, @"\", rootDirectoryItems);

            compositionFixture.ExportAsyncGateway(gatewayMock.Object);

            var pipelineFixture = new PipelineFixture();

            pipelineFixture.SetVariable("credential", PipelineFixture.GetCredential("TestUser", "TestPassword"));
            var result = pipelineFixture.Invoke(
                FileSystemFixture.NewDriveCommandWithCredential,
                @"Get-ChildItem -Path Y:\"
                );

            Assert.AreEqual(rootDirectoryItems.Length, result.Count, "Unexpected number of results");
            CollectionAssert.AreEquivalent(rootDirectoryItems, result.Select(p => p.BaseObject).Cast <FileSystemInfoContract>().ToList());
        }