<commit_before>﻿using System.Collections;
using System.Collections.Generic;
using System.Web;
using Moq;
using Should;
using Xunit;

namespace Cassette.Aspnet
{
    public class PlaceholderRewriter_Tests
    {
        readonly PlaceholderRewriter rewriter;
        readonly CassetteSettings settings;
        readonly Mock<IPlaceholderTracker> tracker;
        readonly Mock<HttpContextBase> httpContext;
        readonly Mock<HttpResponseBase> response;
        readonly IDictionary items;

        public PlaceholderRewriter_Tests()
        {
            settings = new CassetteSettings();
            tracker = new Mock<IPlaceholderTracker>();
            httpContext = new Mock<HttpContextBase>();
            response = new Mock<HttpResponseBase>();
            items = new Dictionary<string, object>();
            httpContext.SetupGet(c => c.Items).Returns(items);
            httpContext.SetupGet(c => c.Response).Returns(response.Object);
            rewriter = new PlaceholderRewriter(settings, () => tracker.Object, () => httpContext.Object);
        }

        [Fact]
        public void WhenAddPlaceholderTrackerToHttpContextItems_ThenTrackerAddedToHttpContextItems()
        {
            rewriter.AddPlaceholderTrackerToHttpContextItems();
            items[typeof(IPlaceholderTracker).FullName].ShouldEqual(tracker.Object);
        }

        [Fact]
        public void GivenCanRewriteOutput_WhenRewriteOutput_ThenPlaceholderReplacingResponseFilterSetForResponse()
        {
            settings.IsHtmlRewritingEnabled = true;
            ContentType("text/html");
            StatusCode(200);
<commit_msg>Fix unit test<commit_after>﻿using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Web;
using Moq;
using Should;
using Xunit;

namespace Cassette.Aspnet
{
    public class PlaceholderRewriter_Tests
    {
        readonly PlaceholderRewriter rewriter;
        readonly CassetteSettings settings;
        readonly Mock<IPlaceholderTracker> tracker;
        readonly Mock<HttpContextBase> httpContext;
        readonly Mock<HttpResponseBase> response;
        readonly IDictionary items;

        public PlaceholderRewriter_Tests()
        {
            settings = new CassetteSettings();
            tracker = new Mock<IPlaceholderTracker>();
            httpContext = new Mock<HttpContextBase>();
            response = new Mock<HttpResponseBase>();
            items = new Dictionary<string, object>();
            httpContext.SetupGet(c => c.Items).Returns(items);
            httpContext.SetupGet(c => c.Response).Returns(response.Object);
            response.SetupGet(r => r.Output.Encoding).Returns(Encoding.UTF8);
            rewriter = new PlaceholderRewriter(settings, () => tracker.Object, () => httpContext.Object);
        }

        [Fact]
        public void WhenAddPlaceholderTrackerToHttpContextItems_ThenTrackerAddedToHttpContextItems()
        {
            rewriter.AddPlaceholderTrackerToHttpContextItems();
            items[typeof(IPlaceholderTracker).FullName].ShouldEqual(tracker.Object);
        }

        [Fact]
        public void GivenCanRewriteOutput_WhenRewriteOutput_ThenPlaceholderReplacingResponseFilterSetForResponse()
        {
            settings.IsHtmlRewritingEnabled = true;
            ContentType("text/html");
            StatusCode(200);

{'fraction_non_alphanumeric': 0.08560311284046693, 'fraction_numerical': 0.0020951810835079317, 'mean_word_length': 2.931764705882353, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6032506', 'n_tokens_mistral': 849, 'n_tokens_neox': 814, 'n_words': 158}