Beispiel #1
0
        public Task SetParametersAsync(ParameterView parameters)
        {
            var suppliedName = parameters.GetValueOrDefault <string>("Name");

            if (suppliedName != _subscribedName)
            {
                _registry.Unsubscribe(_subscribedName, _onChangeCallback);
                _registry.Subscribe(suppliedName, _onChangeCallback);
                _subscribedName = suppliedName;
            }

            return(Task.CompletedTask);
        }
Beispiel #2
0
        public void CanGetValueOrDefault_WithMultipleMatchingValues()
        {
            // Arrange
            var myEntryValue = new object();
            var parameters   = new ParameterView(ParameterViewLifetime.Unbound, new[]
            {
                RenderTreeFrame.Element(0, "some element").WithElementSubtreeLength(3),
                RenderTreeFrame.Attribute(1, "my entry", myEntryValue),
                RenderTreeFrame.Attribute(1, "my entry", new object()),
            }, 0);

            // Act
            var result = parameters.GetValueOrDefault <object>("my entry");

            // Assert: Picks first match
            Assert.Same(myEntryValue, result);
        }
Beispiel #3
0
        public void CanGetValueOrDefault_WithNonExistingValue()
        {
            // Arrange
            var parameters = new ParameterView(ParameterViewLifetime.Unbound, new[]
            {
                RenderTreeFrame.Element(0, "some element").WithElementSubtreeLength(2),
                RenderTreeFrame.Attribute(1, "some other entry", new object())
            }, 0).WithCascadingParameters(new List <CascadingParameterState>
            {
                new CascadingParameterState("another entry", new TestCascadingValue(null))
            });

            // Act
            var result = parameters.GetValueOrDefault <DateTime>("nonexisting entry");

            // Assert
            Assert.Equal(default, result);
Beispiel #4
0
        public void CanGetValueOrDefault_WithExistingValue()
        {
            // Arrange
            var myEntryValue = new object();
            var parameters   = new ParameterView(ParameterViewLifetime.Unbound, new[]
            {
                RenderTreeFrame.Element(0, "some element").WithElementSubtreeLength(2),
                RenderTreeFrame.Attribute(1, "my entry", myEntryValue),
                RenderTreeFrame.Attribute(1, "my other entry", new object())
            }, 0);

            // Act
            var result = parameters.GetValueOrDefault <object>("my entry");

            // Assert
            Assert.Same(myEntryValue, result);
        }