forked from commandlineparser/commandline
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFSharpOptionHelperTests.cs
More file actions
50 lines (42 loc) · 1.67 KB
/
Copy pathFSharpOptionHelperTests.cs
File metadata and controls
50 lines (42 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information.
using System.Reflection;
using CommandLine.Infrastructure;
using CommandLine.Tests.Fakes;
using Microsoft.FSharp.Core;
using FluentAssertions;
using Xunit;
namespace CommandLine.Tests.Unit.Infrastructure
{
public class FSharpOptionHelperTests
{
[Fact]
public void Match_type_returns_true_if_FSharpOption()
{
ReflectionHelper.IsFSharpOptionType(TestData.PropertyType)
.Should().BeTrue();
}
[Fact]
public void Get_underlying_type()
{
FSharpOptionHelper.GetUnderlyingType(TestData.PropertyType).FullName
.Should().BeEquivalentTo("System.String");
}
[Fact]
public void Create_some()
{
var expected = FSharpOptionHelper.Some(FSharpOptionHelper.GetUnderlyingType(TestData.PropertyType), "with data");
expected.Should().BeOfType<FSharpOption<string>>();
FSharpOption<string>.get_IsSome((FSharpOption<string>)expected).Should().BeTrue();
}
[Fact]
public void Create_none()
{
var expected = FSharpOptionHelper.None(FSharpOptionHelper.GetUnderlyingType(TestData.PropertyType));
FSharpOption<string>.get_IsNone((FSharpOption<string>)expected).Should().BeTrue();
}
private PropertyInfo TestData
{
get { return typeof(Options_With_FSharpOption).GetProperty("FileName", BindingFlags.Public | BindingFlags.Instance); }
}
}
}