-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now correctly wraps around iamges when midnight != 00:00 Remaining work: tests!
- Loading branch information
Showing
6 changed files
with
175 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
tests/Acoustics.Test/Shared/Extensions/DateTimeAndTimeSpanExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// <copyright file="DateTimeAndTimeSpanExtensions.cs" company="QutEcoacoustics"> | ||
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group). | ||
// </copyright> | ||
|
||
namespace Acoustics.Test.Shared.Extensions | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Accord.Math; | ||
using Acoustics.Shared; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using static System.DateTimeAndTimeSpanExtensions; | ||
|
||
[TestClass] | ||
public class DateTimeAndTimeSpanExtensions | ||
{ | ||
[DataTestMethod] | ||
[DataRow("2019-04-08T11:30:00+10:00", RoundingDirection.AwayFromZero, "2019-04-08T11:30:00+10:00")] | ||
[DataRow("2019-04-08T12:57:33+10:00", RoundingDirection.AwayFromZero, "2019-04-08T11:30:00+10:00")] | ||
[DataRow("2019-04-08T09:57:33+10:00", RoundingDirection.AwayFromZero, "2019-04-08T11:30:00+10:00")] | ||
[DataRow("2019-04-08T23:45:33+10:00", RoundingDirection.AwayFromZero, "2019-04-09T11:30:00+10:00")] | ||
[DataRow("2019-04-07T23:15:33+10:00", RoundingDirection.AwayFromZero, "2019-04-07T11:30:00+10:00")] | ||
|
||
[DataRow("2019-04-08T11:30:00+10:00", RoundingDirection.Floor, "2019-04-08T11:30:00+10:00")] | ||
[DataRow("2019-04-08T12:57:33+10:00", RoundingDirection.Floor, "2019-04-08T11:30:00+10:00")] | ||
[DataRow("2019-04-08T09:57:33+10:00", RoundingDirection.Floor, "2019-04-07T11:30:00+10:00")] | ||
[DataRow("2019-04-08T23:45:33+10:00", RoundingDirection.Floor, "2019-04-08T11:30:00+10:00")] | ||
[DataRow("2019-04-07T23:15:33+10:00", RoundingDirection.Floor, "2019-04-07T11:30:00+10:00")] | ||
|
||
[DataRow("2019-04-08T11:30:00+10:00", RoundingDirection.Ceiling, "2019-04-08T11:30:00+10:00")] | ||
[DataRow("2019-04-08T12:57:33+10:00", RoundingDirection.Ceiling, "2019-04-09T11:30:00+10:00")] | ||
[DataRow("2019-04-08T09:57:33+10:00", RoundingDirection.Ceiling, "2019-04-08T11:30:00+10:00")] | ||
[DataRow("2019-04-08T23:45:33+10:00", RoundingDirection.Ceiling, "2019-04-09T11:30:00+10:00")] | ||
[DataRow("2019-04-07T23:15:33+10:00", RoundingDirection.Ceiling, "2019-04-08T11:30:00+10:00")] | ||
public void TestRoundToTimeOfDay(string test, RoundingDirection direction, string expected) | ||
{ | ||
var testDate = DateTimeOffset.ParseExact(test, AppConfigHelper.Iso8601FormatNoFractionalSeconds, CultureInfo.InvariantCulture); | ||
var expectedDate = DateTimeOffset.ParseExact(expected, AppConfigHelper.Iso8601FormatNoFractionalSeconds, CultureInfo.InvariantCulture); | ||
|
||
var actual = testDate.RoundToTimeOfDay(new TimeSpan(11, 30, 0), direction); | ||
|
||
Assert.AreEqual(expectedDate, actual); | ||
} | ||
} | ||
} |