Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace MyTested.AspNetCore.Mvc.Builders.Contracts.Models
{
using System;
using System.Collections.Generic;

/// <summary>
Expand Down Expand Up @@ -28,5 +29,19 @@ public interface IModelStateBuilder
/// <param name="errors">Model state entries as anonymous object.</param>
/// <returns></returns>
IAndModelStateBuilder WithErrors(object errors);

/// <summary>
/// Tests whether the model state entry passes the given assertions.
/// </summary>
/// <param name="assertions">Action containing all assertions for the model state entry.</param>
/// <returns>The same <see cref="IAndModelStateBuilder"/>.</returns>
IAndModelStateBuilder Passing(Action assertions);

/// <summary>
/// Tests whether the data provider entry passes the given predicate.
/// </summary>
/// <param name="predicate">Predicate testing the data provider entry.</param>
/// <returns>The same <see cref="IAndModelStateBuilder"/>.</returns>
IAndModelStateBuilder Passing(Func<bool> predicate);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Contracts.Models;
using Internal.TestContexts;
using Utilities.Extensions;
using System;

/// <summary>
/// Used for building <see cref="ModelStateDictionary"/>
Expand Down Expand Up @@ -54,5 +55,17 @@ public IAndModelStateBuilder WithErrors(object errors)

private void AddError(string key, string errorMessage)
=> this.ModelState.AddModelError(key, errorMessage);

/// <inheritdoc />
public IAndModelStateBuilder Passing(Action assertions)
{
throw new NotImplementedException();
}

/// <inheritdoc />
public IAndModelStateBuilder Passing(Func<bool> predicate)
{
throw new NotImplementedException();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,20 @@ public interface IViewBagTestBuilder
/// <param name="entries">Dictionary of view bag entries.</param>
/// <returns>The same <see cref="IAndViewBagTestBuilder"/>.</returns>
IAndViewBagTestBuilder ContainingEntries(IDictionary<string, object> entries);


/// <summary>
/// Tests whether the view bag entry passes the given assertions.
/// </summary>
/// <param name="assertions">Action containing all assertions for the view bag entry.</param>
/// <returns>The same <see cref="IAndViewBagTestBuilder"/>.</returns>
IAndViewBagTestBuilder Passing(Action assertions);

/// <summary>
/// Tests whether the view bag entry passes the given predicate.
/// </summary>
/// <param name="predicate">Predicate testing the view bag entry.</param>
/// <returns>The same <see cref="IAndViewBagTestBuilder"/>.</returns>
IAndViewBagTestBuilder Passing(Func< bool> predicate);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace MyTested.AspNetCore.Mvc.Builders.Data
{
using System;
using System.Collections.Generic;
using Contracts.Data;
using Internal.TestContexts;
Expand Down Expand Up @@ -32,10 +33,23 @@ public ViewBagTestBuilder(ComponentTestContext testContext)
/// <inheritdoc />
public IViewBagTestBuilder AndAlso() => this;

/// <inheritdoc />
public IAndViewBagTestBuilder Passing(Action assertions)
{
throw new NotImplementedException();
}

/// <inheritdoc />
public IAndViewBagTestBuilder Passing(Func<bool> predicate)
{
throw new NotImplementedException();
}

/// <summary>
/// When overridden in derived class provides a way to built the data provider as <see cref="IDictionary{TKey,TValue}"/>.
/// </summary>
/// <returns>Data provider as <see cref="IDictionary{TKey,TValue}"/></returns>
protected override IDictionary<string, object> GetDataProvider() => this.testContext.GetViewData();

}
}