Пример #1
0
 public TestCaseContext(IDictionary <string, string> options, TestCase testCase, IDisposableLogger logger, IDescriptionWriter descriptionWriter, IItemsHolder itemsHolder)
 {
     Options           = options;
     TestCase          = testCase;
     Logger            = logger;
     DescriptionWriter = descriptionWriter;
     _itemsHolder      = itemsHolder;
 }
Пример #2
0
        public static T GetRequiredItem <T>(this IItemsHolder pipelineContext, string key)
            where T : class
        {
            if (!pipelineContext.TryGetItem <T>(key, out var item))
            {
                Require.Fail($"Could not get required item: {key}");
            }

            return(item);
        }
Пример #3
0
        public static void ReplaceTokens(this IItemsHolder pipelineContext, JToken doc, IDictionary <string, IReadOnlyCollection <string> > groups)
        {
            if (!pipelineContext.TryGetItem("TokenGroups", out IDictionary <string, IDictionary <string, int> > tokenGroups))
            {
                tokenGroups = new Dictionary <string, IDictionary <string, int> >();
                pipelineContext.SetItem("TokenGroups", tokenGroups);
            }

            Replace(doc, groups, new TokenHolder(tokenGroups));
        }
Пример #4
0
        public HighlightSearchItemVm(IItemsHolder <TItem> parent, string color, params Func <TItem, string>[] accessors)
        {
            _parent          = parent;
            _fieldsAccessors = accessors.ToList();
            Color            = (Color)(new ColorConverter().ConvertFrom(color));

            var whenAnyHl = this.WhenAnyValue(x => x.Text).Where(x => _parent.IsLoading == false);

            whenAnyHl.Throttle(TimeSpan.FromMilliseconds(300)).Subscribe(b => OnTextChanged());
        }
Пример #5
0
        public static string GetRequiredItem(this IItemsHolder pipelineContext, string key)
        {
            var item = pipelineContext.GetRequiredItem <object>(key);

            return(item switch
            {
                null => null,
                string stringValue => stringValue,
                JToken jtokenValue => JsonConvert.SerializeObject(jtokenValue),
                _ => throw new NotSupportedException($"Unsupported item type {item.GetType()} for conversion into string"),
            });
Пример #6
0
        public static string GetRequiredItem(this IItemsHolder pipelineContext, string key)
        {
            var item = pipelineContext.GetRequiredItem <object>(key);

            switch (item)
            {
            case null:
                return(null);

            case string stringValue:
                return(stringValue);

            case JToken jtokenValue:
                return(JsonConvert.SerializeObject(jtokenValue));

            default:
                throw new NotSupportedException($"Unsupported item type {item.GetType()} for conversion into string");
            }
        }
Пример #7
0
        public static JToken GetRequiredItemAsJToken(this IItemsHolder pipelineContext, string key)
        {
            var item = pipelineContext.GetRequiredItem <object>(key);

            switch (item)
            {
            case null:
                return(null);

            case string stringValue:
                return(JToken.Parse(stringValue));

            case JToken jtokenValue:
                return(jtokenValue);

            case object obj:
                return(JObject.FromObject(obj));

            default:
                throw new NotSupportedException($"Unsupported item type {item.GetType()} for conversion into JToken");
            }
        }
Пример #8
0
 public NonUniqueIndex(IItemsHolder <T> holder, Indexer <T, P> indexer)
 {
     this.holder  = holder;
     this.indexer = indexer;
 }
Пример #9
0
 internal Cache(IItemsHolder <T> holder)
 {
     this.holder = holder;
 }
Пример #10
0
 public static T GetItem <T>(this IItemsHolder pipelineContext, string key)
     where T : class
 {
     pipelineContext.TryGetItem <T>(key, out var item);
     return(item);
 }
Пример #11
0
        public static T GetRequiredResolvedObject <T>(this IItemsHolder pipelineContext, TestCase testCase, string itemId)
        {
            var content = pipelineContext.GetRequiredResolvedContent(testCase, itemId);

            return(JsonConvert.DeserializeObject <T>(content));
        }
Пример #12
0
        public static string GetRequiredResolvedContent(this IItemsHolder pipelineContext, TestCase testCase, string itemId)
        {
            var content = testCase.GetRequiredContent(itemId);

            return(pipelineContext.Resolve(content));
        }
Пример #13
0
 public static string Resolve(this IItemsHolder pipelineContext, string value)
 {
     return(VariableResolver.Resolve(value, (key) => pipelineContext.GetRequiredItem(key)));
 }