コード例 #1
0
        public void TestGetBlobLocationAsync()
        {
            using (ShimsContext.Create())
            {
                connectionStrings.Add(new ConnectionStringSettings(AppSettings.SEVIS_DS2019_STORAGE_CONNECTION_STRING_KEY, "connection string"));
                string connectionString = settings.DS2019FileStorageConnectionString.ConnectionString;

                string blobName      = "TestBlob";
                string containerName = "ds2019";

                string blobUriString = "http://www.google.com";

                var blobShim = new Microsoft.WindowsAzure.Storage.Blob.Fakes.ShimCloudBlockBlob
                {
                };

                iBlobStorageSettings.Setup(x => x.CreateBlockBlob(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()))
                .Returns(blobShim);

                var shimContainer = new Microsoft.WindowsAzure.Storage.Blob.Fakes.ShimCloudBlobContainer
                {
                    GetBlockBlobReferenceString = (blbnm) =>
                    {
                        return(blobShim);
                    }
                };

                iBlobStorageSettings.Setup(x => x.BlobContainer("ds2019"))
                .Returns(shimContainer);

                Microsoft.WindowsAzure.Storage.Blob.Fakes.ShimCloudBlob.AllInstances.ExistsBlobRequestOptionsOperationContext = (blob, opts, contxt) =>
                {
                    return(true);
                };

                Microsoft.WindowsAzure.Storage.Blob.Fakes.ShimCloudBlob.AllInstances.UriGet = (blb) =>
                {
                    return(new Uri(blobUriString));
                };

                var testInstance = service.GetBlobLocation(blobName, containerName);

                Assert.IsNotNull(testInstance);

                var testAsyncInstance = service.GetBlobAsync(blobName, containerName);

                Assert.IsNotNull(testAsyncInstance);
            }
        }