Skip to content

Commit 9a05e1b

Browse files
committed
Ensure Counter behaves like an int
1 parent 6596b47 commit 9a05e1b

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

ModuleManager/Utils/Counter.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ public void Increment()
1414
Value++;
1515
}
1616

17+
public override string ToString()
18+
{
19+
return Value.ToString();
20+
}
21+
1722
public static implicit operator int(Counter counter) => counter.Value;
1823
}
1924
}

ModuleManagerTests/Utils/CounterTest.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,22 @@ public void TestIncrement()
3333
Assert.Equal(2, counter.Value);
3434
}
3535

36+
[Fact]
37+
public void TestToString()
38+
{
39+
Counter counter = new Counter();
40+
41+
Assert.Equal("0", counter.ToString());
42+
43+
counter.Increment();
44+
45+
Assert.Equal("1", counter.ToString());
46+
47+
counter.Increment();
48+
49+
Assert.Equal("2", counter.ToString());
50+
}
51+
3652
[Fact]
3753
public void Test__CastAsInt()
3854
{

0 commit comments

Comments
 (0)