Esempio n. 1
0
        public void ShouldAddMultipleHeaders(ExtendableOptions options)
        {
            var header1 = Header.Add("key1", "value1");
            var header2 = Header.Add("key2", "value2");
            var header3 = Header.Add("key3", "value3");

            header1.Apply(options);
            header2.Apply(options);
            header3.Apply(options);

            Assert.That(options.GetHeaders(), Contains.Item(new KeyValuePair <string, string>("key1", "value1")));
            Assert.That(options.GetHeaders(), Contains.Item(new KeyValuePair <string, string>("key2", "value2")));
            Assert.That(options.GetHeaders(), Contains.Item(new KeyValuePair <string, string>("key3", "value3")));
        }
    public static bool HasValue(this ExtendableOptions options)
    {
        var messageId = options.GetMessageId();

        if (messageId is not null)
        {
            return(true);
        }

        if (options is SendOptions sendOptions)
        {
            if (sendOptions.GetDeliveryDate().HasValue || sendOptions.GetDeliveryDelay().HasValue)
            {
                return(true);
            }
        }

        var headers = options.GetHeaders();

        if (headers.Any())
        {
            return(true);
        }

        var extensions = options.GetExtensions();

        if (extensions is not null)
        {
            return(ContextBagHelper.HasContent(extensions));
        }

        return(false);
    }
Esempio n. 3
0
        public void ShouldAllowCtorUsage(ExtendableOptions options)
        {
            var header = new Header("key", "value");

            header.Apply(options);

            Assert.That(options.GetHeaders(), Contains.Item(new KeyValuePair <string, string>("key", "value")));
        }
        internal override bool IsApplied(ExtendableOptions options)
        {
            string headerValue;

            if (options.GetHeaders().TryGetValue(key, out headerValue))
            {
                return(headerValue == value);
            }

            return(false);
        }
Esempio n. 5
0
    public static Dictionary <string, string> GetCleanedHeaders(this ExtendableOptions options)
    {
        var dictionary = new Dictionary <string, string>();

        foreach (var header in options.GetHeaders())
        {
            var key = header.Key;

            if (key.StartsWith("NServiceBus."))
            {
                key = key[12..];
    public static Dictionary <string, string> GetCleanedHeaders(this ExtendableOptions options)
    {
        var dictionary = new Dictionary <string, string>();

        foreach (var header in options.GetHeaders())
        {
            var key = header.Key;
            if (key.StartsWith("NServiceBus."))
            {
                key = key.Substring(12);
            }
            if (header.Key == Headers.SagaType)
            {
                dictionary.Add(key, Type.GetType(header.Value, throwOnError: true).FullName);
                continue;
            }

            dictionary.Add(key, header.Value);
        }

        return(dictionary);
    }