public void WhenErrorSummaryItemInvoked_TheViewModelIsUpdated(string key, string value) { var values = new Dictionary <string, string>() { { key, value } }; var component = new ErrorSummaryItem(); component.ViewComponentContext = ViewComponentTestHelper.GetViewComponentContext(); ViewViewComponentResult result = component.Invoke(values) as ViewViewComponentResult; ErrorSummaryItemModel resultModel = (ErrorSummaryItemModel)result.ViewData.Model; //Assert value.Should().Be(ViewComponentTestHelper.GetPropertyValue(resultModel, key)); }
public void AddItem_AddsItemToItems() { // Arrange var context = new ErrorSummaryContext(); var item = new ErrorSummaryItem() { Content = new HtmlString("An error message"), Href = "#TheField" }; // Act context.AddItem(item); // Assert Assert.Collection( context.Items, item => { Assert.Equal("An error message", item.Content.RenderToString()); Assert.Equal("#TheField", item.Href); }); }