public async Task ShouldIgnoreDuplicatePathsCaseInsensitive() { // Arrange var assembly1 = typeof(RazorMultiViewCompilerProviderTests).Assembly.GetName().Name; // Default assembly var assembly2 = typeof(RazorMultiViewEngineOptions).Assembly.GetName().Name; // Conifgured assembly var view1 = TestRazorCompiledItem.CreateForView(typeof(RazorMultiViewCompilerProviderTests), "test1"); var view2 = TestRazorCompiledItem.CreateForView(typeof(RazorMultiViewCompilerProviderTests), "TEST1"); var options = new RazorMultiViewEngineOptions { DefaultViewLibrary = new ViewLibraryInfo { AssemblyName = assembly1 }, ViewLibraryConfig = new Dictionary <string, string[]> { { "test", new[] { assembly2 } } } }; var accessorWithItems = GetWithItems(new Dictionary <object, object> { { options.HttpContextItemsKey, "test" } }); var partsMan = GetApplicationPartManager(new[] { view1, view2 }); // Act var provider = new RazorMultiViewCompilerProvider(partsMan, accessorWithItems, Options.Create(options)); var compiledView1 = await provider.GetCompiler().CompileAsync("/test1"); var compiledView2 = await provider.GetCompiler().CompileAsync("/TEST1"); Assert.Equal(view1, compiledView1.Item); Assert.Equal(view1, compiledView2.Item); }
public void ShouldGetDefaultCompilerWhenConfigValidButKeyNotRecognised() { // Arrange var assembly1 = typeof(RazorMultiViewCompilerProviderTests).Assembly.GetName().Name; // Default assembly var assembly2 = typeof(RazorMultiViewEngineOptions).Assembly.GetName().Name; // Conifgured assembly var options = new RazorMultiViewEngineOptions { DefaultViewLibrary = new ViewLibraryInfo { AssemblyName = assembly1 }, ViewLibraryConfig = new Dictionary <string, string[]> { { "test", new[] { assembly2 } } } }; var accessorWithItems = GetWithItems(new Dictionary <object, object> { { options.HttpContextItemsKey, "no-test" } }); var partsMan = GetApplicationPartManager(Array.Empty <RazorCompiledItem>()); // Act var provider = new RazorMultiViewCompilerProvider(partsMan, accessorWithItems, Options.Create(options)); // Assert Assert.True(provider.compilers.ContainsKey("default")); Assert.True(provider.compilers.ContainsKey("test")); Assert.Equal <IViewCompiler>(provider.GetCompiler(), provider.compilers["default"]); }
public void ShouldGetDefaultCompilerWhenNoKeyPresent() { // Arrange var partsMan = GetApplicationPartManager(Array.Empty <RazorCompiledItem>()); var options = new RazorMultiViewEngineOptions(); var accessorWithItems = GetWithItems(new Dictionary <object, object>()); // Act var provider = new RazorMultiViewCompilerProvider(partsMan, accessorWithItems, Options.Create(options)); // Assert Assert.Single(provider.compilers); Assert.True(provider.compilers.ContainsKey("default")); Assert.Equal <IViewCompiler>(provider.GetCompiler(), provider.compilers["default"]); }