コード例 #1
0
        public static IEnumerable <object[]> GetEqualsTestData()
        {
            var name  = "foo";
            var value = "bar";
            var p1    = ComponentParameter.CreateParameter(name, value);
            var p2    = ComponentParameter.CreateParameter(name, value);
            var p3    = ComponentParameter.CreateCascadingValue(name, value);
            var p4    = ComponentParameter.CreateParameter(string.Empty, value);
            var p5    = ComponentParameter.CreateParameter(name, string.Empty);

            yield return(new object[] { p1, p1, true });

            yield return(new object[] { p1, p2, true });

            yield return(new object[] { p3, p3, true });

            yield return(new object[] { p1, p3, false });

            yield return(new object[] { p1, p4, false });

            yield return(new object[] { p1, p5, false });
        }
コード例 #2
0
 public void Test004()
 {
     ComponentParameter.CreateParameter(string.Empty, string.Empty)
     .Equals(new object())
     .ShouldBeFalse();
 }
コード例 #3
0
 public void Test002()
 {
     Should.Throw <ArgumentNullException>(() => ComponentParameter.CreateParameter(null !, null));
     Should.Throw <ArgumentNullException>(() => { ComponentParameter p = (null, null, false); });
 }
コード例 #4
0
 public void Test001()
 {
     Should.Throw <ArgumentNullException>(() => ComponentParameter.CreateCascadingValue(null, null !));
     Should.Throw <ArgumentNullException>(() => { ComponentParameter p = (null, null, true); });
 }
コード例 #5
0
 /// <summary>
 /// Creates a <see cref="ComponentParameter"/> with an <see cref="Microsoft.AspNetCore.Components.EventCallback"/> that will call the provided <paramref name="callback"/>.
 /// </summary>
 /// <param name="name">Parameter name.</param>
 /// <param name="callback">The event callback.</param>
 /// <returns>The <see cref="ComponentParameter"/>.</returns>
 public static ComponentParameter EventCallback <TValue>(string name, Func <TValue, Task> callback)
 {
     return(ComponentParameter.CreateParameter(name, new EventCallback <TValue>(null, callback)));
 }
コード例 #6
0
 /// <summary>
 /// Creates a <see cref="ComponentParameter"/> with an <see cref="Microsoft.AspNetCore.Components.EventCallback"/> that will call the provided <paramref name="callback"/>.
 /// </summary>
 /// <param name="name">Parameter name.</param>
 /// <param name="callback">The event callback.</param>
 /// <returns>The <see cref="ComponentParameter"/>.</returns>
 public static ComponentParameter EventCallback(string name, Func <object, Task> callback)
 {
     return(ComponentParameter.CreateParameter(name, new EventCallback(null, callback)));
 }
コード例 #7
0
 /// <summary>
 /// Creates a <see cref="ComponentParameter"/> with an <see cref="Microsoft.AspNetCore.Components.EventCallback"/> that will call the provided <paramref name="callback"/>.
 /// </summary>
 /// <param name="name">Parameter name.</param>
 /// <param name="callback">The event callback.</param>
 /// <returns>The <see cref="ComponentParameter"/>.</returns>
 public static ComponentParameter EventCallback(string name, Action callback)
 {
     return(ComponentParameter.CreateParameter(name, new EventCallback(null, callback)));
 }
コード例 #8
0
 /// <summary>
 /// Creates a <see cref="ComponentParameter"/> with an <see cref="Microsoft.AspNetCore.Components.EventCallback"/> as parameter value
 /// for this <see cref="TestContext"/> and
 /// <paramref name="callback"/>.
 /// </summary>
 /// <param name="name">Parameter name.</param>
 /// <param name="callback">The event callback.</param>
 /// <returns>The <see cref="ComponentParameter"/>.</returns>
 protected ComponentParameter EventCallback(string name, Action callback)
 {
     return(ComponentParameter.CreateParameter(name, EC.Factory.Create(this, callback)));
 }
コード例 #9
0
 /// <summary>
 /// Creates a <see cref="Microsoft.AspNetCore.Components.RenderFragment"/> which will render a <typeparamref name="TComponent"/> component
 /// with the provided <paramref name="parameters"/> as input, and passes it to the parameter specified in <paramref name="name"/>.
 /// </summary>
 /// <typeparam name="TComponent">The type of the component to render with the <see cref="Microsoft.AspNetCore.Components.RenderFragment"/></typeparam>
 /// <param name="name">Parameter name.</param>
 /// <param name="parameters">Parameters to pass to the <typeparamref name="TComponent"/>.</param>
 /// <returns>The <see cref="ComponentParameter"/>.</returns>
 public static ComponentParameter RenderFragment <TComponent>(string name, params ComponentParameter[] parameters) where TComponent : class, IComponent
 {
     return(ComponentParameter.CreateParameter(name, parameters.ToComponentRenderFragment <TComponent>()));
 }
