public void Uninitialized() { SuccessResult <int> successResult = new SuccessResult <int>(); successResult.Should().BeOfType <SuccessResult <int> >(); successResult.IsSuccess.Should().BeFalse(); successResult.IsFailed.Should().BeTrue(); Static.GetValue(() => successResult.Value).Should().Throw <NotInitializedException>(); }
public void Uninitialized() { FailedResult <DomainError> failedResult = new FailedResult <DomainError>(); failedResult.Should().BeOfType <FailedResult <DomainError> >(); failedResult.IsSuccess.Should().BeFalse(); failedResult.IsFailed.Should().BeTrue(); Static.GetValue(() => failedResult.ErrorValue).Should().Throw <NotInitializedException>(); }
public void OptionalInterface() { var optional = Some("Hello"); optional.IsSome.Should().BeTrue(); optional.IsNone.Should().BeFalse(); optional.GetUnderlyingType().Should().Be <string>(); optional.MatchUntyped( value => value + " world", () => throw new InvalidOperationException()) .Should().Be("Hello world"); optional.AsEnumerable().Should().BeEquivalentTo("Hello"); optional.ToList().Should().BeEquivalentTo("Hello"); optional.Should().BeEquivalentTo(Some("Hello")); Equals(optional, Some("Hello")).Should().BeTrue(); optional.ToString().Should().Be("Some(Hello)"); optional.GetHashCode().Should().Be("Hello".GetHashCode()); var notInitalizedOption = new Option <string>(); Static.GetValue(() => (string)notInitalizedOption).Should().Throw <InvalidCastException>(); notInitalizedOption.GetHashCode().Should().Be(0); }
public void AssertNotInitialized() { Some <int> some = default; Static.GetValue(() => some.Value).Should().Throw <SomeNotInitializedException>(); }