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 });
        }
Example #2
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)));
 }
 public void Test004()
 {
     ComponentParameter.CreateParameter(string.Empty, string.Empty)
     .Equals(new object())
     .ShouldBeFalse();
 }
Example #4
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)));
 }
Example #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(string name, Func <object, Task> callback)
 {
     return(ComponentParameter.CreateParameter(name, new EventCallback(null, callback)));
 }
Example #6
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>()));
 }
Example #7
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));
 }
Example #8
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()));
 }
Example #9
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));
 }
Example #10
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)));
 }
Example #11
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)));
 }
Example #12
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)));
 }