public void ConstructorLoadsThemeAndTemplate_VPPRegistrationChanging() { // Arrange // Vanilla theme, as in ConstructorLoadsThemeAndTemplate() string template = WriteTemplate( @"<Chart BorderlineDashStyle=""DashDot""><Legends><Legend BackColor=""Red"" /></Legends></Chart>" ); HttpContextBase context = GetContext(); string templatePath = VirtualPathUtility.Combine( context.Request.AppRelativeCurrentExecutionFilePath, template ); MockVirtualPathProvider provider1 = new MockVirtualPathProvider(); MockVirtualPathProvider provider2 = new MockVirtualPathProvider(); VirtualPathProvider provider = provider1; // Act; use one provider in constructor and another in ExecuteChartAction() Chart chart = new Chart( context, () => provider, 100, 100, theme: ChartTheme.Vanilla, themePath: template ); // The moral equivalent of HostingEnvironment.RegisterVirtualPathProvider(provider2) provider = provider2; // Assert AssertBuiltChartAction( chart, c => { Assert.Equal(ChartColorPalette.SemiTransparent, c.Palette); Assert.Equal(c.BorderColor, Color.FromArgb(0, Color.Black)); Assert.Equal(ChartDashStyle.DashDot, c.BorderlineDashStyle); Legend legend = Assert.Single(c.Legends); Assert.Equal(legend.BackColor, Color.Red); ChartArea chartArea = Assert.Single(c.ChartAreas); Assert.False(chartArea.AxisX.MajorGrid.Enabled); Assert.False(chartArea.AxisY.MinorGrid.Enabled); } ); Assert.Equal(1, provider1.FileExistsCalls); Assert.Equal(0, provider1.GetFileCalls); Assert.Equal(0, provider2.FileExistsCalls); Assert.Equal(1, provider2.GetFileCalls); }
public void ConstructorLoadsThemeAndTemplate_VPPRegistrationChanging() { // Arrange // Vanilla theme, as in ConstructorLoadsThemeAndTemplate() string template = WriteTemplate(@"<Chart BorderlineDashStyle=""DashDot""><Legends><Legend BackColor=""Red"" /></Legends></Chart>"); HttpContextBase context = GetContext(); string templatePath = VirtualPathUtility.Combine(context.Request.AppRelativeCurrentExecutionFilePath, template); MockVirtualPathProvider provider1 = new MockVirtualPathProvider(); MockVirtualPathProvider provider2 = new MockVirtualPathProvider(); VirtualPathProvider provider = provider1; // Act; use one provider in constructor and another in ExecuteChartAction() Chart chart = new Chart(context, () => provider, 100, 100, theme: ChartTheme.Vanilla, themePath: template); // The moral equivalent of HostingEnvironment.RegisterVirtualPathProvider(provider2) provider = provider2; // Assert AssertBuiltChartAction(chart, c => { Assert.Equal(c.Palette, ChartColorPalette.SemiTransparent); Assert.Equal(c.BorderColor, Color.FromArgb(0, Color.Black)); Assert.Equal(c.BorderlineDashStyle, ChartDashStyle.DashDot); Assert.Equal(1, c.ChartAreas.Count); Assert.Equal(c.Legends.Count, 1); Assert.Equal(c.Legends[0].BackColor, Color.Red); Assert.False(c.ChartAreas[0].AxisX.MajorGrid.Enabled); Assert.False(c.ChartAreas[0].AxisY.MinorGrid.Enabled); }); Assert.Equal(1, provider1.FileExistsCalls); Assert.Equal(0, provider1.GetFileCalls); Assert.Equal(0, provider2.FileExistsCalls); Assert.Equal(1, provider2.GetFileCalls); }