• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Data.DataSource类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Gallio.Framework.Data.DataSource的典型用法代码示例。如果您正苦于以下问题:C# DataSource类的具体用法?C# DataSource怎么用?C# DataSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DataSource类属于Gallio.Framework.Data命名空间,在下文中一共展示了DataSource类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: AccessorObtainsAValueFromTheRow

        public void AccessorObtainsAValueFromTheRow()
        {
            DataBinding binding = new DataBinding(0, null);
            ScalarDataBinder binder = new ScalarDataBinder(binding, "name");

            IDataSourceResolver resolver = Mocks.StrictMock<IDataSourceResolver>();
            DataBindingContext context = new DataBindingContext(new NullConverter());

            DataSource source = new DataSource("name");
            source.AddDataSet(new ItemSequenceDataSet(new IDataItem[]
            {
                new ScalarDataItem<int>(42, null, false),
                new ScalarDataItem<string>("42", null, false)
            }, 1));

            using (Mocks.Record())
            {
                Expect.Call(resolver.ResolveDataSource("name")).Return(source);
            }

            using (Mocks.Playback())
            {
                IDataAccessor accessor = binder.Register(context, resolver);
                Assert.IsTrue(context.DataSets.Contains(source), "The data sets list should contain the source that was resolved during binder registration.");

                List<IDataItem> items = new List<IDataItem>(context.GetItems(true));
                Assert.Count(2, items);

                Assert.AreEqual(42, accessor.GetValue(items[0]));
                Assert.AreEqual("42", accessor.GetValue(items[1]));
            }
        }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:32,代码来源:ScalarDataBinderTest.cs


示例2: PopulateDataSource

 protected override void PopulateDataSource(IPatternScope scope, DataSource dataSource, ICodeElementInfo codeElement)
 {
     for (int i = 1; i <= count; i++)
     {
         var row = new object[] { i, "Hello from #" + i };
         dataSource.AddDataSet(new ItemSequenceDataSet(new IDataItem[] { new ListDataItem<object>(row, GetMetadata(), false) }, row.Length));
     }
 }
开发者ID:KidFashion,项目名称:UBL.net,代码行数:8,代码来源:Example.cs


示例3: PopulateDataSource

 /// <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);
     }
 }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:10,代码来源:TextDataAttribute.cs


示例4: PopulateDataSource

 /// <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);
     }
 }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:11,代码来源:BinaryDataAttribute.cs


示例5: DefineDataSource

        /// <inheritdoc />
        public DataSource DefineDataSource(string name)
        {
            if (name == null)
                throw new ArgumentNullException("name");

            DataSource source;

            if (sources != null)
            {
                if (sources.TryGetValue(name, out source))
                    return source;
            }
            else
            {
                sources = new Dictionary<string, DataSource>();
            }

            source = new DataSource(name);
            sources.Add(name, source);
            return source;
        }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:22,代码来源:DataSourceTable.cs


示例6: CanBindAppliesNoTranslationIfNoAliasesAreDefined

        public void CanBindAppliesNoTranslationIfNoAliasesAreDefined()
        {
            IDataSet dataSet = Mocks.StrictMock<IDataSet>();

            using (Mocks.Record())
            {
                SetupResult.For(dataSet.ColumnCount).Return(2);

                Expect.Call(dataSet.CanBind(null)).IgnoreArguments().Do((CanBindDelegate)delegate(DataBinding binding)
                {
                    Assert.AreEqual("untranslatedPath", binding.Path);
                    Assert.AreEqual(5, binding.Index);
                    return false;
                });
            }

            using (Mocks.Playback())
            {
                DataSource source = new DataSource("theName");
                source.AddDataSet(dataSet);

                Assert.IsFalse(source.CanBind(new DataBinding(5, "untranslatedPath")));
            }
        }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:24,代码来源:DataSourceTest.cs


