public static void SendEvent_TestHub([EventHub(TestHubName, Connection = TestHubName)] out TestPoco evt)
 {
     evt = new TestPoco()
     {
         Value = "data", Name = "foo"
     };
 }
 public static void CloudBlockBlobBinding_WithUrlBinding(
     [QueueTrigger("testqueue")] TestPoco poco,
     [Blob("{A}")] string blob)
 {
     Assert.AreEqual(TestData, blob);
     _numBlobsRead = 1;
 }
예제 #3
0
 public static void TriggerPoco(
     [ServiceBusTrigger(FirstQueueNameKey)] TestPoco received)
 {
     Assert.AreEqual("value", received.Value);
     Assert.AreEqual("name", received.Name);
     _waitHandle1.Set();
 }
        internal async Task WriteQueueMessage(TestPoco obj, string sessionId = null)
        {
            var serializer = new DataContractSerializer(typeof(TestPoco));

            byte[] payload = null;
            using (var memoryStream = new MemoryStream(10))
            {
                var xmlDictionaryWriter = XmlDictionaryWriter.CreateBinaryWriter(memoryStream, null, null, false);
                serializer.WriteObject(xmlDictionaryWriter, obj);
                xmlDictionaryWriter.Flush();
                memoryStream.Flush();
                memoryStream.Position = 0;
                payload = memoryStream.ToArray();
            }

            await using ServiceBusClient client = new ServiceBusClient(ServiceBusTestEnvironment.Instance.ServiceBusConnectionString);
            var sender = client.CreateSender(_firstQueueScope.QueueName);
            ServiceBusMessage messageObj = new ServiceBusMessage(payload);

            if (!string.IsNullOrEmpty(sessionId))
            {
                messageObj.SessionId = sessionId;
            }
            await sender.SendMessageAsync(messageObj);
        }
 public static void BindToPoco([EventHubTrigger(TestHubName)] TestPoco input, string value, string name, ILogger logger)
 {
     Assert.AreEqual(input.Value, value);
     Assert.AreEqual(input.Name, name);
     logger.LogInformation($"PocoValues({name},{value})");
     _eventWait.Set();
 }
 public static void BindToPoco([EventHubTrigger(TestHubName, Connection = TestHubName)] TestPoco input, ILogger logger)
 {
     Assert.AreEqual(input.Value, "data");
     Assert.AreEqual(input.Name, "foo");
     logger.LogInformation($"PocoValues(foo,data)");
     _eventWait.Set();
 }
예제 #7
0
 public static void OutputPoco(
     [ServiceBus(FirstQueueNameKey)] out TestPoco output)
 {
     output = new TestPoco()
     {
         Value = "value", Name = "name"
     };
 }
 public static void BindToPoco(
     [ServiceBusTrigger(FirstQueueNameKey)] TestPoco input,
     string name, string value, string messageId,
     ILogger logger)
 {
     Assert.AreEqual(input.Name, name);
     Assert.AreEqual(input.Value, value);
     logger.LogInformation($"PocoValues({name},{value})");
     _eventWait.Set();
 }
 public static void IEnumerableCloudBlockBlobBinding_WithModelBinding(
     [QueueTrigger("testqueue")] TestPoco poco,
     [Blob("{A}/{B}ob")] IEnumerable <CloudBlockBlob> blobs)
 {
     foreach (var blob in blobs)
     {
         string content = blob.DownloadText();
         Assert.Equal(TestData, content);
     }
     NumBlobsRead = blobs.Count();
 }
        public static async Task IEnumerableCloudBlockBlobBinding_WithModelBinding(
            [QueueTrigger("testqueue")] TestPoco poco,
            [Blob("{A}/{B}ob")] IEnumerable <BlockBlobClient> blobs)
        {
            foreach (var blob in blobs)
            {
                string content = await blob.DownloadTextAsync();

                Assert.AreEqual(TestData, content);
            }
            _numBlobsRead = blobs.Count();
        }
        public async Task BindToCloudBlobContainer_WithModelBinding()
        {
            TestPoco poco = new TestPoco
            {
                A = _fixture.NameResolver.ResolveWholeString(ContainerName)
            };
            string json      = JsonConvert.SerializeObject(poco);
            var    arguments = new { poco = json };

            await _fixture.JobHost.CallAsync(typeof(BlobBindingEndToEndTests).GetMethod("CloudBlobContainerBinding_WithModelBinding"), arguments);

            Assert.AreEqual(6, _numBlobsRead);
        }
        public async Task BindToCloudBlockBlob_WithUrlBinding()
        {
            // get url for the test blob
            BlockBlobClient blob = _fixture.BlobContainer.GetBlockBlobClient("blob1");
            TestPoco        poco = new TestPoco
            {
                A = blob.Uri.ToString()
            };
            string json      = JsonConvert.SerializeObject(poco);
            var    arguments = new { poco = json };
            await _fixture.JobHost.CallAsync(typeof(BlobBindingEndToEndTests).GetMethod("CloudBlockBlobBinding_WithUrlBinding"), arguments);

            Assert.AreEqual(1, _numBlobsRead);
        }
