Пример #1
0
        public void CompositeBindingSourceTest_CanAcceptDataFrom_NoMatch()
        {
            // Arrange
            var composite = CompositeBindingSource.Create(
                bindingSources: new BindingSource[] { BindingSource.Query, BindingSource.Form },
                displayName: "Test Source1");

            // Act
            var result = composite.CanAcceptDataFrom(BindingSource.Path);

            // Assert
            Assert.False(result);
        }
Пример #2
0
        public void BindingSourceValueProvider_ThrowsOnCompositeSource()
        {
            // Arrange
            var expected = $"The provided binding source 'Test Source' is a composite. '{nameof(BindingSourceValueProvider)}' " +
                           "requires that the source must represent a single type of input.";

            var bindingSource = CompositeBindingSource.Create(
                bindingSources: new BindingSource[] { BindingSource.Query, BindingSource.Form },
                displayName: "Test Source");

            // Act & Assert
            ExceptionAssert.ThrowsArgument(
                () => new TestableBindingSourceValueProvider(bindingSource),
                "bindingSource",
                expected);
        }
Пример #3
0
        public void BindingSource_CanAcceptDataFrom_ThrowsOnComposite()
        {
            // Arrange
            var expected = "The provided binding source 'Test Source' is a composite. " +
                           $"'{nameof(BindingSource.CanAcceptDataFrom)}' requires that the source must represent a single type of input.";

            var bindingSource = CompositeBindingSource.Create(
                bindingSources: new BindingSource[] { BindingSource.Query, BindingSource.Form },
                displayName: "Test Source");

            // Act & Assert
            ExceptionAssert.ThrowsArgument(
                () => BindingSource.Query.CanAcceptDataFrom(bindingSource),
                "bindingSource",
                expected);
        }
        public void BindingSourceValueProvider_ThrowsOnCompositeSource()
        {
            // Arrange
            var expected =
                "The provided binding source 'Test Source' is a composite. " +
                "'BindingSourceValueProvider' requires that the source must represent a single type of input." +
                Environment.NewLine +
                "Parameter name: bindingSource";

            var bindingSource = CompositeBindingSource.Create(
                bindingSources: new BindingSource[] { BindingSource.Query, BindingSource.Form },
                displayName: "Test Source");

            // Act & Assert
            var exception = Assert.Throws <ArgumentException>(
                () => new TestableBindingSourceValueProvider(bindingSource));

            Assert.Equal(expected, exception.Message);
        }
        public void CompositeBindingSourceTest_CanAcceptDataFrom_ThrowsOnComposite()
        {
            // Arrange
            var expected =
                "The provided binding source 'Test Source2' is a composite. " +
                "'CanAcceptDataFrom' requires that the source must represent a single type of input." +
                Environment.NewLine +
                "Parameter name: bindingSource";

            var composite1 = CompositeBindingSource.Create(
                bindingSources: new BindingSource[] { BindingSource.Query, BindingSource.Form },
                displayName: "Test Source1");

            var composite2 = CompositeBindingSource.Create(
                bindingSources: new BindingSource[] { BindingSource.Query, BindingSource.Form },
                displayName: "Test Source2");


            // Act & Assert
            var exception = Assert.Throws <ArgumentException>(
                () => composite1.CanAcceptDataFrom(composite2));

            Assert.Equal(expected, exception.Message);
        }