Skip to content

Commit

Permalink
One day bug (#75)
Browse files Browse the repository at this point in the history
* better selenium filtering for tests

* removing time from datetime comparison
  • Loading branch information
eebbesen authored Jan 22, 2025
1 parent c274014 commit e19b55c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main_stpfoodblazor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --filter FullyQualifiedName\!~StpFoodBlazorTest.Integration --verbosity normal
run: dotnet test --filter DisplayName\!~Integration
build:
runs-on: windows-latest
needs: test
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ jobs:
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --filter FullyQualifiedName\!~StpFoodBlazorTest.Integration --verbosity normal --collect "XPlat Code Coverage"
run: dotnet test --no-build --filter DisplayName\!~Integration --collect "XPlat Code Coverage"
4 changes: 2 additions & 2 deletions StpFoodBlazor/StpFoodBlazor/Helpers/DealFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ private static DealEvent[] FilterByHappyHour(DealEvent[] deals, Boolean happyHou

private static DealEvent[] FilterByEndAndStartDates(DealEvent[] deals) {
return deals.Where(deal =>
(string.IsNullOrEmpty(deal.End) || DateTime.Parse(deal.End) >= DateTime.Now) &&
(string.IsNullOrEmpty(deal.Start) || DateTime.Parse(deal.Start) <= DateTime.Now)
(string.IsNullOrEmpty(deal.End) || DateTime.Parse(deal.End) >= DateTime.Now.Date) &&
(string.IsNullOrEmpty(deal.Start) || DateTime.Parse(deal.Start) <= DateTime.Now.Date)
).ToArray();
}
}
Expand Down
19 changes: 19 additions & 0 deletions StpFoodBlazor/StpFoodBlazorTest/Helpers/DealFilterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,25 @@ public void ShouldReturnFilteredByHappyHourFalse() {
Assert.True(string.IsNullOrWhiteSpace(deal.HappyHour)));
}

[Fact]
public void ShouldShowDealsThatAreOneDayOnly()
{
filter.Deals = new DealEvent[] {
new DealEvent {
Name = "Pino's Pizza",
Day = DateTime.Now.DayOfWeek.ToString(),
Deal = "Free Oone day only",
Start = DateTime.Now.ToString("MM/dd/yyyy"),
End = DateTime.Now.ToString("MM/dd/yyyy")
}
};
filter.Day = DateTime.Now.DayOfWeek.ToString();

DealEvent[] filteredDeals = filter.Filter();

Assert.Single(filteredDeals);
}

[Fact]
public void ShouldFilterDealsThatEnded() {
filter.HappyHour = true;
Expand Down

0 comments on commit e19b55c

Please sign in to comment.