public void FindCascadingParameters_MatchingNameButMismatchingType_ReturnsEmpty() { // Arrange var states = CreateAncestry( CreateCascadingValueComponent(new ValueType2(), "MatchOnName"), new ComponentWithNamedCascadingParam()); // Act var result = CascadingParameterState.FindCascadingParameters(states.Last()); // Assert Assert.Empty(result); }
public void FindCascadingParameters_ConsumerSpecifiesNameButSupplierDoesNot_ReturnsEmpty() { // Arrange var states = CreateAncestry( CreateCascadingValueComponent(new ValueType1()), new ComponentWithNamedCascadingParam()); // Act var result = CascadingParameterState.FindCascadingParameters(states.Last()); // Assert Assert.Empty(result); }
public void FindCascadingParameters_TypeAssignmentIsInvalidForNullValue_ReturnsEmpty() { // Arrange var states = CreateAncestry( CreateCascadingValueComponent((object)null), new ComponentWithGenericCascadingParam <ValueType1>()); // Act var result = CascadingParameterState.FindCascadingParameters(states.Last()); // Assert Assert.Empty(result); }
public void FindCascadingParameters_ComponentRequestsDerivedType_ReturnsEmpty() { // Arrange var states = CreateAncestry( CreateCascadingValueComponent(new CascadingValueTypeBaseClass()), new ComponentWithGenericCascadingParam <CascadingValueTypeDerivedClass>()); // Act var result = CascadingParameterState.FindCascadingParameters(states.Last()); // Assert Assert.Empty(result); }
public void FindCascadingParameters_IfHasNoMatchesInAncestors_ReturnsEmpty() { // Arrange: Build the ancestry list var states = CreateAncestry( new ComponentWithNoParams(), CreateCascadingValueComponent("Hello"), new ComponentWithNoParams(), new ComponentWithCascadingParams()); // Act var result = CascadingParameterState.FindCascadingParameters(states.Last()); // Assert Assert.Empty(result); }
public void FindCascadingParameters_MatchingNameAndType_ReturnsMatches() { // Arrange var states = CreateAncestry( CreateCascadingValueComponent(new ValueType1(), "matchonNAME"), // To show it's case-insensitive new ComponentWithNamedCascadingParam()); // Act var result = CascadingParameterState.FindCascadingParameters(states.Last()); // Assert Assert.Collection(result, match => { Assert.Equal(nameof(ComponentWithNamedCascadingParam.SomeLocalName), match.LocalValueName); Assert.Same(states[0].Component, match.ValueSupplier); }); }
public void FindCascadingParameters_TypeAssignmentIsValidForNullValue_ReturnsMatches() { // Arrange var states = CreateAncestry( CreateCascadingValueComponent((CascadingValueTypeDerivedClass)null), new ComponentWithGenericCascadingParam <CascadingValueTypeBaseClass>()); // Act var result = CascadingParameterState.FindCascadingParameters(states.Last()); // Assert Assert.Collection(result, match => { Assert.Equal(nameof(ComponentWithGenericCascadingParam <object> .LocalName), match.LocalValueName); Assert.Same(states[0].Component, match.ValueSupplier); }); }
public void FindCascadingParameters_ComponentRequestsImplementedInterface_ReturnsMatches() { // Arrange var states = CreateAncestry( CreateCascadingValueComponent(new CascadingValueTypeDerivedClass()), new ComponentWithGenericCascadingParam <ICascadingValueTypeDerivedClassInterface>()); // Act var result = CascadingParameterState.FindCascadingParameters(states.Last()); // Assert Assert.Collection(result, match => { Assert.Equal(nameof(ComponentWithGenericCascadingParam <object> .LocalName), match.LocalValueName); Assert.Same(states[0].Component, match.ValueSupplier); }); }
public void FindCascadingParameters_IfHasPartialMatchesInAncestors_ReturnsMatches() { // Arrange var states = CreateAncestry( new ComponentWithNoParams(), CreateCascadingValueComponent(new ValueType2()), new ComponentWithNoParams(), new ComponentWithCascadingParams()); // Act var result = CascadingParameterState.FindCascadingParameters(states.Last()); // Assert Assert.Collection(result, match => { Assert.Equal(nameof(ComponentWithCascadingParams.CascadingParam2), match.LocalValueName); Assert.Same(states[1].Component, match.ValueSupplier); }); }
public void FindCascadingParameters_CanOverrideNonNullValueWithNull() { // Arrange var states = CreateAncestry( CreateCascadingValueComponent(new ValueType1()), CreateCascadingValueComponent((ValueType1)null), new ComponentWithCascadingParams()); // Act var result = CascadingParameterState.FindCascadingParameters(states.Last()); // Assert Assert.Collection(result.OrderBy(x => x.LocalValueName), match => { Assert.Equal(nameof(ComponentWithCascadingParams.CascadingParam1), match.LocalValueName); Assert.Same(states[1].Component, match.ValueSupplier); Assert.Null(match.ValueSupplier.CurrentValue); }); }
public void FindCascadingParameters_InheritedParameters_ReturnsMatches() { // Arrange var states = CreateAncestry( CreateCascadingValueComponent(new ValueType1()), CreateCascadingValueComponent(new ValueType3()), new ComponentWithInheritedCascadingParams()); // Act var result = CascadingParameterState.FindCascadingParameters(states.Last()); // Assert Assert.Collection(result.OrderBy(x => x.LocalValueName), match => { Assert.Equal(nameof(ComponentWithCascadingParams.CascadingParam1), match.LocalValueName); Assert.Same(states[0].Component, match.ValueSupplier); }, match => { Assert.Equal(nameof(ComponentWithInheritedCascadingParams.CascadingParam3), match.LocalValueName); Assert.Same(states[1].Component, match.ValueSupplier); }); }