BadScript 2
Loading...
Searching...
No Matches
FSharpOptionHelperTests.cs
Go to the documentation of this file.
1
// Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information.
2
3
using
System.Reflection;
4
using
CommandLine.Infrastructure
;
5
using
CommandLine.Tests.Fakes
;
6
using
Microsoft.FSharp.Core;
7
using
FluentAssertions;
8
using
Xunit;
9
10
namespace
CommandLine.Tests.Unit.Infrastructure
11
{
12
public
class
FSharpOptionHelperTests
13
{
14
[Fact]
15
public
void
Match_type_returns_true_if_FSharpOption
()
16
{
17
ReflectionHelper
.
IsFSharpOptionType
(
TestData
.PropertyType)
18
.Should().BeTrue();
19
}
20
21
[Fact]
22
public
void
Get_underlying_type
()
23
{
24
FSharpOptionHelper
.
GetUnderlyingType
(
TestData
.PropertyType).FullName
25
.Should().BeEquivalentTo(
"System.String"
);
26
}
27
28
[Fact]
29
public
void
Create_some
()
30
{
31
var expected =
FSharpOptionHelper
.
Some
(
FSharpOptionHelper
.
GetUnderlyingType
(
TestData
.PropertyType),
"with data"
);
32
33
expected.Should().BeOfType<FSharpOption<string>>();
34
FSharpOption<string>.get_IsSome((FSharpOption<string>)expected).Should().BeTrue();
35
}
36
37
[Fact]
38
public
void
Create_none
()
39
{
40
var expected =
FSharpOptionHelper
.
None
(
FSharpOptionHelper
.
GetUnderlyingType
(
TestData
.PropertyType));
41
42
FSharpOption<string>.get_IsNone((FSharpOption<string>)expected).Should().BeTrue();
43
}
44
45
private
PropertyInfo
TestData
46
{
47
get
{
return
typeof(
Options_With_FSharpOption
).GetProperty(
"FileName"
, BindingFlags.Public | BindingFlags.Instance); }
48
}
49
}
50
}
CommandLine.Infrastructure.FSharpOptionHelper
Definition
FSharpOptionHelper.cs:10
CommandLine.Infrastructure.FSharpOptionHelper.None
static object None(Type type)
Definition
FSharpOptionHelper.cs:25
CommandLine.Infrastructure.FSharpOptionHelper.GetUnderlyingType
static Type GetUnderlyingType(Type type)
Definition
FSharpOptionHelper.cs:11
CommandLine.Infrastructure.FSharpOptionHelper.Some
static object Some(Type type, object value)
Definition
FSharpOptionHelper.cs:17
CommandLine.Infrastructure.ReflectionHelper
Definition
ReflectionHelper.cs:15
CommandLine.Infrastructure.ReflectionHelper.IsFSharpOptionType
static bool IsFSharpOptionType(Type type)
Definition
ReflectionHelper.cs:87
CommandLine.Tests.Fakes.Options_With_FSharpOption
Definition
Options_With_FSharpOption.cs:8
CommandLine.Tests.Unit.Infrastructure.FSharpOptionHelperTests
Definition
FSharpOptionHelperTests.cs:13
CommandLine.Tests.Unit.Infrastructure.FSharpOptionHelperTests.Create_some
void Create_some()
Definition
FSharpOptionHelperTests.cs:29
CommandLine.Tests.Unit.Infrastructure.FSharpOptionHelperTests.Create_none
void Create_none()
Definition
FSharpOptionHelperTests.cs:38
CommandLine.Tests.Unit.Infrastructure.FSharpOptionHelperTests.TestData
PropertyInfo TestData
Definition
FSharpOptionHelperTests.cs:46
CommandLine.Tests.Unit.Infrastructure.FSharpOptionHelperTests.Match_type_returns_true_if_FSharpOption
void Match_type_returns_true_if_FSharpOption()
Definition
FSharpOptionHelperTests.cs:15
CommandLine.Tests.Unit.Infrastructure.FSharpOptionHelperTests.Get_underlying_type
void Get_underlying_type()
Definition
FSharpOptionHelperTests.cs:22
CommandLine.Infrastructure
Definition
EnumerableExtensions.cs:8
CommandLine.Tests.Fakes
Definition
Custom_Struct.cs:6
CommandLine.Tests.Unit.Infrastructure
Definition
ReflectionExtensions.cs:9
deps
commandlineparser
tests
CommandLine.Tests
Unit
Infrastructure
FSharpOptionHelperTests.cs
Generated by
1.9.8