public void WrapAndRetrieveNone() { IOption <int> option = FakeService.GetOption(false); var some = (None <int>)option; Assert.IsType <None <int> >(option); }
public void WrapAndRetrieveSome() { IOption <int> option = FakeService.GetOption(true); var some = (Some <int>)option; Assert.IsType <Some <int> >(option); Assert.Equal(10, some); }
public void WrapAndRetrieveSomeWithPatternMatching() { IOption <int> option = FakeService.GetOption(true); int res = 0; switch (option) { case Some <int> some: res = some; break; case None <int> _: res = 0; break; } Assert.IsType <Some <int> >(option); Assert.Equal(10, res); }
public void WrapAndRetrieveNoneWithPatternMatching() { IOption <int> option = FakeService.GetOption(false); int res = 0; switch (option) { case Some <int> some: res = some; break; case None <int> _: // Set it to -1 for the assert to check something different to 0. res = -1; break; } Assert.IsType <None <int> >(option); Assert.Equal(-1, res); }