public void IsDynamicIsSameAsSpecifiedInConstructor(bool isDynamic)
        {
            ValueSequenceDataSet dataSet = new ValueSequenceDataSet(new object[] { "a" }, null, isDynamic);
            List<IDataItem> items = new List<IDataItem>(dataSet.GetItems(EmptyArray<DataBinding>.Instance, true));

            Assert.AreEqual(isDynamic, items[0].IsDynamic);
        }
        public void ItemsContainEmptyMetadataWhenParameterWasNull()
        {
            ValueSequenceDataSet dataSet = new ValueSequenceDataSet(new object[] { "a" }, null, false);
            List<IDataItem> items = new List<IDataItem>(dataSet.GetItems(EmptyArray<DataBinding>.Instance, true));

            PropertyBag map = DataItemUtils.GetMetadata(items[0]);
            Assert.Count(0, map);
        }
 /// <inheritdoc />
 protected override void PopulateDataSource(IPatternScope scope, DataSource dataSource, ICodeElementInfo codeElement)
 {
     using (var textReader = OpenTextReader(codeElement))
     {
         var text = textReader.ReadToEnd();
         var dataSet = new ValueSequenceDataSet(new[] { text }, null, false);
         dataSource.AddDataSet(dataSet);
     }
 }
 /// <inheritdoc />
 protected override void PopulateDataSource(IPatternScope scope, DataSource dataSource, ICodeElementInfo codeElement)
 {
     using (var stream = OpenStream(codeElement))
     {
         var bytes = new byte[stream.Length];
         stream.Read(bytes, 0, bytes.Length);
         var dataSet = new ValueSequenceDataSet(new[] { bytes }, null, false);
         dataSource.AddDataSet(dataSet);
     }
 }
        public void ItemsContainSameMetadataAsSpecifiedInConstructor()
        {
            List<KeyValuePair<string, string>> metadataPairs = new List<KeyValuePair<string, string>>();
            metadataPairs.Add(new KeyValuePair<string, string>("Foo", "Bar"));

            ValueSequenceDataSet dataSet = new ValueSequenceDataSet(new object[] { "a" }, metadataPairs, false);
            List<IDataItem> items = new List<IDataItem>(dataSet.GetItems(EmptyArray<DataBinding>.Instance, true));

            PropertyBag map = DataItemUtils.GetMetadata(items[0]);
            Assert.Count(1, map);
            Assert.AreEqual("Bar", map.GetValue("Foo"));
        }
        public void ItemsAreScalarDataItemsThatContainValuesAtBindingIndexZero()
        {
            ValueSequenceDataSet dataSet = new ValueSequenceDataSet(new object[] { "a", "b" }, null, false);
            List<IDataItem> items = new List<IDataItem>(dataSet.GetItems(EmptyArray<DataBinding>.Instance, true));

            Assert.Count(2, items);

            Assert.AreEqual("a", items[0].GetValue(new DataBinding(0, null)));
            Assert.AreEqual("b", items[1].GetValue(new DataBinding(0, null)));

            Assert.IsInstanceOfType(typeof(ScalarDataItem<object>), items[0]);
            Assert.IsInstanceOfType(typeof(ScalarDataItem<object>), items[1]);
        }
        public void ItemsEnumerationIsEmptyIfDynamicAndNotIncludingDynamicRows()
        {
            ValueSequenceDataSet dataSet = new ValueSequenceDataSet(new object[] { "a" }, null, true);
            List<IDataItem> items = new List<IDataItem>(dataSet.GetItems(EmptyArray<DataBinding>.Instance, false));

            Assert.Count(0, items);
        }
 public void ColumnCountIsExactlyOne()
 {
     ValueSequenceDataSet dataSet = new ValueSequenceDataSet(EmptyArray<object>.Instance, null, true);
     Assert.AreEqual(1, dataSet.ColumnCount);
 }
 public void CanBindReturnsTrueOnlyIfTheBindingIndexIsZero(bool expectedResult, string path, object index)
 {
     ValueSequenceDataSet dataSet = new ValueSequenceDataSet(EmptyArray<object>.Instance, null, true);
     Assert.AreEqual(expectedResult, dataSet.CanBind(new DataBinding((int?) index, path)));
 }