Example #1
0
        public void Format_BinderParameterLog_ReturnsNull()
        {
            ParameterLog log = new BinderParameterLog();

            string result = LogAnalysis.Format(log);

            Assert.Null(result);
        }
        public static void AddParameterModels(string parameterName, FunctionInstanceArgument argument, ParameterLog log,
                                              FunctionInstanceSnapshot snapshot, ICollection <ParamModel> parameterModels)
        {
            ParamModel model = new ParamModel
            {
                Name            = parameterName,
                ArgInvokeString = argument.Value
            };

            if (log != null)
            {
                model.Status = Format(log);
            }

            if (argument.IsBlob)
            {
                model.ExtendedBlobModel = LogAnalysis.CreateExtendedBlobModel(snapshot, argument);
            }

            parameterModels.Add(model);

            // Special-case IBinder, which adds sub-parameters.
            BinderParameterLog binderLog = log as BinderParameterLog;

            if (binderLog != null)
            {
                IEnumerable <BinderParameterLogItem> items = binderLog.Items;

                if (items != null)
                {
                    int count = items.Count();
                    model.Status = String.Format(CultureInfo.CurrentCulture, "Bound {0} object{1}.", count, count != 1 ? "s" : String.Empty);

                    foreach (BinderParameterLogItem item in items)
                    {
                        if (item == null)
                        {
                            continue;
                        }

                        ParameterSnapshot        itemSnapshot = HostIndexer.CreateParameterSnapshot(item.Descriptor);
                        string                   itemName     = parameterName + ": " + itemSnapshot.AttributeText;
                        FunctionInstanceArgument itemArgument =
                            FunctionIndexer.CreateFunctionInstanceArgument(item.Value, item.Descriptor);

                        AddParameterModels(itemName, itemArgument, item.Log, snapshot, parameterModels);
                    }
                }
            }
        }