public void SetOwner_IfUnsupportedValueType_Throws()
        {
            // Arrange
            var  jobject = CreateJsonObject(123);
            Guid g       = Guid.NewGuid();

            // Act & Assert
            ExceptionAssert.ThrowsArgumentNull(() => QueueCausalityManager.SetOwner(g, jobject), "token");
        }
示例#2
0
            // Hook JObject serialization to so we can stamp the object with a causality marker.
            private static Task <JObject> SerializeToJobject(object input, Attribute attrResolved, ValueBindingContext context)
            {
                JObject objectToken        = JObject.FromObject(input, JsonSerialization.Serializer);
                var     functionInstanceId = context.FunctionInstanceId;

                QueueCausalityManager.SetOwner(functionInstanceId, objectToken);

                return(Task.FromResult <JObject>(objectToken));
            }
        public void SetOwner_IfValidOwner_AddsOwner()
        {
            // Arrange
            var jobject = CreateJsonObject(new Payload {
                Val = 123
            });
            Guid g = Guid.NewGuid();

            // Act
            QueueCausalityManager.SetOwner(g, jobject);

            // Assert
            AssertOwnerEqual(g, jobject.ToString());
        }
        public void SetOwner_IfEmptyOwner_DoesNotAddOwner()
        {
            // Arrange
            var jobject = CreateJsonObject(new Payload {
                Val = 123
            });
            Guid g = Guid.Empty;

            // Act
            QueueCausalityManager.SetOwner(g, jobject);

            // Assert
            AssertOwnerIsNull(jobject.ToString());
        }
        public IStorageQueueMessage Convert(TInput input)
        {
            JToken token;

            if (input == null)
            {
                token = new JValue((string)null);
            }
            else
            {
                JObject objectToken = JObject.FromObject(input, JsonSerialization.Serializer);
                Debug.Assert(objectToken != null);
                QueueCausalityManager.SetOwner(_functionInstanceId, objectToken);
                token = objectToken;
            }

            string contents = token.ToJsonString();

            return(_queue.CreateMessage(contents));
        }