示例#1
0
    public void IncomingCascadingValueMatchesCascadingParameter_SetsValue()
    {
        // Arrange
        var builder = new ParameterViewBuilder();

        builder.Add(nameof(HasCascadingParameter.Cascading), "hi", cascading: true);
        var parameters = builder.Build();

        var target = new HasCascadingParameter();

        // Act
        parameters.SetParameterProperties(target);

        // Assert
        Assert.Equal("hi", target.Cascading);
    }
示例#2
0
    public void NoIncomingCascadingValueMatchesDeclaredCascadingParameter_LeavesValueUnchanged()
    {
        // Arrange
        var builder    = new ParameterViewBuilder();
        var parameters = builder.Build();

        var target = new HasCascadingParameter()
        {
            Cascading = "bye",
        };

        // Act
        parameters.SetParameterProperties(target);

        // Assert
        Assert.Equal("bye", target.Cascading);
    }
示例#3
0
    public void IncomingCascadingValueMatchesNoDeclaredParameter_Throws()
    {
        // Arrange
        var builder = new ParameterViewBuilder();

        builder.Add("SomethingElse", "hi", cascading: true);
        var parameters = builder.Build();

        var target = new HasCascadingParameter();

        // Act
        var ex = Assert.Throws <InvalidOperationException>(() => parameters.SetParameterProperties(target));

        // Assert
        Assert.Equal(
            $"Object of type '{typeof(HasCascadingParameter).FullName}' does not have a property " +
            $"matching the name 'SomethingElse'.",
            ex.Message);
    }