Skip to content

Commit a2479f5

Browse files
committed
Update dotnet from 3.0 to 3.1, and pass more 5 tests clock
1 parent a3d37ee commit a2479f5

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

Exercism/csharp/clock/Clock.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,22 @@ public Clock(int hours, int minutes)
1212
hours = hours + (minutes / 60);
1313
minutes = minutes % 60;
1414
}
15+
else if (minutes < 0)
16+
{
17+
hours -= 1;
18+
}
1519

1620
_hours = hours % 24;
21+
if (_hours < 0)
22+
{
23+
_hours = 24 - Math.Abs(_hours);
24+
}
25+
1726
_minutes = minutes;
27+
if (_minutes < 0)
28+
{
29+
_minutes = 60 - Math.Abs(_minutes);
30+
}
1831
}
1932

2033
public Clock Add(int minutesToAdd)

Exercism/csharp/clock/Clock.csproj

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.0</TargetFramework>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
55
</PropertyGroup>
66

7-
<ItemGroup>
8-
<Compile Remove="Example.cs" />
9-
</ItemGroup>
10-
117
<ItemGroup>
128
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
139
<PackageReference Include="xunit" Version="2.4.1" />

Exercism/csharp/clock/ClockTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,35 +74,35 @@ public void Hour_and_minutes_roll_over_continuously()
7474
Assert.Equal("11:01", sut.ToString());
7575
}
7676

77-
[Fact(Skip = "Remove this Skip property to run this test")]
77+
[Fact]
7878
public void Hour_and_minutes_roll_over_to_exactly_midnight()
7979
{
8080
var sut = new Clock(72, 8640);
8181
Assert.Equal("00:00", sut.ToString());
8282
}
8383

84-
[Fact(Skip = "Remove this Skip property to run this test")]
84+
[Fact]
8585
public void Negative_hour()
8686
{
8787
var sut = new Clock(-1, 15);
8888
Assert.Equal("23:15", sut.ToString());
8989
}
9090

91-
[Fact(Skip = "Remove this Skip property to run this test")]
91+
[Fact]
9292
public void Negative_hour_rolls_over()
9393
{
9494
var sut = new Clock(-25, 0);
9595
Assert.Equal("23:00", sut.ToString());
9696
}
9797

98-
[Fact(Skip = "Remove this Skip property to run this test")]
98+
[Fact]
9999
public void Negative_hour_rolls_over_continuously()
100100
{
101101
var sut = new Clock(-91, 0);
102102
Assert.Equal("05:00", sut.ToString());
103103
}
104104

105-
[Fact(Skip = "Remove this Skip property to run this test")]
105+
[Fact]
106106
public void Negative_minutes()
107107
{
108108
var sut = new Clock(1, -40);

0 commit comments

Comments
 (0)