Skip to content

Add xUnit analyzers and take fixer suggestions (2 of 5): System.Web.Helpers.Test to System.Web.Http.SignalR.Test #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 45 additions & 45 deletions test/System.Web.Helpers.Test/ChartTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public void BuildChartAddsDefaultArea()
var chart = new Chart(GetContext(), GetVirtualPathProvider(), 100, 100);
AssertBuiltChartAction(chart, c =>
{
Assert.Equal(1, c.ChartAreas.Count);
Assert.Equal("Default", c.ChartAreas[0].Name);
ChartArea chartArea = Assert.Single(c.ChartAreas);
Assert.Equal("Default", chartArea.Name);
});
}

Expand All @@ -38,10 +38,10 @@ public void XAxisOverrides()
.SetXAxis("AxisX", 1, 100);
AssertBuiltChartAction(chart, c =>
{
Assert.Equal(1, c.ChartAreas.Count);
Assert.Equal("AxisX", c.ChartAreas[0].AxisX.Title);
Assert.Equal(1, c.ChartAreas[0].AxisX.Minimum);
Assert.Equal(100, c.ChartAreas[0].AxisX.Maximum);
ChartArea chartArea = Assert.Single(c.ChartAreas);
Assert.Equal("AxisX", chartArea.AxisX.Title);
Assert.Equal(1, chartArea.AxisX.Minimum);
Assert.Equal(100, chartArea.AxisX.Maximum);
});
}

Expand All @@ -52,10 +52,10 @@ public void YAxisOverrides()
.SetYAxis("AxisY", 1, 100);
AssertBuiltChartAction(chart, c =>
{
Assert.Equal(1, c.ChartAreas.Count);
Assert.Equal("AxisY", c.ChartAreas[0].AxisY.Title);
Assert.Equal(1, c.ChartAreas[0].AxisY.Minimum);
Assert.Equal(100, c.ChartAreas[0].AxisY.Maximum);
ChartArea chartArea = Assert.Single(c.ChartAreas);
Assert.Equal("AxisY", chartArea.AxisY.Title);
Assert.Equal(1, chartArea.AxisY.Minimum);
Assert.Equal(100, chartArea.AxisY.Maximum);
});
}