示例7: PopulateDataSource

 protected override void PopulateDataSource(IPatternScope scope, DataSource dataSource, Gallio.Common.Reflection.ICodeElementInfo codeElement)
 {
     dataSource.AddDataSet(new SharedDataSet());
     base.PopulateDataSource(scope, dataSource, codeElement);
 }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:5,代码来源:SharedDataSetTest.cs


示例8: PopulateDataSource

 protected override void PopulateDataSource(IPatternScope scope, DataSource dataSource, ICodeElementInfo codeElement)
 {
     object[] values = Enumerable.Range(1, count).Select<int, object>(i => Convert.ToChar((Convert.ToInt32('A') + i - 1)).ToString()).ToArray();
     dataSource.AddDataSet(new ValueSequenceDataSet(values, GetMetadata(), false));
 }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:5,代码来源:Example.cs


示例9: TranslatedDataItem

 public TranslatedDataItem(DataSource source, IDataItem item)
 {
     this.source = source;
     this.item = item;
 }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:5,代码来源:DataSource.cs


示例10: PopulateDataSource

 /// <summary>
 /// Populates the data source with the contributions of this attribute.
 /// </summary>
 /// <param name="scope">The scope.</param>
 /// <param name="dataSource">The data source.</param>
 /// <param name="codeElement">The code element.</param>
 protected virtual void PopulateDataSource(IPatternScope scope, DataSource dataSource, ICodeElementInfo codeElement)
 {
 }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:9,代码来源:DataPatternAttribute.cs


示例11: PopulateDataSource

 /// <inheritdoc />
 protected override void PopulateDataSource(IPatternScope scope, DataSource dataSource, ICodeElementInfo codeElement)
 {
     var invoker = new FixtureMemberInvoker<IEnumerable>(type, scope, memberName);
     var dataSet = new FactoryDataSet(() => invoker.Invoke(), kind, columnCount);
     dataSource.AddDataSet(dataSet);
 }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:7,代码来源:FactoryAttribute.cs


示例12: TranslateBindingSupportsReplaceIndex

        public void TranslateBindingSupportsReplaceIndex()
        {
            JoinedDataSet dataSet = new JoinedDataSet();
            DataSource source = new DataSource("dummy");
            dataSet.AddDataSet(source);

            DataBinding dataBinding = dataSet.TranslateBinding(source, new DataBinding(null, "path"));
            Assert.IsNull(dataBinding.Index);
            Assert.AreEqual("path", dataBinding.Path);

            DataBinding changedDataBinding = dataBinding.ReplaceIndex(5);
            Assert.AreEqual(5, changedDataBinding.Index);
            Assert.AreEqual("path", dataBinding.Path);
        }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:14,代码来源:JoinedDataSetTest.cs


