Complete test cases

This commit is contained in:
Steve Sanderson 2019-09-28 00:58:37 +01:00 committed by Artak
parent d59baa8a24
commit e6656a68ab
1 changed files with 11 additions and 5 deletions

View File

@ -3720,11 +3720,17 @@ namespace Microsoft.AspNetCore.Components.Test
// Act/Assert // Act/Assert
var capturingComponent = (ParameterViewIllegalCapturingComponent)renderer.GetCurrentRenderTreeFrames(rootComponentId).Array[0].Component; var capturingComponent = (ParameterViewIllegalCapturingComponent)renderer.GetCurrentRenderTreeFrames(rootComponentId).Array[0].Component;
var ex = Assert.Throws<InvalidOperationException>(() => var parameterView = capturingComponent.CapturedParameterView;
{
// TODO: check other types of access too // All public APIs on capturingComponent should be electrified now
capturingComponent.CapturedParameterView.TryGetValue<object>("anything", out _); // Internal APIs don't have to be, because we won't call them at the wrong time
}); Assert.Throws<InvalidOperationException>(() => parameterView.GetEnumerator());
Assert.Throws<InvalidOperationException>(() => parameterView.GetValueOrDefault<object>("anything"));
Assert.Throws<InvalidOperationException>(() => parameterView.SetParameterProperties(new object()));
Assert.Throws<InvalidOperationException>(() => parameterView.ToDictionary());
var ex = Assert.Throws<InvalidOperationException>(() => parameterView.TryGetValue<object>("anything", out _));
// It's enough to assert about one of the messages
Assert.Equal($"The {nameof(ParameterView)} instance can no longer be read because it has expired. {nameof(ParameterView)} can only be read synchronously and must not be stored for later use.", ex.Message); Assert.Equal($"The {nameof(ParameterView)} instance can no longer be read because it has expired. {nameof(ParameterView)} can only be read synchronously and must not be stored for later use.", ex.Message);
} }