public void PopulateFeature_DoesNotFail_IfAssemblyHasEmptyLocation() { // Arrange var assembly = new AssemblyWithEmptyLocation(); var applicationPartManager = new ApplicationPartManager(); applicationPartManager.ApplicationParts.Add(new AssemblyPart(assembly)); applicationPartManager.FeatureProviders.Add(new ViewsFeatureProvider()); var feature = new ViewsFeature(); // Act applicationPartManager.PopulateFeature(feature); // Assert Assert.Empty(feature.ViewDescriptors); }
public void PopulateFeature_PreservesOldBehavior_IfGetViewAttributesWasOverriden() { // Arrange var assembly = new AssemblyWithEmptyLocation( new RazorViewAttribute[] { new RazorViewAttribute("view", typeof(string)) }, new RazorCompiledItemAttribute[] { }); var partManager = new ApplicationPartManager(); partManager.ApplicationParts.Add(new AssemblyPart(assembly)); partManager.FeatureProviders.Add(new OverrideViewsFeatureProvider()); var feature = new ViewsFeature(); // Act partManager.PopulateFeature(feature); // Assert Assert.Empty(feature.ViewDescriptors); }
public void PopulateFeature_ReadsAttributesFromTheCurrentAssembly() { // Arrange var item1 = new RazorCompiledItemAttribute(typeof(string), "mvc.1.0.view", "view"); var assembly = new AssemblyWithEmptyLocation( new RazorViewAttribute[] { new RazorViewAttribute("view", typeof(string)) }, new RazorCompiledItemAttribute[] { item1 }); var partManager = new ApplicationPartManager(); partManager.ApplicationParts.Add(new AssemblyPart(assembly)); partManager.FeatureProviders.Add(new ViewsFeatureProvider()); var feature = new ViewsFeature(); // Act partManager.PopulateFeature(feature); // Assert var descriptor = Assert.Single(feature.ViewDescriptors); Assert.Equal(typeof(string), descriptor.Item.Type); Assert.Equal("mvc.1.0.view", descriptor.Item.Kind); Assert.Equal("view", descriptor.Item.Identifier); }