public void RenderIncludes_ShouldWriteOutASingleReferenceToTheCompressorController_WhenInReleaseMode(IDictionary<string, string> includes, IncludeType type, string key, string expected, IncludeTypeElement settings) { var stubContext = _mocks.Stub<HttpContextBase>(); stubContext.Replay(); stubContext.Expect(c => c.IsDebuggingEnabled).Return(false); _mockHttp.Expect(s => s.Context).Return(stubContext); _mockSettings.Expect(s => s.Types[type]).Return(settings); foreach (var kvp in includes) { var include = new Include(type, kvp.Key, "foo", Clock.UtcNow); _mockReader.Expect(r => r.Read(kvp.Key, type)).Return(include); _mockStorage.Expect(s => s.Store(include)); } _mockReader.Expect(r => r.ToAbsolute(Arg<string>.Is.NotNull)).Return(string.Format("/content/{0}/{1}.{0}", type.ToString().ToLowerInvariant(), key)); string hash = null; _mockStorage.Expect(s => hash = s.Store(Arg<IncludeCombination>.Is.NotNull)).Return("foo"); string reference = null; Assert.DoesNotThrow(() => reference = _combiner.RenderIncludes(includes.Keys, type, false)); Assert.Equal(expected, reference); }
public void RegisterCombination_ShouldReadAllSourcesToAddEachToTheCombination_AndReturnAHash(IncludeType type, IDictionary<string, Include> sources, IncludeTypeElement settings) { foreach (var kvp in sources) { _mockReader.Expect(r => r.Read(kvp.Key, kvp.Value.Type)).Return(kvp.Value); _mockStorage.Expect(s => s.Store(kvp.Value)); } _mockStorage.Expect(s => s.Store(new IncludeCombination(type, sources.Keys, "content", Clock.UtcNow, settings))).IgnoreArguments().Return("foo"); _mockSettings.Expect(s => s.Types).Return(new Dictionary<IncludeType, IIncludeTypeSettings> {{type,settings }}); string key = null; Assert.DoesNotThrow(() => key = _combiner.RegisterCombination(sources.Keys, IncludeType.Js, Clock.UtcNow)); Assert.Equal("foo", key); }