Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added .NET (Core) 5 support #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// limitations under the License.
#endregion
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FLS.Tests.Defuzzification
{
Expand Down
13 changes: 2 additions & 11 deletions FLS.Tests/Examples/UsageExampleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,10 @@
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// limitations under the License.
#endregion
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FLS;
using FLS.Rules;

namespace FLS.Tests
Expand All @@ -46,7 +41,7 @@ public void UsageExample_Success()
LinguisticVariable power = new LinguisticVariable("Power");
var low = power.MembershipFunctions.AddTriangle("Low", 0, 25, 50);
var high = power.MembershipFunctions.AddTriangle("High", 25, 50, 75);

IFuzzyEngine fuzzyEngine = new FuzzyEngineFactory().Default();

var rule1 = Rule.If(water.Is(cold).Or(water.Is(warm))).Then(power.Is(high));
Expand All @@ -62,9 +57,5 @@ public void UsageExample_Success()
//Extra
System.Diagnostics.Debug.WriteLine(result);
}




}
}
37 changes: 18 additions & 19 deletions FLS.Tests/Extensions/IEnumerableExtensionsTests.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#region License and Terms
// MoreLINQ - Extensions to LINQ to Objects
// Copyright (c) 2008 Jonathan Skeet. All rights reserved.
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -20,7 +20,6 @@
using System.Linq;
using System.Text;
using NUnit.Framework;
using NUnit.Framework.Constraints;
using FLS;

namespace MoreLinq.Test
Expand All @@ -37,19 +36,19 @@ public void DistinctBy()
}

