public void RenderIncludes_ShouldWriteOutEachIncludeSeparately_WhenInDebugMode(RenderingInDebug data) { var stubContext = _mocks.Stub <HttpContextBase>(); stubContext.Replay(); stubContext.Expect(c => c.IsDebuggingEnabled).Return(true); _mockHttp.Expect(s => s.Context).Return(stubContext); foreach (var kvp in data.Includes) { _mockReader.Expect(sr => sr.ToAbsolute(kvp.Key)).Return(kvp.Value); } _mockStorage.Expect(s => s.Clear()); string rendered = _combiner.RenderIncludes(data.Includes.Keys, data.Type, true); Assert.AreEqual(rendered, data.Expected); }
public void RenderCss_ShouldFlushTheSet() { var stubContext = _mocks.Stub <HttpContextBase>(); stubContext.Replay(); stubContext.Expect(c => c.IsDebuggingEnabled).Return(true); _mockHttpContextProvider.Expect(s => s.Context).Return(stubContext); _html.IncludeCss("/foo.css"); var before = _viewData[getViewDataKey(IncludeType.Css)] as IList <string>; Assert.AreEqual(1, before.Count); _html.RenderCss(true); var after = _viewData[getViewDataKey(IncludeType.Css)] as IList <string>; Assert.AreEqual(0, after.Count); }
public void TestSetup() { _viewData = new ViewDataDictionary(); _mocks = new MockRepository(); _mockHttpContextProvider = _mocks.Stub<IHttpContextProvider>(); _mockHttpContextProvider.Expect(hcp => hcp.Request).Return(_mocks.Stub<HttpRequestBase>()).Repeat.Twice(); _mockSettings = _mocks.Stub<IIncludeHandlingSettings>(); _html = WebTestUtility.BuildHtmlHelper(_mocks, _viewData, null); _mocks.ReplayAll(); var resolver = new QnDDepResolver(_mockHttpContextProvider, _mockSettings, new Controller[] { }); DependencyResolver.SetResolver(resolver); }
public void RenderIncludes_InDebugMode_ShouldClearStorage() { var stubContext = _mocks.Stub <HttpContextBase>(); stubContext.Replay(); stubContext.Expect(c => c.IsDebuggingEnabled).Return(true); _mockHttp.Expect(s => s.Context).Return(stubContext); _mockReader.Expect(r => r.ToAbsolute("foo.js")).Return("/foo.js"); _mockStorage.Expect(s => s.Clear()); string rendered = _combiner.RenderIncludes(new[] { "foo.js" }, IncludeType.Js, true); _mocks.VerifyAll(); }
public void TestSetup() { _viewData = new ViewDataDictionary(); _mocks = new MockRepository(); _mockHttpContextProvider = _mocks.Stub <IHttpContextProvider>(); _mockHttpContextProvider.Expect(hcp => hcp.Request).Return(_mocks.Stub <HttpRequestBase>()).Repeat.Twice(); _mockSettings = _mocks.Stub <IIncludeHandlingSettings>(); _html = WebTestUtility.BuildHtmlHelper(_mocks, _viewData, null); _mocks.ReplayAll(); var resolver = new QnDDepResolver(_mockHttpContextProvider, _mockSettings, new Controller[] { }); DependencyResolver.InitializeWith(resolver); }
public IncludeCombinerHtmlExtensionsFacts() { _mocks = new MockRepository(); _mockHttpContextProvider = _mocks.Stub<IHttpContextProvider>(); _mockHttpContextProvider.Expect(hcp => hcp.Request).Return(_mocks.Stub<HttpRequestBase>()).Repeat.Twice(); _mockSettings = _mocks.Stub<IIncludeHandlingSettings>(); ServiceLocator.SetLocatorProvider(() => QnDServiceLocator.Create(_mockHttpContextProvider, _mockSettings, new Controller[] { })); _viewData = new ViewDataDictionary(); _html = WebTestUtility.BuildHtmlHelper(_mocks, _viewData, null); _mocks.ReplayAll(); }