Skip to content

Commit

Permalink
#48 - Added missing tests
Browse files Browse the repository at this point in the history
Fixed a bunch of spelling mistakes too.
  • Loading branch information
DavidArno committed Jul 23, 2018
1 parent 9bb38e2 commit 79e3c92
Show file tree
Hide file tree
Showing 30 changed files with 106 additions and 80 deletions.
2 changes: 2 additions & 0 deletions SuccincT.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=TVTE/@EntryIndexedValue">TVTE</s:String>
<s:Boolean x:Key="/Default/UserDictionary/Words/=analyser/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Composable/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Succinc/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
2 changes: 1 addition & 1 deletion tests/SuccincT.Tests.JSON/EitherConverterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void ConvertingRightEitherToJsonAndBack_PreservesEitherState()
}

[Test]
public void ConvertingListOfEithersToJsonAndBack_PreservesUEitherState()
public void ConvertingListOfEitherValuesToJsonAndBack_PreservesUEitherState()
{
var settings = new JsonSerializerSettings();
settings.Converters.Add(new EitherConverter());
Expand Down
32 changes: 16 additions & 16 deletions tests/SuccincT.Tests/ExampleTests/OptionMatcherExamplesTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,35 +83,35 @@ public void OptionMatcherPrintsNothingForNone()
}

[Test]
public void NumberNamerReturnsCorrectNames()
public void NumberToNameMapperReturnsCorrectNames()
{
var result = NumberNamer(Option<int>.Some(1)) +
NumberNamer(Option<int>.Some(2)) +
NumberNamer(Option<int>.Some(3)) +
NumberNamer(Option<int>.Some(4)) +
NumberNamer(Option<int>.Some(5)) +
NumberNamer(Option<int>.Some(6)) +
NumberNamer(Option<int>.Some(7)) +
NumberNamer(Option<int>.Some(8)) +
NumberNamer(Option<int>.Some(9));
var result = NumberToNameMapper(Option<int>.Some(1)) +
NumberToNameMapper(Option<int>.Some(2)) +
NumberToNameMapper(Option<int>.Some(3)) +
NumberToNameMapper(Option<int>.Some(4)) +
NumberToNameMapper(Option<int>.Some(5)) +
NumberToNameMapper(Option<int>.Some(6)) +
NumberToNameMapper(Option<int>.Some(7)) +
NumberToNameMapper(Option<int>.Some(8)) +
NumberToNameMapper(Option<int>.Some(9));

AreEqual("OneTwoThreeFourFiveSixSevenEightNine", result);
}

[Test]
public void NumberNamerReturnsNumbersForValuesOutside1To4()
public void NumberToNameMapperReturnsNumbersForValuesOutside1To4()
{
var result = NumberNamer(Option<int>.Some(-1)) +
NumberNamer(Option<int>.Some(0)) +
NumberNamer(Option<int>.Some(10));
var result = NumberToNameMapper(Option<int>.Some(-1)) +
NumberToNameMapper(Option<int>.Some(0)) +
NumberToNameMapper(Option<int>.Some(10));

AreEqual("-1010", result);
}

