Skip to content

Commit

Permalink
linter remediation
Browse files Browse the repository at this point in the history
  • Loading branch information
eebbesen committed Oct 29, 2024
1 parent 9389c12 commit baca7ea
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
18 changes: 9 additions & 9 deletions StpFoodBlazor/StpFoodBlazor/Helpers/DealFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,41 @@ public class DealFilter {
public bool? Alcohol { get; set; }
public bool? HappyHour { get; set; }

public DealEvent[] filter() {
public DealEvent[] Filter() {
if (Deals == null) {
return [];
}

DealEvent[] filteredDeals = Deals;

if (!string.IsNullOrWhiteSpace(Day)) {
filteredDeals = filterByDay(filteredDeals, Day);
filteredDeals = FilterByDay(filteredDeals, Day);
}

if (!string.IsNullOrWhiteSpace(Name)) {
filteredDeals = filterByName(filteredDeals, Name);
filteredDeals = FilterByName(filteredDeals, Name);
}

if (Alcohol != null) {
filteredDeals = filterByAlcohol(filteredDeals, (bool)Alcohol);
filteredDeals = FilterByAlcohol(filteredDeals, (bool)Alcohol);
}

if(HappyHour != null) {
filteredDeals = filterByHappyHour(filteredDeals, (bool)HappyHour);
filteredDeals = FilterByHappyHour(filteredDeals, (bool)HappyHour);
}

return filteredDeals;
}

private static DealEvent[] filterByDay(DealEvent[] deals, String day) {
private static DealEvent[] FilterByDay(DealEvent[] deals, String day) {
return deals.Where(deal => deal.Day == day).ToArray();
}

private static DealEvent[] filterByName(DealEvent[] deals, String name) {
private static DealEvent[] FilterByName(DealEvent[] deals, String name) {
return deals.Where(deal => deal.Name == name).ToArray();
}

private static DealEvent[] filterByAlcohol(DealEvent[] deals, Boolean alcohol) {
private static DealEvent[] FilterByAlcohol(DealEvent[] deals, Boolean alcohol) {
if (alcohol) {
return deals.Where(deal => !string.IsNullOrWhiteSpace(deal.Alcohol)).ToArray();
}
Expand All @@ -51,7 +51,7 @@ private static DealEvent[] filterByAlcohol(DealEvent[] deals, Boolean alcohol) {
}

// Need to convert column header with space to model attribute without one
private static DealEvent[] filterByHappyHour(DealEvent[] deals, Boolean happyHour) {
private static DealEvent[] FilterByHappyHour(DealEvent[] deals, Boolean happyHour) {
if (happyHour) {
return deals.Where(deal =>
deal.HappyHour != null && deal.HappyHour.Trim() != "").ToArray();
Expand Down
18 changes: 9 additions & 9 deletions StpFoodBlazor/StpFoodBlazorTest/Helpers/DealFilterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public DealFilterTest() {

[Fact]
public void ShouldHandleEmptyDeals() {
DealEvent[] filteredDeals = new DealFilter().filter();
DealEvent[] filteredDeals = new DealFilter().Filter();

Assert.Empty(filteredDeals);
}
Expand All @@ -26,7 +26,7 @@ public void ShouldHandleEmptyDeals() {
public void ShouldReturnInputWhenNoFilterConditions() {
int dealsLength = deals.Length;

DealEvent[] filteredDeals = filter.filter();
DealEvent[] filteredDeals = filter.Filter();

Assert.Equal(324, dealsLength);
Assert.Equal(dealsLength, filteredDeals.Length);
Expand All @@ -37,7 +37,7 @@ public void ShouldReturnFilteredByDay() {
String day = "Monday";
filter.Day = day;

DealEvent[] filteredDeals = filter.filter();
DealEvent[] filteredDeals = filter.Filter();

Assert.Equal(45, filteredDeals.Length);
Array.ForEach(filteredDeals, deal => Assert.Equal(day, deal.Day));
Expand All @@ -48,7 +48,7 @@ public void ShouldReturnFilteredByName() {
String name = "Pino's Pizza";
filter.Name = name;

DealEvent[] filteredDeals = filter.filter();
DealEvent[] filteredDeals = filter.Filter();

Assert.Equal(5, filteredDeals.Length);
Array.ForEach(filteredDeals, deal => Assert.Equal(name, deal.Name));
Expand All @@ -61,7 +61,7 @@ public void ShouldReturnFilteredByNameAndDay() {
filter.Name = name;
filter.Day = day;

DealEvent[] filteredDeals = filter.filter();
DealEvent[] filteredDeals = filter.Filter();

Assert.Single(filteredDeals);
Array.ForEach(filteredDeals, deal => {
Expand All @@ -74,7 +74,7 @@ public void ShouldReturnFilteredByNameAndDay() {
public void ShouldReturnFilteredByAlcoholTrue() {
filter.Alcohol = true;

DealEvent[] filteredDeals = filter.filter();
DealEvent[] filteredDeals = filter.Filter();

Assert.Equal(109, filteredDeals.Length);
Array.ForEach(filteredDeals, deal => {
Expand All @@ -86,7 +86,7 @@ public void ShouldReturnFilteredByAlcoholTrue() {
public void ShouldReturnFilteredByAlcoholFalse() {
filter.Alcohol = false;

DealEvent[] filteredDeals = filter.filter();
DealEvent[] filteredDeals = filter.Filter();

Assert.Equal(215, filteredDeals.Length);
Array.ForEach(filteredDeals, deal => {
Expand All @@ -98,7 +98,7 @@ public void ShouldReturnFilteredByAlcoholFalse() {
public void ShouldReturnFilteredByHappyHourTrue() {
filter.HappyHour = true;

DealEvent[] filteredDeals = filter.filter();
DealEvent[] filteredDeals = filter.Filter();

Assert.Equal(191, filteredDeals.Length);
Array.ForEach(filteredDeals, deal => Assert.NotNull(deal.HappyHour));
Expand All @@ -108,7 +108,7 @@ public void ShouldReturnFilteredByHappyHourTrue() {
public void ShouldReturnFilteredByHappyHourFalse() {
filter.HappyHour = false;

DealEvent[] filteredDeals = filter.filter();
DealEvent[] filteredDeals = filter.Filter();

Assert.Equal(133, filteredDeals.Length);
Array.ForEach(filteredDeals, deal =>
Expand Down

0 comments on commit baca7ea

Please sign in to comment.