示例13: GetItemsDelegatesToTheStrategy

        public void GetItemsDelegatesToTheStrategy()
        {
            JoinedDataSet dataSet = new JoinedDataSet();

            IList<KeyValuePair<string, string>> metadata1 = new KeyValuePair<string, string>[]
            {
                new KeyValuePair<string, string>("abc", "123"),
                new KeyValuePair<string, string>("def", "456")
            };
            IList<KeyValuePair<string, string>> metadata2 = new KeyValuePair<string, string>[]
            {
                new KeyValuePair<string, string>("ghi", "789"),
            };

            DataSource dataSet1 = new DataSource("");
            dataSet1.AddIndexAlias("path", 1);
            dataSet1.AddDataSet(new ItemSequenceDataSet(new IDataItem[]
            {
                new ListDataItem<int>(new int[] { 1, 2, 3 }, metadata1, false),
                new ListDataItem<int>(new int[] { -1, -2, -3 }, metadata2, false)
            }, 3));
            dataSet.AddDataSet(dataSet1);

            IDataSet dataSet2 = new ItemSequenceDataSet(new IDataItem[]
            {
                new ListDataItem<int>(new int[] { 4, 5 }, metadata2, false),
                new ListDataItem<int>(new int[] { -4, -5 }, null, true)
            }, 2);
            dataSet.AddDataSet(dataSet2);

            List<IDataItem> dataSet1Items = new List<IDataItem>(dataSet1.GetItems(EmptyArray<DataBinding>.Instance, true));
            List<IDataItem> dataSet2Items = new List<IDataItem>(dataSet2.GetItems(EmptyArray<DataBinding>.Instance, true));

            List<IList<IDataItem>> results = new List<IList<IDataItem>>();
            results.Add(new IDataItem[] { dataSet1Items[0], dataSet2Items[0] });
            results.Add(new IDataItem[] { dataSet1Items[1], dataSet2Items[1] });

            IJoinStrategy strategy = Mocks.StrictMock<IJoinStrategy>();
            dataSet.Strategy = strategy;

            DataBinding pathBinding = new DataBinding(null, "path");
            DataBinding indexZeroBinding = new DataBinding(0, null);
            DataBinding indexOneBinding = new DataBinding(1, null);
            DataBinding indexThreeBinding = new DataBinding(3, null);

            DataBinding[] bindings = new DataBinding[]
            {
                new DataBinding(null, null), // unresolvable binding because no data sets can claim it
                pathBinding, // claimed by dataSet1
                indexZeroBinding, // claimed by dataSet1
                indexThreeBinding, // claimed by dataSet2
                dataSet.TranslateBinding(dataSet1, pathBinding), // scoped by dataSet1
                dataSet.TranslateBinding(dataSet2, indexOneBinding), // scoped by dataSet2
            };

            using (Mocks.Record())
            {
                Expect.Call(strategy.Join(null, null, true)).IgnoreArguments().Do((JoinDelegate)delegate(IList<IDataProvider> joinProviders, IList<ICollection<DataBinding>> joinBindingsPerProvider,
                    bool includeDynamicItems)
                {
                    Assert.IsTrue(includeDynamicItems);
                    Assert.AreElementsEqual(new IDataProvider[] { dataSet1, dataSet2 }, joinProviders);

                    Assert.Count(2, joinBindingsPerProvider);

                    Assert.AreElementsEqual(new DataBinding[] { pathBinding, indexZeroBinding, pathBinding }, joinBindingsPerProvider[0]);
                    Assert.AreElementsEqual(new DataBinding[] { indexZeroBinding, indexOneBinding }, joinBindingsPerProvider[1]);

                    return results;
                });
            }

            using (Mocks.Playback())
            {
                List<IDataItem> items = new List<IDataItem>(dataSet.GetItems(bindings, true));
                Assert.Count(2, items);

                Assert.Throws<ArgumentNullException>(delegate { items[0].GetValue(null); });

                Assert.Throws<DataBindingException>(delegate { items[0].GetValue(bindings[0]); });
                Assert.AreEqual(2, items[0].GetValue(bindings[1]));
                Assert.AreEqual(1, items[0].GetValue(bindings[2]));
                Assert.AreEqual(4, items[0].GetValue(bindings[3]));
                Assert.AreEqual(2, items[0].GetValue(bindings[4]));
                Assert.AreEqual(5, items[0].GetValue(bindings[5]));

                PropertyBag map = DataItemUtils.GetMetadata(items[0]);
                Assert.Count(3, map);
                Assert.AreEqual("123", map.GetValue("abc"));
                Assert.AreEqual("456", map.GetValue("def"));
                Assert.AreEqual("789", map.GetValue("ghi"));

                Assert.IsFalse(items[0].IsDynamic);

                Assert.Throws<DataBindingException>(delegate { items[1].GetValue(bindings[0]); });
                Assert.AreEqual(-2, items[1].GetValue(bindings[1]));
                Assert.AreEqual(-1, items[1].GetValue(bindings[2]));
                Assert.AreEqual(-4, items[1].GetValue(bindings[3]));
                Assert.AreEqual(-2, items[1].GetValue(bindings[4]));
                Assert.AreEqual(-5, items[1].GetValue(bindings[5]));
//.........这里部分代码省略.........
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:101,代码来源:JoinedDataSetTest.cs


示例14: CanBindResolvesScopedBindings

        public void CanBindResolvesScopedBindings()
        {
            JoinedDataSet dataSet = new JoinedDataSet();

            DataSource dataSet1 = new DataSource("");
            dataSet1.AddIndexAlias("path", 1);
            dataSet1.AddDataSet(new ItemSequenceDataSet(EmptyArray<IDataItem>.Instance, 3));
            IDataSet dataSet2 = new ItemSequenceDataSet(EmptyArray<IDataItem>.Instance, 2);

            dataSet.AddDataSet(dataSet1);
            dataSet.AddDataSet(dataSet2);

            Assert.IsFalse(dataSet.CanBind(dataSet.TranslateBinding(dataSet1, new DataBinding(null, null))),
                "Cannot bind because there is no path or index in the translated binding.");
            Assert.IsFalse(dataSet.CanBind(dataSet.TranslateBinding(dataSet1, new DataBinding(3, null))),
                "Cannot bind because index 3 is beyond the range of columns in the scoped data set.");
            Assert.IsFalse(dataSet.CanBind(dataSet.TranslateBinding(dataSet2, new DataBinding(2, null))),
                "Cannot bind because index 2 is beyond the range of columns in the scoped data set.");
            Assert.IsTrue(dataSet.CanBind(dataSet.TranslateBinding(dataSet2, new DataBinding(1, null))),
                "Can bind because index 1 is within the range of columns in the scoped data set.");
            Assert.IsTrue(dataSet.CanBind(dataSet.TranslateBinding(dataSet1, new DataBinding(null, "path"))),
                "Can bind because path is supported by one of the scoped data set.");
            Assert.IsFalse(dataSet.CanBind(dataSet.TranslateBinding(dataSet2, new DataBinding(null, "path"))),
                "Cannot bind because path is supported by one of the scoped data set.");
        }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:25,代码来源:JoinedDataSetTest.cs


示例15: CanBindResolvesExternalBindings

        public void CanBindResolvesExternalBindings()
        {
            JoinedDataSet dataSet = new JoinedDataSet();

            DataSource dataSet1 = new DataSource("");
            dataSet1.AddIndexAlias("path", 1);
            dataSet1.AddDataSet(new ItemSequenceDataSet(EmptyArray<IDataItem>.Instance, 3));
            IDataSet dataSet2 = new ItemSequenceDataSet(EmptyArray<IDataItem>.Instance, 2);

            dataSet.AddDataSet(dataSet1);
            dataSet.AddDataSet(dataSet2);

            Assert.IsFalse(dataSet.CanBind(new DataBinding(null, null)),
                "Cannot bind because there is no path or index.");
            Assert.IsFalse(dataSet.CanBind(new DataBinding(5, null)),
                "Cannot bind because index 5 is beyond the range of columns in the joined data set.");
            Assert.IsTrue(dataSet.CanBind(new DataBinding(4, null)),
                "Can bind because index 4 is within the range of columns in the joined data set.");
            Assert.IsTrue(dataSet.CanBind(new DataBinding(0, null)),
                "Can bind because index 0 is within the range of columns in the joined data set.");
            Assert.IsTrue(dataSet.CanBind(new DataBinding(null, "path")),
                "Can bind because path is supported by one of the data sets.");
        }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:23,代码来源:JoinedDataSetTest.cs


示例16: GetItemsAppliesIndexAliasTranslation

        public void GetItemsAppliesIndexAliasTranslation()
        {
            List<KeyValuePair<string, string>> metadataPairs = new List<KeyValuePair<string, string>>();
            metadataPairs.Add(new KeyValuePair<string, string>("Foo", "Bar"));
            IDataSet dataSet = Mocks.StrictMock<IDataSet>();

            using (Mocks.Record())
            {
                SetupResult.For(dataSet.ColumnCount).Return(3);

                Expect.Call(dataSet.GetItems(null, true)).IgnoreArguments().Do((GetItemsDelegate)delegate(ICollection<DataBinding> bindings,
                    bool includeDynamicItems)
                {
                    Assert.IsTrue(includeDynamicItems);

                    List<IDataItem> items = new List<IDataItem>();
                    items.Add(new ListDataItem<object>(new object[] { "abc", "def", "ghi" }, metadataPairs, true));

                    List<DataBinding> bindingList = new List<DataBinding>(bindings);

                    Assert.AreEqual("translatedPath", bindingList[0].Path);
                    Assert.AreEqual(2, bindingList[0].Index);

                    Assert.AreEqual("untranslatedPath", bindingList[1].Path);
                    Assert.AreEqual(1, bindingList[1].Index);

                    return items;
                });
            }

            using (Mocks.Playback())
            {
                DataSource source = new DataSource("theName");
                source.AddIndexAlias("translatedPath", 2);
                source.AddDataSet(dataSet);

                DataBinding[] bindings = new DataBinding[] {
                    new DataBinding(5, "translatedPath"),
                    new DataBinding(1, "untranslatedPath")
                };

                List<IDataItem> items = new List<IDataItem>(source.GetItems(bindings, true));
                Assert.Count(1, items);

                PropertyBag map = DataItemUtils.GetMetadata(items[0]);
                Assert.Count(1, map);
                Assert.AreEqual("Bar", map.GetValue("Foo"));

                Assert.Throws<ArgumentNullException>(delegate { items[0].GetValue(null); });
                Assert.AreEqual("ghi", items[0].GetValue(bindings[0]));
                Assert.AreEqual("def", items[0].GetValue(bindings[1]));

                // Should throw ArgumentNullException when binding list is null.
                Assert.Throws<ArgumentNullException>(delegate
                {
                    items[0].GetValue(null);
                });
            }
        }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:59,代码来源:DataSourceTest.cs


示例17: CanGetDescriptiveDataBindingsFromItem

        public void CanGetDescriptiveDataBindingsFromItem()
        {
            DataSource dataSet = new DataSource("Source");
            dataSet.AddDataSet(new ItemSequenceDataSet(new[] { new DataRow("abc", "def") }, 2));
            dataSet.AddIndexAlias("xxx", 1);

            List<IDataItem> items = new List<IDataItem>(dataSet.GetItems(EmptyArray<DataBinding>.Instance, true));

            Assert.AreElementsEqual(new[]
            {
                new DataBinding(0, null),
                new DataBinding(1, "xxx")
            }, items[0].GetBindingsForInformalDescription());
        }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:14,代码来源:DataSourceTest.cs


示例18: PopulateDataSource

 /// <inheritdoc />
 protected override void PopulateDataSource(IPatternScope scope, DataSource dataSource, ICodeElementInfo codeElement)
 {
     for (int i = 0; i < columnNames.Length; i++)
         dataSource.AddIndexAlias(columnNames[i], i);
 }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:6,代码来源:HeaderAttribute.cs


示例19: NameIsSameAsWasSpecifiedInTheConstructor

 public void NameIsSameAsWasSpecifiedInTheConstructor()
 {
     DataSource source = new DataSource("theName");
     Assert.AreEqual("theName", source.Name);
 }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:5,代码来源:DataSourceTest.cs


示例20: PopulateDataSource

 /// <inheritdoc />
 protected override void PopulateDataSource(IPatternScope scope, DataSource dataSource, ICodeElementInfo codeElement)
 {
     dataSource.AddDataSet(new ValueSequenceDataSet(GetValues(), GetMetadata(), false));
 }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:5,代码来源:EnumDataAttribute.cs



注:本文中的Gallio.Framework.Data.DataSource类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Game.World类代码示例发布时间:2022-05-26
下一篇:
C# node.TypedList类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap