Skip to content

Commit

Permalink
fixed some roslyn compiler CA1860 warnings in unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vividos committed Apr 30, 2024
1 parent e6190f1 commit 832d5ff
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 26 deletions.
7 changes: 3 additions & 4 deletions src/Geo/UnitTest/GpxDataFileTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.IO;
using System.Linq;
using WhereToFly.Geo.DataFormats;

namespace WhereToFly.Geo.UnitTest
Expand All @@ -25,7 +24,7 @@ public void TestGetTrackList()
var trackList = gpxFile.GetTrackList();

// check
Assert.IsTrue(trackList.Any(), "track list list must at least one track");
Assert.IsTrue(trackList.Count != 0, "track list list must at least one track");
}
}

Expand All @@ -44,7 +43,7 @@ public void TestLoadTrack()
var track = gpxFile.LoadTrack(0);

// check
Assert.IsTrue(track.TrackPoints.Any(), "track points list must not be empty");
Assert.IsTrue(track.TrackPoints.Count != 0, "track points list must not be empty");
}
}

Expand All @@ -64,7 +63,7 @@ public void TestLoadLocationList()
var locationList = gpxFile.LoadLocationList();

// check
Assert.IsTrue(locationList.Any(), "loaded location list must contain locations");
Assert.IsTrue(locationList.Count != 0, "loaded location list must contain locations");
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/Geo/UnitTest/IgcDataFileTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.IO;
using System.Linq;
using WhereToFly.Geo.DataFormats;
using WhereToFly.Geo.Model;

Expand Down Expand Up @@ -50,7 +49,7 @@ public void TestLoadTrack()
// check
Assert.IsNotNull(track, "track must not be null");
Assert.IsNotNull(track.Name, "track name must be set");
Assert.IsTrue(track.TrackPoints.Any(), "there must be any track points");
Assert.IsTrue(track.TrackPoints.Count > 0, "there must be any track points");
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Geo/UnitTest/IgcParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void TestParseIgcFile()
// check
Assert.IsNotNull(track, "track must not be null");
Assert.IsNotNull(track.Name, "track name must be set");
Assert.IsTrue(track.TrackPoints.Any(), "there must be any track points");
Assert.IsTrue(track.TrackPoints.Count > 0, "there must be any track points");
Assert.IsFalse(parsingErrors.Any(), "there must be no parsing errors");
}

Expand Down
13 changes: 6 additions & 7 deletions src/Geo/UnitTest/KmlDataFileTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.IO;
using System.Linq;
using WhereToFly.Geo.DataFormats;

namespace WhereToFly.Geo.UnitTest
Expand All @@ -25,7 +24,7 @@ public void TestGetTrackList()
var trackList = kmlFile.GetTrackList();

// check
Assert.IsTrue(trackList.Any(), "track list must contain any tracks");
Assert.IsTrue(trackList.Count > 0, "track list must contain any tracks");
}

/// <summary>
Expand All @@ -44,8 +43,8 @@ public void TestLoadTrack()
var track1 = kmlFile.LoadTrack(1);

// check
Assert.IsTrue(track0.TrackPoints.Any(), "track points list must not be empty");
Assert.IsTrue(track1.TrackPoints.Any(), "track points list must not be empty");
Assert.IsTrue(track0.TrackPoints.Count > 0, "track points list must not be empty");
Assert.IsTrue(track1.TrackPoints.Count > 0, "track points list must not be empty");
}

/// <summary>
Expand All @@ -63,7 +62,7 @@ public void TestLoadLocationList()
var locationList = kmlFile.LoadLocationList();

// check
Assert.IsTrue(locationList.Any(), "loaded location list must contain locations");
Assert.IsTrue(locationList.Count > 0, "loaded location list must contain locations");
}

/// <summary>
Expand All @@ -81,7 +80,7 @@ public void TestLoadLocationListKmz()
var locationList = kmlFile.LoadLocationList();

// check
Assert.IsTrue(locationList.Any(), "loaded location list must contain locations");
Assert.IsTrue(locationList.Count != 0, "loaded location list must contain locations");
}

/// <summary>
Expand All @@ -99,7 +98,7 @@ public void TestFileWithoutPlacemarks()

// check
Assert.IsFalse(kmlFile.HasLocations(), "kml file must not contain locations");
Assert.IsFalse(locationList.Any(), "loaded location list must not contain locations");
Assert.IsFalse(locationList.Count != 0, "loaded location list must not contain locations");
}

/// <summary>
Expand Down
3 changes: 1 addition & 2 deletions src/Geo/UnitTest/SeeYouDataFileTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.IO;
using System.Linq;
using WhereToFly.Geo.DataFormats;

namespace WhereToFly.Geo.UnitTest
Expand All @@ -26,7 +25,7 @@ public void TestLoadLocationList_EmptyWaypointFile()

// check
Assert.IsFalse(cupFile.HasLocations(), "loaded file must have no locations");
Assert.IsFalse(cupFile.LoadLocationList().Any(), "locations list must contain no locations");
Assert.IsTrue(cupFile.LoadLocationList().Count == 0, "locations list must contain no locations");
}
}

Expand Down
13 changes: 6 additions & 7 deletions src/WebApi/UnitTest/PlanTourEngineTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using WhereToFly.Shared.Model;
using WhereToFly.WebApi.Logic.TourPlanning;

Expand Down Expand Up @@ -73,10 +72,10 @@ public void TestPlanTour_TwoPoints()
var tour = engine.PlanTour(planTourParameters);

// check
Assert.IsTrue(tour.Description.Any(), "description must contain text");
Assert.IsTrue(tour.Description.Length > 0, "description must contain text");
Assert.IsTrue(tour.TotalDuration.TotalMinutes > 0, "total duration must contain value");
Assert.IsTrue(tour.TourEntriesList.Any(), "tour entries list must be filled");
Assert.IsTrue(tour.MapPointList.Any(), "map point list must be filled");
Assert.IsTrue(tour.TourEntriesList.Count > 0, "tour entries list must be filled");
Assert.IsTrue(tour.MapPointList.Count > 0, "map point list must be filled");
}

/// <summary>
Expand Down Expand Up @@ -168,10 +167,10 @@ public void TestPlanTour_GrandTour()
var tour = engine.PlanTour(planTourParameters);

// check
Assert.IsTrue(tour.Description.Any(), "description must contain text");
Assert.IsTrue(tour.Description.Length > 0, "description must contain text");
Assert.IsTrue(tour.TotalDuration.TotalMinutes > 0, "total duration must contain value");
Assert.IsTrue(tour.TourEntriesList.Any(), "tour entries list must be filled");
Assert.IsTrue(tour.MapPointList.Any(), "map point list must be filled");
Assert.IsTrue(tour.TourEntriesList.Count > 0, "tour entries list must be filled");
Assert.IsTrue(tour.MapPointList.Count > 0, "map point list must be filled");
}
}
}
5 changes: 2 additions & 3 deletions src/WebApi/UnitTest/TestLiveTrackServiceTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Linq;
using WhereToFly.WebApi.Logic.Services;

namespace WhereToFly.WebApi.UnitTest
Expand All @@ -22,7 +21,7 @@ public void TestGetLiveTrackingData()

// check
Assert.IsTrue(
data.TrackPoints.Any(),
data.TrackPoints.Length > 0,
"there must be any track points");
}

Expand All @@ -37,7 +36,7 @@ public void TestGenerateLiveTrackData()

// check
Assert.IsTrue(
track.TrackPoints.Any(),
track.TrackPoints.Count > 0,
"there must be any track points");

////GpxWriter.WriteTrack("...\\testlivetrack.gpx", track);
Expand Down

0 comments on commit 832d5ff

Please sign in to comment.