示例#1
0
        public async Task BlobTrigger_IfHasUnboundParameter_CanCall()
        {
            // Arrange
            var          container     = blobServiceClient.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(typeof(BlobProgram), "UnboundParameter", arguments);

            var    outputBlob = container.GetBlockBlobClient("note.csv");
            string content    = await outputBlob.DownloadTextAsync();

            Assert.AreEqual("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 SetWriter_IfNullObject_Throws()
        {
            // Arrange
            Guid g = Guid.NewGuid();

            // Act & Assert
            ExceptionAssert.ThrowsArgumentNull(() => BlobCausalityManager.SetWriter(null, g), "metadata");
        }
        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 SetWriter_IfValidGuid_AddsWriter()
        {
            // Arrange
            IDictionary <string, string> metadata = new Dictionary <string, string>();
            Guid g = Guid.NewGuid();

            // Act
            BlobCausalityManager.SetWriter(metadata, g);

            // Assert
            AssertWriterEqual(g, metadata);
        }
        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();
        }
示例#7
0
 public Task <Guid?> GetWriterAsync(BlobBaseClient blob, CancellationToken cancellationToken)
 {
     return(BlobCausalityManager.GetWriterAsync(blob, cancellationToken));
 }