-
Notifications
You must be signed in to change notification settings - Fork 385
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix nullability indicators for the Parse/TryParse overloads (#1446)
(UnitParser, QuantityParser, Quantity) fixes #1445 --------- Co-authored-by: Andreas Gullberg Larsen <[email protected]>
- Loading branch information
1 parent
abbbf5f
commit e294419
Showing
131 changed files
with
546 additions
and
510 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
// Licensed under MIT No Attribution, see LICENSE file at the root. | ||
// Licensed under MIT No Attribution, see LICENSE file at the root. | ||
// Copyright 2013 Andreas Gullberg Larsen ([email protected]). Maintained at https://github.com/angularsen/UnitsNet. | ||
|
||
using System.Globalization; | ||
using UnitsNet.Tests.CustomQuantities; | ||
using UnitsNet.Units; | ||
using Xunit; | ||
|
||
namespace UnitsNet.Tests | ||
|
@@ -87,5 +89,24 @@ public void TryParse_MappedCustomUnit() | |
Assert.Equal(1, q.Value); | ||
} | ||
|
||
[Fact] | ||
public void TryParse_NullString_Returns_False() | ||
{ | ||
QuantityParser quantityParser = UnitsNetSetup.Default.QuantityParser; | ||
|
||
var success = quantityParser.TryParse<Mass, MassUnit>(null, null, Mass.From, out Mass _); | ||
|
||
Assert.False(success); | ||
} | ||
|
||
[Fact] | ||
public void TryParse_WithInvalidValue_Returns_False() | ||
{ | ||
QuantityParser quantityParser = UnitsNetSetup.Default.QuantityParser; | ||
|
||
var success = quantityParser.TryParse<Mass, MassUnit>("XX kg", CultureInfo.InvariantCulture, Mass.From, out Mass _); | ||
|
||
Assert.False(success); | ||
} | ||
} | ||
} |
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
8 changes: 4 additions & 4 deletions
8
UnitsNet/GeneratedCode/Quantities/AbsorbedDoseOfIonizingRadiation.g.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.