Exemple #1
0
    public void Reinitialize_AllowsContextToBeReused()
    {
        // Arrange
        var tagName          = "test";
        var initialUniqueId  = "123";
        var expectedUniqueId = "456";
        var initialItems     = new Dictionary <object, object>
        {
            { "test-entry", 1234 }
        };
        var expectedItems = new Dictionary <object, object>
        {
            { "something", "new" }
        };
        var initialAttributes = new TagHelperAttributeList
        {
            { "name", "value" }
        };
        var context = new TagHelperContext(
            tagName,
            initialAttributes,
            initialItems,
            initialUniqueId);

        // Act
        context.Reinitialize(tagName, expectedItems, expectedUniqueId);

        // Assert
        Assert.Equal(tagName, context.TagName);
        Assert.Same(expectedItems, context.Items);
        Assert.Equal(expectedUniqueId, context.UniqueId);
        Assert.Empty(context.AllAttributes);
    }