예제 #13
0
        public async Task BindToCloudBlob_WithModelBinding_Fail()
        {
            TestPoco poco = new TestPoco
            {
                A = _fixture.Config.NameResolver.ResolveWholeString(ContainerName)
            };
            string json      = JsonConvert.SerializeObject(poco);
            var    arguments = new { poco = json };
            var    ex        = await Assert.ThrowsAsync <FunctionInvocationException>(() =>
                                                                                      _fixture.Host.CallAsync(typeof(BlobBindingEndToEndTests).GetMethod("CloudBlockBlobBinding_WithUrlBinding"), arguments));

            // CloudBlockBlobBinding_WithUrlBinding is suppose to bind to a blob
            Assert.Equal($"Invalid absolute blob url: {poco.A}", ex.InnerException.InnerException.Message);
        }
        public async Task BindToIEnumerableCloudBlockBlob_WithModelBinding()
        {
            TestPoco poco = new TestPoco
            {
                A = _fixture.Config.NameResolver.ResolveWholeString(ContainerName),
                B = "bl"
            };
            string json      = JsonConvert.SerializeObject(poco);
            var    arguments = new { poco = json };

            await _fixture.Host.CallAsync(typeof(BlobBindingEndToEndTests).GetMethod("IEnumerableCloudBlockBlobBinding_WithModelBinding"), arguments);

            Assert.Equal(3, NumBlobsRead);
        }
        public void BindToCloudBlob_WithModelBinding_Fail()
        {
            TestPoco poco = new TestPoco
            {
                A = _fixture.NameResolver.ResolveWholeString(ContainerName)
            };
            string json      = JsonConvert.SerializeObject(poco);
            var    arguments = new { poco = json };
            var    ex        = Assert.ThrowsAsync <FunctionInvocationException>(() =>
                                                                                _fixture.JobHost.CallAsync(typeof(BlobBindingEndToEndTests).GetMethod("CloudBlockBlobBinding_WithUrlBinding"), arguments));

            // CloudBlockBlobBinding_WithUrlBinding is suppose to bind to a blob
            Assert.AreEqual($"Invalid blob path specified : '{poco.A}'. Blob identifiers must be in the format 'container/blob'.", ex.InnerException.InnerException.Message);
        }
        public void BindToCloudBlobContainer_WithUrlBinding_Fail()
        {
            // get url for the test blob
            var      blob = _fixture.BlobContainer.GetBlockBlobClient("blob1");
            TestPoco poco = new TestPoco
            {
                A = blob.Uri.ToString()
            };
            string json      = JsonConvert.SerializeObject(poco);
            var    arguments = new { poco = json };
            var    ex        = Assert.ThrowsAsync <FunctionInvocationException>(() =>
                                                                                _fixture.JobHost.CallAsync(typeof(BlobBindingEndToEndTests).GetMethod("CloudBlobContainerBinding_WithModelBinding"), arguments));

            // CloudBlobContainerBinding_WithModelBinding is suppose to bind to a container
            Assert.IsInstanceOf <FormatException>(ex.InnerException.InnerException);
        }
예제 #17
0
        public async Task BindToCloudBlobContainer_WithUrlBinding_Fail()
        {
            // get url for the test blob
            CloudBlockBlob blob = _fixture.BlobContainer.GetBlockBlobReference("blob1");
            TestPoco       poco = new TestPoco
            {
                A = blob.Uri.ToString()
            };
            string json      = JsonConvert.SerializeObject(poco);
            var    arguments = new { poco = json };
            var    ex        = await Assert.ThrowsAsync <FunctionInvocationException>(() =>
                                                                                      _fixture.Host.CallAsync(typeof(BlobBindingEndToEndTests).GetMethod("CloudBlobContainerBinding_WithModelBinding"), arguments));

            // CloudBlobContainerBinding_WithModelBinding is suppose to bind to a container
            Assert.Equal($"Invalid container name: {poco.A}", ex.InnerException.InnerException.Message);
        }
        public static async Task WriteQueueMessage(string connectionString, string queueName, TestPoco obj, string sessionId = null)
        {
            var serializer = new DataContractSerializer(typeof(TestPoco));

            byte[] payload = null;
            using (var memoryStream = new MemoryStream(10))
            {
                var xmlDictionaryWriter = XmlDictionaryWriter.CreateBinaryWriter(memoryStream, null, null, false);
                serializer.WriteObject(xmlDictionaryWriter, obj);
                xmlDictionaryWriter.Flush();
                memoryStream.Flush();
                memoryStream.Position = 0;
                payload = memoryStream.ToArray();
            }

            QueueClient queueClient = new QueueClient(connectionString, queueName);
            Message     messageObj  = new Message(payload);

            if (!string.IsNullOrEmpty(sessionId))
            {
                messageObj.SessionId = sessionId;
            }
            await queueClient.SendAsync(messageObj);

            await queueClient.CloseAsync();
        }
 public static void CloudBlobContainerBinding_WithModelBinding(
     [QueueTrigger("testqueue")] TestPoco poco,
     [Blob("{A}")] BlobContainerClient container)
 {
     CloudBlobContainerBinding(container);
 }