1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-05-02 20:34:07 +02:00
TweetDuck/lib/TweetTest.Unit/Data/TestResult.fs
Daniel Chýlek 1ccefe853a
Update .NET & begin refactoring code into a core lib ()
* Switch to .NET Framework 4.7.2 & C# 8.0, update libraries

* Add TweetLib.Core project targeting .NET Standard 2.0

* Enable reference nullability checks for TweetLib.Core

* Move a bunch of utility classes into TweetLib.Core & refactor

* Partially move TweetDuck plugin & update system to TweetLib.Core

* Move some constants and CultureInfo setup to TweetLib.Core

* Move some configuration classes to TweetLib.Core

* Minor refactoring and warning suppression

* Add App to TweetLib.Core

* Add IAppErrorHandler w/ implementation

* Continue moving config, plugin, and update classes to TweetLib.Core

* Fix a few nullability checks

* Update installers to check for .NET Framework 4.7.2
2019-05-26 14:55:12 +02:00

58 lines
1.6 KiB
Forth

namespace TweetTest.Data.Result
open Xunit
open TweetLib.Core.Data
open System
module Result_WithValue =
let result = Result<int>(10)
[<Fact>]
let ``HasValue returns true`` () =
Assert.True(result.HasValue)
[<Fact>]
let ``accessing Value returns the provided value`` () =
Assert.Equal(10, result.Value)
[<Fact>]
let ``accessing Exception throws`` () =
Assert.Throws<InvalidOperationException>(fun () -> result.Exception |> ignore)
[<Fact>]
let ``Handle calls the correct callback`` () =
let passTest = fun _ -> ()
let failTest = fun _ -> Assert.True(false)
result.Handle(Action<_>(passTest), Action<_>(failTest))
[<Fact>]
let ``Select returns another valid Result`` () =
Assert.Equal(20, result.Select(fun x -> x * 2).Value)
module Result_WithException =
let result = Result<int>(IndexOutOfRangeException("bad"))
[<Fact>]
let ``HasValue returns false`` () =
Assert.False(result.HasValue)
[<Fact>]
let ``accessing Value throws`` () =
Assert.Throws<InvalidOperationException>(fun () -> result.Value |> ignore)
[<Fact>]
let ``accessing Exception returns the provided exception`` () =
Assert.IsType<IndexOutOfRangeException>(result.Exception)
[<Fact>]
let ``Handle calls the correct callback`` () =
let passTest = fun _ -> ()
let failTest = fun _ -> Assert.True(false)
result.Handle(Action<_>(failTest), Action<_>(passTest))
[<Fact>]
let ``Select returns a Result with the same Exception`` () =
Assert.Same(result.Exception, result.Select(fun x -> x * 2).Exception)