-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7575987
commit e5a8366
Showing
2 changed files
with
64 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// WatchOnlyBitcoinWallet Tests | ||
// Copyright (c) 2016 Coding Enthusiast | ||
// Distributed under the MIT software license, see the accompanying | ||
// file LICENCE or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
using Avalonia.Media; | ||
using System.Globalization; | ||
using WatchOnlyBitcoinWallet.MVVM.Converters; | ||
|
||
namespace Tests.MVVM.Converters | ||
{ | ||
public class NumberToColorConverterTests | ||
{ | ||
public static TheoryData<decimal, IImmutableSolidColorBrush> GetConvertCases() | ||
{ | ||
TheoryData<decimal, IImmutableSolidColorBrush> result = new() | ||
{ | ||
{ 0, Brushes.Transparent }, | ||
{ 0.01m, Brushes.LightGreen }, | ||
{ -0.002m, Brushes.Orange }, | ||
}; | ||
|
||
return result; | ||
} | ||
[Theory] | ||
[MemberData(nameof(GetConvertCases))] | ||
public void ConvertTest(decimal value, IImmutableSolidColorBrush expected) | ||
{ | ||
NumberToColorConverter converter = new(); | ||
object actual = converter.Convert(value, typeof(decimal), null, CultureInfo.InvariantCulture); | ||
Assert.Equal(expected, actual); | ||
} | ||
|
||
[Fact] | ||
public void ExceptionTests() | ||
{ | ||
NumberToColorConverter converter = new(); | ||
Type t = typeof(decimal); | ||
CultureInfo ci = CultureInfo.InvariantCulture; | ||
|
||
Assert.Throws<NotImplementedException>(() => converter.Convert(null, t, null, ci)); | ||
Assert.Throws<NotImplementedException>(() => converter.Convert("foo", t, null, ci)); | ||
Assert.Throws<NotImplementedException>(() => converter.Convert(123, t, null, ci)); | ||
Assert.Throws<NotImplementedException>(() => converter.ConvertBack(null, t, null, ci)); | ||
} | ||
} | ||
} |
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