public async Task BlobTrigger_IfHasUnboundParameter_CanCall() { // Arrange var client = account.CreateBlobServiceClient(); var container = client.GetBlobContainerClient(ContainerName); const string inputBlobName = "note-monday.csv"; var inputBlob = container.GetBlockBlobClient(inputBlobName); await container.CreateIfNotExistsAsync(); await inputBlob.UploadTextAsync("abc"); IDictionary <string, object> arguments = new Dictionary <string, object> { { "values", ContainerName + "/" + inputBlobName }, { "unbound", "test" } }; // Act await CallAsync(account, typeof(BlobProgram), "UnboundParameter", arguments); var outputBlob = container.GetBlockBlobClient("note.csv"); string content = await outputBlob.DownloadTextAsync(); Assert.Equal("done", content); // $$$ Put this in its own unit test? Guid?guid = BlobCausalityManager.GetWriterAsync(outputBlob, CancellationToken.None).GetAwaiter().GetResult(); Assert.True(guid != Guid.Empty, "Blob is missing causality information"); }
public void GetWriter_IfFetchFails_ReturnsNull() { // Arrange Mock <BlobBaseClient> blobMock = SetupBlobMock(isFetchSuccess: false); // Act Guid?writer = BlobCausalityManager.GetWriterAsync(blobMock.Object, CancellationToken.None).GetAwaiter().GetResult(); // Assert Assert.Null(writer); blobMock.Verify(); }
public void GetWriter_IfMetadataDoesNotHaveWriterProperty_ReturnsNull() { // Arrange Mock <ICloudBlob> blobMock = SetupBlobMock(isFetchSuccess: true); // Act Guid?writer = BlobCausalityManager.GetWriterAsync(blobMock.Object, CancellationToken.None).GetAwaiter().GetResult(); // Assert Assert.Null(writer); blobMock.Verify(); }
public void GetWriter_IfMetadataPropertyIsGuid_ReturnsThatGuid() { // Arrange Guid expected = Guid.NewGuid(); Mock <ICloudBlob> blobMock = SetupBlobMock(isFetchSuccess: true); blobMock.Object.Metadata[BlobMetadataKeys.ParentId] = expected.ToString(); // Act Guid?writer = BlobCausalityManager.GetWriterAsync(blobMock.Object, CancellationToken.None).GetAwaiter().GetResult(); // Assert Assert.Equal(expected, writer); blobMock.Verify(); }
public void GetWriter_IfMetadataPropertyIsNotGuid_ReturnsNull() { // Arrange Mock <BlobBaseClient> blobMock = SetupBlobMock( isFetchSuccess: true, new Dictionary <string, string>() { { BlobMetadataKeys.ParentId, "abc" } }); // Act Guid?writer = BlobCausalityManager.GetWriterAsync(blobMock.Object, CancellationToken.None).GetAwaiter().GetResult(); // Assert Assert.Null(writer); blobMock.Verify(); }
public void GetWriter_IfMetadataPropertyIsGuid_ReturnsThatGuid() { // Arrange Guid expected = Guid.NewGuid(); Mock <BlobBaseClient> blobMock = SetupBlobMock( isFetchSuccess: true, new Dictionary <string, string>() { { BlobMetadataKeys.ParentId, expected.ToString() } }); // Act Guid?writer = BlobCausalityManager.GetWriterAsync(blobMock.Object, CancellationToken.None).GetAwaiter().GetResult(); // Assert Assert.AreEqual(expected, writer); blobMock.Verify(); }