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.");
        }
        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.");
        }
 public void CanBindReturnsFalseIfThereAreNoDataSets()
 {
     JoinedDataSet dataSet = new JoinedDataSet();
     Assert.IsFalse(dataSet.CanBind(new DataBinding(0, null)),
         "Cannot bind because there are no data sets.");
 }