[Test]
public void NumberNamerReturnsNoneForNone()
public void NumberToNameMapperReturnsNoneForNone()
{
var result = NumberNamer(Option<int>.None());
var result = NumberToNameMapper(Option<int>.None());
AreEqual("None", result);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ namespace SuccincTTests.ExampleTests
public class ValueOrErrorExamplesTests
{
[Test]
public void IntPrefex_ReturnsInt()
public void IntPrefix_ReturnsInt()
{
var result = ValueOrErrorExamples.IntParser(ValueOrError.WithValue("Int:6"));
AreEqual(6, result.Value);
}

[Test]
public void IntPrefexReturnsNone_IfFollowedByJunk()
public void IntPrefixReturnsNone_IfFollowedByJunk()
{
var result = ValueOrErrorExamples.IntParser(ValueOrError.WithValue("Int:no number here"));
IsFalse(result.HasValue);
}

[Test]
public void ValueOtherThanIntPrefex_ReturnsNone()
public void ValueOtherThanIntPrefix_ReturnsNone()
{
var result = ValueOrErrorExamples.IntParser(ValueOrError.WithValue("xxx"));
IsFalse(result.HasValue);
Expand Down
2 changes: 1 addition & 1 deletion tests/SuccincT.Tests/Examples/OptionMatcherExamples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static void OptionMatcher(Option<int> data) =>
.None().Do(() => { })
.Exec();

public static string NumberNamer(Option<int> data)
public static string NumberToNameMapper(Option<int> data)
{
var names = new[] { "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine" };
return data.Match<string>()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using NUnit.Framework;
using SuccincT.Functional;
Expand Down Expand Up @@ -30,6 +31,7 @@ public void EmptyListConvertedToCons_CanBeEnumerated()
}

[Test]
[SuppressMessage("ReSharper", "StringLiteralTypo")]
public void EnumerationConvertedToCons_CanBeEnumeratedManyTimesWithoutReRunningOriginalEnumeration()
{
var enumRunCount = 0;
Expand Down Expand Up @@ -72,6 +74,7 @@ public void ManyItemsAddedToList_ResultsInThemAndOriginalListAllBeingEnumerated(
}

[Test]
[SuppressMessage("ReSharper", "StringLiteralTypo")]
public void EnumerationConvertedToConsAndItemsAdded_CanBeEnumeratedManyTimesWithoutReRunningOriginalEnumeration()
{
var enumRunCount = 0;
Expand All @@ -98,7 +101,7 @@ public void WhenListsAndItemsAddedToList_ResultsInThemAllBeingEnumerated()
}

[Test]
public void SplittingEnumerationViaCons_DoesntFullyEnumerateEnumeration()
public void SplittingEnumerationViaCons_DoesNotFullyEnumerateEnumeration()
{
var enumRunCount = 0;
var (_, _) = EnumerationWithNotificationOfEnd(() => enumRunCount++);
Expand Down Expand Up @@ -198,6 +201,7 @@ public void MultipleEnumerationConsEnumerable_CanBeCorrectlyReadViaDeconstruct()
}

[Test]
[SuppressMessage("ReSharper", "StringLiteralTypo")]
public void ForEach_WorksWithConsEnumerable()
{
var enumRunCount = 0;
Expand Down
2 changes: 1 addition & 1 deletion tests/SuccincT.Tests/SuccincT/Functional/UnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void AllUnits_AreEqual()
AreEqual(unit1, unit3);
AreEqual(unit2, unit3);

IsTrue(unit1.Equals((object)unit2));
IsTrue(unit1.Equals(unit2));
IsTrue(unit1.Equals((object)unit3));
IsTrue(unit2.Equals((object)unit3));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void SameSomeValue_AreEqualAndHaveSameHashCode()
}

[Test]
public void TwoNones_AreEqualAndHaveSameHashCode()
public void TwoNoneValues_AreEqualAndHaveSameHashCode()
{
var a = Option<string>.None();
var b = Option<string>.None();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void WhenKeyExists_TryGetValueReturnsValue()
}

[Test]
public void WhenKeyDoesntExists_TryGetValueReturnsNone()
public void WhenKeyDoesNotExist_TryGetValueReturnsNone()
{
var dict = new Dictionary<int, int> { [1] = 1 };
Assert.IsFalse(dict.TryGetValue(2).HasValue);
Expand Down
2 changes: 1 addition & 1 deletion tests/SuccincT.Tests/SuccincT/Options/OptionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void WhenOptionIsSomeElseIsDefinedAndNoSomeMatch_ElseResultIsReturned()
}

[Test]
public void WhenOptionIsSomeElseIsDefinedAndSomeDoesntMatch_ElseResultIsReturned()
public void WhenOptionIsSomeElseIsDefinedAndSomeDoesNotMatch_ElseResultIsReturned()
{
var option = Option<int>.Some(2);
var result = option.Match<int>().Some().Of(1).Do(x => 1).None().Do(() => 0).Else(o => o.Value).Result();
Expand Down
2 changes: 1 addition & 1 deletion tests/SuccincT.Tests/SuccincT/Options/SingleOrNoneTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void TrySingleWithCollectionAndMatchManyElementFunc_ReturnsNone()
}

[Test]
public void TrySingleWithNullFunc_ThrowsExcpetion()
public void TrySingleWithNullFunc_ThrowsException()
{
var collection = new List<int> { 1, 2, 3 };
Assert.Throws<ArgumentNullException>(() => collection.TrySingle(null));
Expand Down
4 changes: 2 additions & 2 deletions tests/SuccincT.Tests/SuccincT/Options/SuccessTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public void WhenFailureAndElseIsDefinedAndNoErrorMatch_ElseIsExecuted()
}

[Test]
public void WhenFailureAndElseIsDefinedAndErrorDoesntMatch_ElseIsExecuted()
public void WhenFailureAndElseIsDefinedAndErrorDoesNotMatch_ElseIsExecuted()
{
var success = Success.CreateFailure(2);
var result = 0;
Expand All @@ -163,7 +163,7 @@ public void WhenFailureAndElseIsDefinedAndNoErrorMatch_ElseResultIsReturned()
}

[Test]
public void WhenFailureAndElseIsDefinedAndErrorDoesntMatch_ElseResultIsReturned()
public void WhenFailureAndElseIsDefinedAndErrorDoesNotMatch_ElseResultIsReturned()
{
var success = Success.CreateFailure(2);
var result = success.Match<int>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace SuccincTTests.SuccincT.Options
{
[TestFixture]
public sealed class ValueOrErrorT1T2ExecTests
public sealed class ValueOrErrorTVTEExecTests
{
[Test]
public void WhenValueIsSet_OnlyValueActionOccurs()
Expand Down Expand Up @@ -79,6 +79,24 @@ public void WhenErrorIsSetAndNoErrorMatchDefinedForExec_ExceptionThrown()
Throws<NoMatchException>(() => valueOrError.Match().Value().Do(x => { }).Exec());
}

[Test]
public void WhenValueIsSetAndNoValueMatchDefinedForExecAndIgnoreElseUsed_NoActionTaken()
{
var result = "1";
var valueOrError = WithValue("2");
valueOrError.Match().Error().Do(x => result = "2").IgnoreElse().Exec();
AreEqual("1", result);
}

[Test]
public void WhenErrorIsSetAndNoErrorMatchDefinedForExecAndIgnoreElseUsed_NoActionTaken()
{
var result = 1;
var valueOrError = WithError(new Exception("x"));
valueOrError.Match().Value().Do(x => result = 2).IgnoreElse().Exec();
AreEqual(1, result);
}

private static ValueOrError<string, Exception> WithValue(string s)
=> ValueOrError<string, Exception>.WithValue(s);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace SuccincTTests.SuccincT.Options
{
[TestFixture]
public sealed class ValueOrErrorT1T2Tests
public sealed class ValueOrErrorTVTETests
{
[Test]
public void WhenValueIsSet_ValueSuppliedToFunction()
Expand Down Expand Up @@ -94,7 +94,7 @@ public void WhenErrorIsSetAndNoErrorMatch_ElseResultIsReturned()
public void WhenValueIsSetAndNoErrorMatch_ElseResultIsReturned()
{
var valueOrError = WithValue("1");
var result = valueOrError.Match<int>().Error().Do(x => 2).Else(x => 3).Result();
var result = valueOrError.Match<int>().Error().Do(x => 2).Else(3).Result();
AreEqual(3, result);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/SuccincT.Tests/SuccincT/PatternMatchers/AnyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace SuccincTTests.SuccincT.PatternMatchers
public class AnyTests
{
[Test]
public void AnyTwoAnys_AreEqual()
public void AnyTwoAnyValues_AreEqual()
{
var x = any;
var y = any;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using NUnit.Framework;
using SuccincT.PatternMatchers;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using static NUnit.Framework.Assert;

Expand Down Expand Up @@ -75,7 +76,7 @@ public void SingleItemList_CanBeMatchedWithWhereWithResultViaLambda()
}

[Test]
public void SingleItemList_CanBeMatchedWhenWhereDoesntMatch()
public void SingleItemList_CanBeMatchedWhenWhereDoesNotMatch()
{
var list = new List<int> { 0 };
var result = list.Match().To<bool>()
Expand Down Expand Up @@ -227,6 +228,7 @@ public void MultiItemList_CanBeRecursivelyMatchedUsingWhere()
}

[Test]
[SuppressMessage("ReSharper", "StringLiteralTypo")]
public void MultiItemIList_CanBeRecursivelyMatchedUsingWhere()
{
var list = StringList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void Tuple_CanBeMatchedUsingAnyStringAndColorWithExec()
}

[Test]
public void Tuple_CanBeMatchedUsingThreeAnysWithExec()
public void Tuple_CanBeMatchedUsingThreeAnyValueWithExec()
{
var tuple = Tuple.Create(1, "a", Colors.Red);
var result = false;
Expand Down Expand Up @@ -128,7 +128,7 @@ public void Tuple_CanBeMatchedViaOrUsingAnyStringAndColorWithExec()
}

[Test]
public void Tuple_CanBeMatchedViaOrUsingThreeAnysWithExec()
public void Tuple_CanBeMatchedViaOrUsingThreeAnyValuesWithExec()
{
var tuple = Tuple.Create(1, "a", Colors.Red);
var result = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void Tuple_CanBeMatchedUsingAnyAnimalWithExec()
}

[Test]
public void Tuple_CanBeMatchedUsingFourAnysWithExec()
public void Tuple_CanBeMatchedUsingFourAnyValuesWithExec()
{
var tuple = Tuple.Create(1, "a", Colors.Red, Animals.Cow);
var result = false;
Expand Down Expand Up @@ -101,7 +101,7 @@ public void Tuple_CanBeMatchedViaOrUsingAnyAnimalWithExec()
}

[Test]
public void Tuple_CanBeMatchedViaOrUsingFourAnysWithExec()
public void Tuple_CanBeMatchedViaOrUsingFourAnyValuesWithExec()
{
var tuple = Tuple.Create(1, "a", Colors.Green, Animals.Cow);
var result = false;
Expand Down Expand Up @@ -165,7 +165,7 @@ public void TupleWithAndWhereDefinedUsingAnyInt_WhereCorrectlyUsedWithExec()
}

[Test]
public void TupleWithAndWhereDefinedUsingFourAnys_WithCorrectlyUsedWithExec()
public void TupleWithAndWhereDefinedUsingFourAnyValues_WithCorrectlyUsedWithExec()
{
var tuple = Tuple.Create(1, "a", Colors.Red, Animals.Cow);
var result = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace SuccincTTests.SuccincT.Tuples
{
[TestFixture]
internal class TupleMatchebleTestsT1T2T3
internal class TupleMatchableTestsT1T2T3
{
private enum Colors { Red, Green, Blue }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void Tuple_CanBeMatchedWithAnyString()
}

[Test]
public void Tuple_CanBeMatchedWithTwoAnys()
public void Tuple_CanBeMatchedWithTwoAnyValues()
{
var tuple = new TestClass { A = 1, B = "a" };
var result = tuple.Match().To<bool>().With(__, __).Do((x, y) => true).Result();
Expand All @@ -57,7 +57,7 @@ public void Tuple_CanBeMatchedViaOrWithAnyString()
}

[Test]
public void Tuple_CanBeMatchedViaOrWithTwoAnys()
public void Tuple_CanBeMatchedViaOrWithTwoAnyValues()
{
var tuple = new TestClass { A = 1, B = "a" };
var result = tuple.Match().To<bool>().With(2, __).Or(any, any).Do((x, y) => true).Result();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace SuccincTTests.SuccincT.Tuples
{
[TestFixture]
internal class TupleMatchebleTestsUsingAnyT1T2T3
internal class TupleMatchableTestsUsingAnyT1T2T3
{
private enum Colors { Red, Green, Blue }

Expand Down Expand Up @@ -67,7 +67,7 @@ public void Tuple_CanBeMatchedUsingAnyStringAndColor()
}

[Test]
public void Tuple_CanBeMatchedUsingThreeAnys()
public void Tuple_CanBeMatchedUsingThreeAnyValues()
{
var tuple = new TestClass { A = 1, B = "a", C = Colors.Red };
var result = tuple.Match().To<bool>().With(__, __, __).Do((x, y, z) => true).Result();
Expand Down Expand Up @@ -129,7 +129,7 @@ public void Tuple_CanBeMatchedViaOrUsingAnyStringAndColor()
}

[Test]
public void Tuple_CanBeMatchedViaOrUsingThreeAnys()
public void Tuple_CanBeMatchedViaOrUsingThreeAnyValues()
{
var tuple = new TestClass { A = 1, B = "a", C = Colors.Red };
var result = tuple.Match().To<bool>().With(1, "a", Colors.Blue).Or(__, __, __).Do((x, y, z) => true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void Tuple_CanBeMatchedViaOrWithAnyAnimal()
}

[Test]
public void Tuple_CanBeMatchedViaOrWithFourAnys()
public void Tuple_CanBeMatchedViaOrWithFourAnyValues()
{
var tuple = new TestClass { A = 1, B = "a", C = Colors.Blue, D = Animals.Cow };
var result = tuple.Match().To<bool>().With(1, "a", Colors.Green, Animals.Pig)
Expand Down
Loading

0 comments on commit 79e3c92

Please sign in to comment.