コード例 #10
0
 /// <summary>
 /// Creates a <see cref="Microsoft.AspNetCore.Components.RenderFragment"/> with the provided
 /// <paramref name="markup"/> as rendered output and passes it to the parameter specified in <paramref name="name"/>.
 /// </summary>
 /// <param name="name">Parameter name.</param>
 /// <param name="markup">Markup to pass to the render fragment parameter</param>
 /// <returns>The <see cref="ComponentParameter"/>.</returns>
 public static ComponentParameter RenderFragment(string name, string markup)
 {
     return(ComponentParameter.CreateParameter(name, markup.ToMarkupRenderFragment()));
 }
コード例 #11
0
 /// <summary>
 /// Creates a cascading value which can be passed to a test contexts render methods.
 /// </summary>
 /// <param name="value">Value of the parameter</param>
 /// <returns>The <see cref="ComponentParameter"/>.</returns>
 public static ComponentParameter CascadingValue(object value)
 {
     return(ComponentParameter.CreateCascadingValue(null, value));
 }
コード例 #12
0
 /// <summary>
 /// Creates a cascading value which can be passed to a test contexts render methods.
 /// </summary>
 /// <param name="name">Parameter name</param>
 /// <param name="value">Value of the parameter</param>
 /// <returns>The <see cref="ComponentParameter"/>.</returns>
 public static ComponentParameter CascadingValue(string name, object value)
 {
     return(ComponentParameter.CreateCascadingValue(name, value));
 }
コード例 #13
0
 /// <summary>
 /// Creates a component parameter which can be passed to a test contexts render methods.
 /// </summary>
 /// <param name="name">Parameter name</param>
 /// <param name="value">Value or null of the parameter</param>
 /// <returns>The <see cref="ComponentParameter"/>.</returns>
 public static ComponentParameter Parameter(string name, object?value)
 {
     return(ComponentParameter.CreateParameter(name, value));
 }
コード例 #14
0
 /// <summary>
 /// Creates a <see cref="ComponentParameter"/> with an <see cref="Microsoft.AspNetCore.Components.EventCallback"/> as parameter value for this <see cref="TestContext"/> and
 /// <paramref name="callback"/>.
 /// </summary>
 /// <param name="name">Parameter name.</param>
 /// <param name="callback">The event callback.</param>
 /// <returns>The <see cref="ComponentParameter"/>.</returns>
 protected ComponentParameter EventCallback(string name, Func <object, Task> callback)
 {
     return(ComponentParameter.CreateParameter(name, EC.Factory.Create(this, callback)));
 }
コード例 #15
0
 public void Test005(ComponentParameter left, ComponentParameter right, bool expectedResult)
 {
     left.GetHashCode().Equals(right.GetHashCode()).ShouldBe(expectedResult);
 }
コード例 #16
0
 /// <summary>
 /// Creates a template component parameter which will pass the <paramref name="template"/> <see cref="Microsoft.AspNetCore.Components.RenderFragment{TValue}" />
 /// to the parameter with the name <paramref name="name"/>.
 /// </summary>
 /// <typeparam name="TValue">The value used to build the content.</typeparam>
 /// <param name="name">Parameter name.</param>
 /// <param name="template"><see cref="Microsoft.AspNetCore.Components.RenderFragment{TValue}" /> to pass to the parameter.</param>
 /// <returns>The <see cref="ComponentParameter"/>.</returns>
 public static ComponentParameter Template <TValue>(string name, RenderFragment <TValue> template)
 {
     return(ComponentParameter.CreateParameter(name, template));
 }
コード例 #17
0
 /// <summary>
 /// Creates a <see cref="ComponentParameter"/> with an <see cref="Microsoft.AspNetCore.Components.EventCallback"/> as parameter value for this <see cref="TestContext"/> and
 /// <paramref name="callback"/>.
 /// </summary>
 /// <param name="name">Parameter name.</param>
 /// <param name="callback">The event callback.</param>
 /// <returns>The <see cref="ComponentParameter"/>.</returns>
 protected ComponentParameter EventCallback <TValue>(string name, Func <TValue, Task> callback)
 {
     return(ComponentParameter.CreateParameter(name, EC.Factory.Create <TValue>(this, callback)));
 }