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

25 lines
668 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
2016-11-07 19:12:09 +01:00
{
[TestFixture]
public class AttemptTests
{
[Test]
public void AttemptIf()
{
// Just making sure that it is ok to use TryParse as a condition.
var attempt = Attempt.If(int.TryParse("1234", out int value), value);
2016-11-07 19:12:09 +01:00
Assert.IsTrue(attempt.Success);
Assert.AreEqual(1234, attempt.Result);
attempt = Attempt.If(int.TryParse("12xxx34", out value), value);
Assert.IsFalse(attempt.Success);
}
}
}