Skip to content

Commit

Permalink
removed obsolete DateTimeUtility
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoCoderMatrix86 committed Aug 28, 2024
1 parent 6fa136d commit 59af636
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 174 deletions.
143 changes: 0 additions & 143 deletions AudioCuesheetEditor/Model/Utility/DateTimeUtility.cs

This file was deleted.

1 change: 0 additions & 1 deletion AudioCuesheetEditor/Model/Utility/TimeSpanUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ namespace AudioCuesheetEditor.Model.Utility
{
public class TimeSpanUtility
{
//TODO: Unit Tests
public static TimeSpan? ParseTimeSpan(String input, TimeSpanFormat? timeSpanFormat = null)
{
TimeSpan? result = null;
Expand Down
1 change: 0 additions & 1 deletion AudioCuesheetEditor/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@

builder.Services.AddScoped<SessionStateContainer>();
builder.Services.AddScoped<TraceChangeManager>();
builder.Services.AddScoped<DateTimeUtility>();
builder.Services.AddScoped<ImportManager>();
builder.Services.AddScoped<TextImportService>();
builder.Services.AddScoped<CuesheetImportService>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,63 +1,51 @@
//This file is part of AudioCuesheetEditor.

//AudioCuesheetEditor is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.

//AudioCuesheetEditor is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with Foobar. If not, see
//<http: //www.gnu.org/licenses />.
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using AudioCuesheetEditor.Model.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AudioCuesheetEditor.Model.Utility.Tests
{
[TestClass()]
public class DateTimeUtilityTests
public class TimeSpanUtilityTests
{
[TestMethod()]
public void ParseTimeSpanTest()
{
var utility = new DateTimeUtility(new TimeSpanFormat());
var timespan = utility.ParseTimeSpan("01:23:45");
var timespan = TimeSpanUtility.ParseTimeSpan("01:23:45");
Assert.IsNotNull(timespan);
Assert.AreEqual(new TimeSpan(1, 23, 45), timespan);
var format = new TimeSpanFormat() { Scheme = "(?'Minutes'\\d{1,})[:](?'Seconds'\\d{1,})" };
utility = new DateTimeUtility(format);
timespan = utility.ParseTimeSpan("3:12");
timespan = TimeSpanUtility.ParseTimeSpan("3:12", format);
Assert.IsNotNull(timespan);
Assert.AreEqual(new TimeSpan(0, 3, 12), timespan);
timespan = utility.ParseTimeSpan("63:12");
timespan = TimeSpanUtility.ParseTimeSpan("63:12", format);
Assert.IsNotNull(timespan);
Assert.AreEqual(new TimeSpan(1, 3, 12), timespan);
format.Scheme = "(?'Hours'\\d{1,})[:](?'Minutes'\\d{1,})";
timespan = utility.ParseTimeSpan("23:12");
timespan = TimeSpanUtility.ParseTimeSpan("23:12", format);
Assert.IsNotNull(timespan);
Assert.AreEqual(new TimeSpan(23, 12, 0), timespan);
format.Scheme = "(?'Hours'\\d{1,})[:](?'Minutes'\\d{1,})[:](?'Seconds'\\d{1,})";
timespan = utility.ParseTimeSpan("23:45:56");
timespan = TimeSpanUtility.ParseTimeSpan("23:45:56", format);
Assert.IsNotNull(timespan);
Assert.AreEqual(new TimeSpan(0, 23, 45, 56), timespan);
format.Scheme = "(?'Days'\\d{1,})[.](?'Hours'\\d{1,})[:](?'Minutes'\\d{1,})[:](?'Seconds'\\d{1,})";
timespan = utility.ParseTimeSpan("2.23:45:56");
timespan = TimeSpanUtility.ParseTimeSpan("2.23:45:56", format);
Assert.IsNotNull(timespan);
Assert.AreEqual(new TimeSpan(2, 23, 45, 56), timespan);
format.Scheme = "(?'Hours'\\d{1,})[:](?'TimeSpanFormat.Minutes'\\d{1,})[:](?'TimeSpanFormat.Seconds'\\d{1,})[.](?'TimeSpanFormat.Milliseconds'\\d{1,})";
timespan = utility.ParseTimeSpan("23:45:56.599");
timespan = TimeSpanUtility.ParseTimeSpan("23:45:56.599", format);
Assert.IsNotNull(timespan);
Assert.AreEqual(new TimeSpan(0, 23, 45, 56, 599), timespan);
timespan = utility.ParseTimeSpan("1.2e:45:87.h3a");
timespan = TimeSpanUtility.ParseTimeSpan("1.2e:45:87.h3a", format);
Assert.IsNull(timespan);
timespan = utility.ParseTimeSpan("Test");
timespan = TimeSpanUtility.ParseTimeSpan("Test", format);
Assert.IsNull(timespan);
format.Scheme = "this is a test";
timespan = utility.ParseTimeSpan("Test");
timespan = TimeSpanUtility.ParseTimeSpan("Test", format);
Assert.IsNull(timespan);
}
}
Expand Down

0 comments on commit 59af636

Please sign in to comment.