[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void DistinctByNullSequence()
{
string[] source = null;
source.DistinctBy(x => x.Length);
var result = new TestDelegate(() => source.DistinctBy(x => x.Length));
Assert.Throws(Is.InstanceOf(typeof(ArgumentNullException)), result);
}

[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void DistinctByNullKeySelector()
{
string[] source = { };
source.DistinctBy((Func<string, string>)null);
string[] source = Array.Empty<string>();
var result = new TestDelegate(() => source.DistinctBy((Func<string, string>)null));
Assert.Throws(Is.InstanceOf(typeof(ArgumentNullException)), result);
}

[Test]
Expand All @@ -61,19 +60,19 @@ public void DistinctByWithComparer()
}

[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void DistinctByNullSequenceWithComparer()
{
string[] source = null;
source.DistinctBy(x => x, StringComparer.Ordinal);
var result = new TestDelegate(() => source.DistinctBy(x => x, StringComparer.Ordinal));
Assert.Throws(Is.InstanceOf(typeof(ArgumentNullException)), result);
}

[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void DistinctByNullKeySelectorWithComparer()
{
string[] source = { };
source.DistinctBy(null, StringComparer.Ordinal);
string[] source = Array.Empty<string>();
var result = new TestDelegate(() => source.DistinctBy(null, StringComparer.Ordinal));
Assert.Throws(Is.InstanceOf(typeof(ArgumentNullException)), result);
}

[Test]
Expand All @@ -94,19 +93,19 @@ public void ForEach_Success()
}

[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void ForEach_NullAction_Success()
{
string[] source = { };
source.ForEach(null);
string[] source = Array.Empty<string>();
var result = new TestDelegate(() => source.ForEach(null));
Assert.Throws(Is.InstanceOf(typeof(ArgumentNullException)), result);
}

[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void ForEach_NullSource_Success()
{
string[] source = null;
source.ForEach(word => word.ToLower());
var result = new TestDelegate(() => source.ForEach(word => word.ToLower()));
Assert.Throws(Is.InstanceOf(typeof(ArgumentNullException)), result);
}
}

Expand Down
96 changes: 22 additions & 74 deletions FLS.Tests/FLS.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,85 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{B0B30274-DFD1-49B9-8E9E-EC04B3D7C6E3}</ProjectGuid>
<RootNamespace>FLS.Test</RootNamespace>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>FLS.Tests</RootNamespace>
<AssemblyName>FLS.Tests</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TargetFramework>net5.0</TargetFramework>
<LangVersion>7.3</LangVersion>
<DebugSymbols>true</DebugSymbols>
<PlatformTarget>AnyCPU</PlatformTarget>
<ExternalConsole>false</ExternalConsole>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<Nullable>disable</Nullable>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
</PropertyGroup>

<ItemGroup>
<Reference Include="nunit.framework, Version=2.6.3.13283, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<HintPath>..\Solution\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Defuzzification\CoGDefuzzificationTest.cs" />
<Compile Include="Defuzzification\TrapezoidCoGDefuzzificationTests.cs" />
<Compile Include="Extensions\IEnumerableExtensionsTests.cs" />
<Compile Include="InferenceEngines\CoGFuzzyEngineTests.cs" />
<Compile Include="InferenceEngines\FuzzyEngineFactoryTests.cs" />
<Compile Include="InferenceEngines\FuzzyEngineTests.cs" />
<Compile Include="MembershipFunctions\BellMembershipFunctionTests.cs" />
<Compile Include="MembershipFunctions\CompositeMembershipFunctionTests.cs" />
<Compile Include="MembershipFunctions\MembershipFunctionCollectionTests.cs" />
<Compile Include="MembershipFunctions\SandZShapedMembershipFunctionTests.cs" />
<Compile Include="Rules\FuzzyRuleTests.cs" />
<Compile Include="MembershipFunctions\GaussianMembershipFunctionTests.cs" />
<Compile Include="InferenceEngines\MoMFuzzyEngineTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Rules\FuzzyRuleEvaluatorTests.cs" />
<Compile Include="Rules\RuleFactoryTests.cs" />
<Compile Include="TestUtilities.cs" />
<Compile Include="MembershipFunctions\TrapezoidMembershipFunctionTests.cs" />
<Compile Include="Examples\UsageExampleTests.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<Compile Include="**/*.cs" Exclude="$(DefaultItemExcludes)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\FLS\FLS.csproj">
<Project>{008088ec-5365-4ebd-bc54-97fc0bb4876c}</Project>
<Name>FLS</Name>
<Private>False</Private>
</ProjectReference>
<PackageReference Include="NUnit" Version="3.13.2" />
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->

</Project>
13 changes: 4 additions & 9 deletions FLS.Tests/InferenceEngines/CoGFuzzyEngineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,12 @@
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// limitations under the License.
#endregion

using FLS.Constants;
using FLS.Rules;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FLS.Tests
{
Expand Down Expand Up @@ -91,7 +86,6 @@ public void CoG_Trap_Defuzzify2_Success(Int32 waterInputValue, Double expectedVa
}

[Test]
[ExpectedException(ExpectedException = typeof(ArgumentException), ExpectedMessage = ErrorMessages.AllMembershipFunctionsMustBeTrapezoid)]
public void CoG_Trap_Defuzzify_WrongType()
{
//Arrange
Expand All @@ -110,9 +104,10 @@ public void CoG_Trap_Defuzzify_WrongType()
fuzzyEngine.Rules.If(water.Is(hot)).Then(power.Is(low));

//Act
var result = fuzzyEngine.Defuzzify(new { water = 60 });
var result = new TestDelegate(() => fuzzyEngine.Defuzzify(new { water = 60 }));

//Assert
Assert.Throws(Is.InstanceOf(typeof(ApplicationException)), result, ErrorMessages.AllMembershipFunctionsMustBeTrapezoid);
}

[Test]
Expand Down
8 changes: 1 addition & 7 deletions FLS.Tests/InferenceEngines/FuzzyEngineFactoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,10 @@
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// limitations under the License.
#endregion
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FLS.Tests.InferenceEngines
{
Expand Down Expand Up @@ -47,7 +43,5 @@ public void Factory_EngineType_Success(FuzzyEngineType engineType, Type defuzzTy
Assert.That(engine, Is.InstanceOf<FuzzyEngine>());
Assert.That(engine.Defuzzification, Is.InstanceOf(defuzzType));
}


}
}
16 changes: 5 additions & 11 deletions FLS.Tests/InferenceEngines/FuzzyEngineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,11 @@
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// limitations under the License.
#endregion
using FLS.Constants;
using FLS.MembershipFunctions;
using FLS.Rules;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FLS.Tests
{
Expand All @@ -36,7 +30,6 @@ public void Setup()
}

[Test]
[ExpectedException(ExpectedException = typeof(Exception), ExpectedMessage = ErrorMessages.RulesAreInvalid)]
public void FuzzyEngine_InvalidRules_Success()
{
//Arrange
Expand All @@ -55,13 +48,13 @@ public void FuzzyEngine_InvalidRules_Success()
fuzzyEngine.Rules.If(water.Is(hot));

//Act
var result = fuzzyEngine.Defuzzify(new { water = 60 });
var result = new TestDelegate(() => fuzzyEngine.Defuzzify(new { water = 60 }));

//Assert
Assert.Throws(Is.InstanceOf(typeof(Exception)), result, ErrorMessages.RulesAreInvalid);
}

[Test]
[ExpectedException(ExpectedException = typeof(ArgumentException))]
public void FuzzyEngine_InvalidInputs_Success()
{
//Arrange
Expand All @@ -80,9 +73,10 @@ public void FuzzyEngine_InvalidInputs_Success()
fuzzyEngine.Rules.If(water.Is(hot)).Then(power.Is(high));

//Act
var result = fuzzyEngine.Defuzzify(new { water = "invalid input" });
var rule = new TestDelegate(() => fuzzyEngine.Defuzzify(new { water = "invalid input" }));

//Assert
Assert.Throws(Is.InstanceOf(typeof(ArgumentException)), rule);
}
}
}
Loading