Files
Umbraco-CMS/tests/Umbraco.Tests.UnitTests/Umbraco.Core/AttemptTests.cs

24 lines
610 B
C#
Raw Normal View History

// Copyright (c) Umbraco.
// See LICENSE for more details.
using NUnit.Framework;
using Umbraco.Cms.Core;
2016-11-07 19:12:09 +01:00
namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core;
[TestFixture]
public class AttemptTests
2016-11-07 19:12:09 +01:00
{
[Test]
public void AttemptIf()
2016-11-07 19:12:09 +01:00
{
// Just making sure that it is ok to use TryParse as a condition.
var attempt = Attempt.If(int.TryParse("1234", out var value), value);
Assert.IsTrue(attempt.Success);
Assert.AreEqual(1234, attempt.Result);
2016-11-07 19:12:09 +01:00
attempt = Attempt.If(int.TryParse("12xxx34", out value), value);
Assert.IsFalse(attempt.Success);
2016-11-07 19:12:09 +01:00
}
}