public void Accessing_Value_Before_Await_Throws() { var either = new AsyncEither <int, string>( Task.Run(async() => { await Task.Delay(100); return(EitherMethods.CreateValue <int, string>(20)); }) ); Assert.Throws <InvalidEitherStateException>(() => either.Value); }
public async Task Creating_Either_With_Error_After_Delay_Await_Both() { var either = new AsyncEither <int, string>( Task.Run(async() => { await Task.Delay(100); return(EitherMethods.CreateError <int, string>("ERROR")); }) ); Assert.True(await either.HasError); Assert.False(await either.HasValue); Assert.Equal(default, either.Value);
public async Task Accessing_Value_Before_After_Awaiting_HasValue_Does_Not_Throw() { var either = new AsyncEither <int, string>( Task.Run(async() => { await Task.Delay(100); return(EitherMethods.CreateValue <int, string>(20)); }) ); await either.HasValue; var exception = Record.Exception(() => either.Value); Assert.Null(exception); }