Skip to content

Commit

Permalink
Added tests for Microsoft.VisualBasic.CompilerServices.Conversions #1…
Browse files Browse the repository at this point in the history
…4344
  • Loading branch information
Oswald Maskens committed Feb 1, 2018
1 parent dee052f commit 7316066
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
41 changes: 41 additions & 0 deletions src/Microsoft.VisualBasic/tests/ConversionsTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Microsoft.VisualBasic.CompilerServices;
using Xunit;

namespace Microsoft.VisualBasic.Tests
{
public class ConversionsTests
{
[Theory]
[InlineData("true", true)]
[InlineData("false", false)]
[InlineData("5", true)]
[InlineData("0", false)]
[InlineData("5.5", true)]
[InlineData("0.0", false)]
[InlineData("&h5", true)]
[InlineData("&h0", false)]
[InlineData("&o5", true)]
[InlineData("&o0", false)]
public void ToBoolean_String_ReturnsExpected(string str, bool expected)
{
Assert.Equal(expected, Conversions.ToBoolean(str));
}

[Theory]
[InlineData("yes")]
[InlineData("contoso")]
public void ToBoolean_String_ThrowsOnInvalidFormat(string str)
{
Assert.Throws<InvalidCastException>(() => Conversions.ToBoolean(str));
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Release|AnyCPU'" />
<ItemGroup>
<Compile Include="ConversionsTests.cs" />
<Compile Include="OperatorsTests.cs" />
<Compile Include="UtilsTests.cs" />
<Compile Include="StringsTests.cs" />
Expand All @@ -18,4 +19,4 @@
<EmbeddedResource Include="Resources\$(AssemblyName).rd.xml" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
</Project>

0 comments on commit 7316066

Please sign in to comment.