Expand All @@ -71,7 +71,7 @@ public void ConstructorLoadsTemplate()
public void ConstructorLoadsTheme()
{
//Vanilla theme
/*
/*
* <Chart Palette="SemiTransparent" BorderColor="#000" BorderWidth="2" BorderlineDashStyle="Solid">
<ChartAreas>
<ChartArea _Template_="All" Name="Default">
Expand All @@ -90,19 +90,19 @@ public void ConstructorLoadsTheme()
var chart = new Chart(GetContext(), GetVirtualPathProvider(), 100, 100, theme: ChartTheme.Vanilla);
AssertBuiltChartAction(chart, c =>
{
Assert.Equal(c.Palette, ChartColorPalette.SemiTransparent);
Assert.Equal(ChartColorPalette.SemiTransparent, c.Palette);
Assert.Equal(c.BorderColor, Color.FromArgb(0, Color.Black));
Assert.Equal(1, c.ChartAreas.Count);
Assert.False(c.ChartAreas[0].AxisX.MajorGrid.Enabled);
Assert.False(c.ChartAreas[0].AxisY.MinorGrid.Enabled);
ChartArea chartArea = Assert.Single(c.ChartAreas);
Assert.False(chartArea.AxisX.MajorGrid.Enabled);
Assert.False(chartArea.AxisY.MinorGrid.Enabled);
});
}

[Fact]
public void ConstructorLoadsThemeAndTemplate()
{
//Vanilla theme
/*
/*
* <Chart Palette="SemiTransparent" BorderColor="#000" BorderWidth="2" BorderlineDashStyle="Solid">
<ChartAreas>
<ChartArea _Template_="All" Name="Default">
Expand All @@ -122,14 +122,14 @@ public void ConstructorLoadsThemeAndTemplate()
var chart = new Chart(GetContext(), GetVirtualPathProvider(), 100, 100, theme: ChartTheme.Vanilla, themePath: template);
AssertBuiltChartAction(chart, c =>
{
Assert.Equal(c.Palette, ChartColorPalette.SemiTransparent);
Assert.Equal(ChartColorPalette.SemiTransparent, c.Palette);
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(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);
});
}

Expand All @@ -155,14 +155,14 @@ public void ConstructorLoadsThemeAndTemplate_VPPRegistrationChanging()
// Assert
AssertBuiltChartAction(chart, c =>
{
Assert.Equal(c.Palette, ChartColorPalette.SemiTransparent);
Assert.Equal(ChartColorPalette.SemiTransparent, c.Palette);
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(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);
Expand Down Expand Up @@ -221,7 +221,7 @@ public void DataBindCrossTable()
{
Assert.Equal(2, c.Series.Count);
Assert.Equal(2, c.Series[0].Points.Count);
Assert.Equal(1, c.Series[1].Points.Count);
Assert.Single(c.Series[1].Points);
});
}

Expand Down Expand Up @@ -281,8 +281,8 @@ public void DataBindTable()
// todo - anything else to verify here?
AssertBuiltChartAction(chart, c =>
{
Assert.Equal(1, c.Series.Count);
Assert.Equal(3, c.Series[0].Points.Count);
var series = Assert.Single(c.Series);
Assert.Equal(3, series.Points.Count);
});
}

Expand All @@ -300,8 +300,8 @@ public void DataBindTableWhenXFieldIsNull()
// todo - anything else to verify here?
AssertBuiltChartAction(chart, c =>
{
Assert.Equal(1, c.Series.Count);
Assert.Equal(3, c.Series[0].Points.Count);
var series = Assert.Single(c.Series);
Assert.Equal(3, series.Points.Count);
});
}

Expand Down Expand Up @@ -353,10 +353,10 @@ public void LegendDefaults()
var chart = new Chart(GetContext(), GetVirtualPathProvider(), 100, 100).AddLegend();
AssertBuiltChartAction(chart, c =>
{
Assert.Equal(1, c.Legends.Count);
Legend legend = Assert.Single(c.Legends);
// NOTE: Chart.Legends.Add will create default name
Assert.Equal("Legend1", c.Legends[0].Name);
Assert.Equal(1, c.Legends[0].BorderWidth);
Assert.Equal("Legend1", legend.Name);
Assert.Equal(1, legend.BorderWidth);
});
}

Expand Down Expand Up @@ -474,7 +474,7 @@ public void SaveXmlWritesToFile()
chart.SaveXml(GetContext(), "SaveXmlWritesToFile.xml");
Assert.True(File.Exists("SaveXmlWritesToFile.xml"));
string result = File.ReadAllText("SaveXmlWritesToFile.xml");
Assert.True(result.Contains("BorderWidth=\"2\""));
Assert.Contains("BorderWidth=\"2\"", result);
}

[Fact]
Expand Down Expand Up @@ -531,8 +531,8 @@ public void SeriesOverrides()
.AddSeries(chartType: "Bar");
AssertBuiltChartAction(chart, c =>
{
Assert.Equal(1, c.Series.Count);
Assert.Equal(SeriesChartType.Bar, c.Series[0].ChartType);
var series = Assert.Single(c.Series);
Assert.Equal(SeriesChartType.Bar, series.ChartType);
});
}

Expand All @@ -556,11 +556,11 @@ public void TitleDefaults()
var chart = new Chart(GetContext(), GetVirtualPathProvider(), 100, 100).AddTitle();
AssertBuiltChartAction(chart, c =>
{
Assert.Equal(1, c.Titles.Count);
var title = Assert.Single(c.Titles);
// NOTE: Chart.Titles.Add will create default name
Assert.Equal("Title1", c.Titles[0].Name);
Assert.Equal(String.Empty, c.Titles[0].Text);
Assert.Equal(1, c.Titles[0].BorderWidth);
Assert.Equal("Title1", title.Name);
Assert.Equal(String.Empty, title.Text);
Assert.Equal(1, title.BorderWidth);
});
}

Expand Down
2 changes: 1 addition & 1 deletion test/System.Web.Helpers.Test/DynamicHelperTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void TryGetMemberValueReturnsValueIfBinderIsNotCSharp()
bool result = DynamicHelper.TryGetMemberValue(dynamic, mockMemberBinder, out value);

// Assert
Assert.Equal(value, "Bar");
Assert.Equal("Bar", value);
}

private class MockMemberBinder : GetMemberBinder
Expand Down
Loading