🚚 Move X10D tests to Core namespace

This commit is contained in:
Oliver Booth 2020-07-15 14:32:59 +01:00
parent ad1c2f5e7c
commit 600b37fe82
12 changed files with 200 additions and 200 deletions

View File

@ -1,92 +1,15 @@
namespace X10D.Tests
namespace X10D.Tests.Core
{
using Microsoft.VisualStudio.TestTools.UnitTesting;
/// <summary>
/// Tests for <see cref="BooleanExtensions"/>.
/// Tests for <see cref="BooleanExtensions" />.
/// </summary>
[TestClass]
public class BooleanTests
{
/// <summary>
/// Tests for <see cref="BooleanExtensions.ToByte"/>.
/// </summary>
[TestMethod]
public void ToByte()
{
const bool a = true;
const bool b = false;
const byte c = 1;
const byte d = 0;
Assert.IsTrue(a);
Assert.IsFalse(b);
Assert.AreEqual(c, a.ToByte());
Assert.AreEqual(d, b.ToByte());
}
/// <summary>
/// Tests for <see cref="BooleanExtensions.ToInt16"/>.
/// </summary>
[TestMethod]
public void ToInt16()
{
const bool a = true;
const bool b = false;
Assert.IsTrue(a);
Assert.IsFalse(b);
Assert.AreEqual(1, a.ToInt16());
Assert.AreEqual(0, b.ToInt16());
}
/// <summary>
/// Tests for <see cref="BooleanExtensions.ToInt32"/>.
/// </summary>
[TestMethod]
public void ToInt32()
{
const bool a = true;
const bool b = false;
Assert.IsTrue(a);
Assert.IsFalse(b);
Assert.AreEqual(1, a.ToInt32());
Assert.AreEqual(0, b.ToInt32());
}
/// <summary>
/// Tests for <see cref="BooleanExtensions.ToInt64"/>.
/// </summary>
[TestMethod]
public void ToInt64()
{
const bool a = true;
const bool b = false;
Assert.IsTrue(a);
Assert.IsFalse(b);
Assert.AreEqual(1L, a.ToInt64());
Assert.AreEqual(0L, b.ToInt64());
}
/// <summary>
/// Tests for <see cref="BooleanExtensions.Not"/>.
/// </summary>
[TestMethod]
public void Not()
{
const bool a = true;
const bool b = false;
Assert.IsTrue(a);
Assert.IsFalse(b);
Assert.IsFalse(a.Not());
Assert.IsTrue(b.Not());
}
/// <summary>
/// Tests for <see cref="BooleanExtensions.And"/>.
/// Tests for <see cref="BooleanExtensions.And" />.
/// </summary>
[TestMethod]
public void And()
@ -107,49 +30,7 @@ namespace X10D.Tests
}
/// <summary>
/// Tests for <see cref="BooleanExtensions.Or"/>.
/// </summary>
[TestMethod]
public void Or()
{
const bool a = true;
const bool b = true;
const bool c = false;
const bool d = false;
Assert.IsTrue(a);
Assert.IsTrue(b);
Assert.IsFalse(c);
Assert.IsFalse(d);
Assert.IsTrue(a.Or(b));
Assert.IsTrue(b.Or(c));
Assert.IsFalse(c.Or(d));
}
/// <summary>
/// Tests for <see cref="BooleanExtensions.XOr"/>.
/// </summary>
[TestMethod]
public void XOr()
{
const bool a = true;
const bool b = true;
const bool c = false;
const bool d = false;
Assert.IsTrue(a);
Assert.IsTrue(b);
Assert.IsFalse(c);
Assert.IsFalse(d);
Assert.IsFalse(a.XOr(b));
Assert.IsTrue(b.XOr(c));
Assert.IsFalse(c.XOr(d));
}
/// <summary>
/// Tests for <see cref="BooleanExtensions.NAnd"/>.
/// Tests for <see cref="BooleanExtensions.NAnd" />.
/// </summary>
[TestMethod]
public void NAnd()
@ -170,7 +51,7 @@ namespace X10D.Tests
}
/// <summary>
/// Tests for <see cref="BooleanExtensions.NOr"/>.
/// Tests for <see cref="BooleanExtensions.NOr" />.
/// </summary>
[TestMethod]
public void NOr()
@ -191,7 +72,105 @@ namespace X10D.Tests
}
/// <summary>
/// Tests for <see cref="BooleanExtensions.XNOr"/>.
/// Tests for <see cref="BooleanExtensions.Not" />.
/// </summary>
[TestMethod]
public void Not()
{
const bool a = true;
const bool b = false;
Assert.IsTrue(a);
Assert.IsFalse(b);
Assert.IsFalse(a.Not());
Assert.IsTrue(b.Not());
}
/// <summary>
/// Tests for <see cref="BooleanExtensions.Or" />.
/// </summary>
[TestMethod]
public void Or()
{
const bool a = true;
const bool b = true;
const bool c = false;
const bool d = false;
Assert.IsTrue(a);
Assert.IsTrue(b);
Assert.IsFalse(c);
Assert.IsFalse(d);
Assert.IsTrue(a.Or(b));
Assert.IsTrue(b.Or(c));
Assert.IsFalse(c.Or(d));
}
/// <summary>
/// Tests for <see cref="BooleanExtensions.ToByte" />.
/// </summary>
[TestMethod]
public void ToByte()
{
const bool a = true;
const bool b = false;
const byte c = 1;
const byte d = 0;
Assert.IsTrue(a);
Assert.IsFalse(b);
Assert.AreEqual(c, a.ToByte());
Assert.AreEqual(d, b.ToByte());
}
/// <summary>
/// Tests for <see cref="BooleanExtensions.ToInt16" />.
/// </summary>
[TestMethod]
public void ToInt16()
{
const bool a = true;
const bool b = false;
Assert.IsTrue(a);
Assert.IsFalse(b);
Assert.AreEqual(1, a.ToInt16());
Assert.AreEqual(0, b.ToInt16());
}
/// <summary>
/// Tests for <see cref="BooleanExtensions.ToInt32" />.
/// </summary>
[TestMethod]
public void ToInt32()
{
const bool a = true;
const bool b = false;
Assert.IsTrue(a);
Assert.IsFalse(b);
Assert.AreEqual(1, a.ToInt32());
Assert.AreEqual(0, b.ToInt32());
}
/// <summary>
/// Tests for <see cref="BooleanExtensions.ToInt64" />.
/// </summary>
[TestMethod]
public void ToInt64()
{
const bool a = true;
const bool b = false;
Assert.IsTrue(a);
Assert.IsFalse(b);
Assert.AreEqual(1L, a.ToInt64());
Assert.AreEqual(0L, b.ToInt64());
}
/// <summary>
/// Tests for <see cref="BooleanExtensions.XNOr" />.
/// </summary>
[TestMethod]
public void XNOr()
@ -210,5 +189,26 @@ namespace X10D.Tests
Assert.IsFalse(b.XNOr(c));
Assert.IsTrue(c.XNOr(d));
}
/// <summary>
/// Tests for <see cref="BooleanExtensions.XOr" />.
/// </summary>
[TestMethod]
public void XOr()
{
const bool a = true;
const bool b = true;
const bool c = false;
const bool d = false;
Assert.IsTrue(a);
Assert.IsTrue(b);
Assert.IsFalse(c);
Assert.IsFalse(d);
Assert.IsFalse(a.XOr(b));
Assert.IsTrue(b.XOr(c));
Assert.IsFalse(c.XOr(d));
}
}
}

View File

@ -1,17 +1,17 @@
namespace X10D.Tests
namespace X10D.Tests.Core
{
using System.Collections.Generic;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
/// <summary>
/// Tests for <see cref="ByteExtensions"/>.
/// Tests for <see cref="ByteExtensions" />.
/// </summary>
[TestClass]
public class ByteTests
{
/// <summary>
/// Tests for <see cref="ByteExtensions.AsString"/>.
/// Tests for <see cref="ByteExtensions.AsString" />.
/// </summary>
[TestMethod]
public void AsString()
@ -21,7 +21,7 @@ namespace X10D.Tests
}
/// <summary>
/// Tests for <see cref="ByteExtensions.GetInt16"/>.
/// Tests for <see cref="ByteExtensions.GetInt16" />.
/// </summary>
[TestMethod]
public void GetInt16()
@ -31,7 +31,7 @@ namespace X10D.Tests
}
/// <summary>
/// Tests for <see cref="ByteExtensions.GetInt32"/>.
/// Tests for <see cref="ByteExtensions.GetInt32" />.
/// </summary>
[TestMethod]
public void GetInt32()
@ -41,7 +41,7 @@ namespace X10D.Tests
}
/// <summary>
/// Tests for <see cref="ByteExtensions.GetInt64"/>.
/// Tests for <see cref="ByteExtensions.GetInt64" />.
/// </summary>
[TestMethod]
public void GetInt64()
@ -51,7 +51,7 @@ namespace X10D.Tests
}
/// <summary>
/// Tests for <see cref="ByteExtensions.GetString(IEnumerable{byte})"/>.
/// Tests for <see cref="ByteExtensions.GetString(IEnumerable{byte})" />.
/// </summary>
[TestMethod]
public void GetString()
@ -61,7 +61,7 @@ namespace X10D.Tests
}
/// <summary>
/// Tests for <see cref="ByteExtensions.GetString(IEnumerable{byte}, Encoding)"/>.
/// Tests for <see cref="ByteExtensions.GetString(IEnumerable{byte}, Encoding)" />.
/// </summary>
[TestMethod]
public void GetStringAscii()
@ -71,7 +71,7 @@ namespace X10D.Tests
}
/// <summary>
/// Tests for <see cref="ByteExtensions.GetUInt16"/>.
/// Tests for <see cref="ByteExtensions.GetUInt16" />.
/// </summary>
[TestMethod]
public void GetUInt16()
@ -81,7 +81,7 @@ namespace X10D.Tests
}
/// <summary>
/// Tests for <see cref="ByteExtensions.GetUInt32"/>.
/// Tests for <see cref="ByteExtensions.GetUInt32" />.
/// </summary>
[TestMethod]
public void GetUInt32()
@ -91,7 +91,7 @@ namespace X10D.Tests
}
/// <summary>
/// Tests for <see cref="ByteExtensions.GetUInt64"/>.
/// Tests for <see cref="ByteExtensions.GetUInt64" />.
/// </summary>
[TestMethod]
public void GetUInt64()

View File

@ -1,17 +1,17 @@
namespace X10D.Tests
namespace X10D.Tests.Core
{
using System;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
/// <summary>
/// Tests for <see cref="CharExtensions"/>.
/// Tests for <see cref="CharExtensions" />.
/// </summary>
[TestClass]
public class CharTests
{
/// <summary>
/// Tests for <see cref="CharExtensions.Repeat"/>.
/// Tests for <see cref="CharExtensions.Repeat" />.
/// </summary>
[TestMethod]
public void Random()
@ -24,7 +24,7 @@ namespace X10D.Tests
}
/// <summary>
/// Tests for <see cref="CharExtensions.Repeat"/>.
/// Tests for <see cref="CharExtensions.Repeat" />.
/// </summary>
[TestMethod]
public void Repeat()

View File

@ -1,15 +1,15 @@
namespace X10D.Tests
namespace X10D.Tests.Core
{
using Microsoft.VisualStudio.TestTools.UnitTesting;
/// <summary>
/// Tests for <see cref="ComparableExtensions"/>.
/// Tests for <see cref="ComparableExtensions" />.
/// </summary>
[TestClass]
public class ComparableTests
{
/// <summary>
/// Tests for <see cref="ComparableExtensions.Between{T}"/>.
/// Tests for <see cref="ComparableExtensions.Between{T}" />.
/// </summary>
[TestMethod]
public void Between()

View File

@ -1,16 +1,16 @@
namespace X10D.Tests
namespace X10D.Tests.Core
{
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
/// <summary>
/// Tests for <see cref="ConvertibleExtensions"/>.
/// Tests for <see cref="ConvertibleExtensions" />.
/// </summary>
[TestClass]
public class ConvertibleTests
{
/// <summary>
/// Tests for <see cref="ConvertibleExtensions.To{T}"/>.
/// Tests for <see cref="ConvertibleExtensions.To{T}" />.
/// </summary>
[TestMethod]
public void To()
@ -21,7 +21,7 @@ namespace X10D.Tests
}
/// <summary>
/// Tests for <see cref="ConvertibleExtensions.ToOrDefault{T}(System.IConvertible, System.IFormatProvider)"/>.
/// Tests for <see cref="ConvertibleExtensions.ToOrDefault{T}(System.IConvertible, System.IFormatProvider)" />.
/// </summary>
[TestMethod]
public void ToOrDefault()
@ -35,7 +35,17 @@ namespace X10D.Tests
}
/// <summary>
/// Tests for <see cref="ConvertibleExtensions.ToOrOther{T}(System.IConvertible, T, System.IFormatProvider)"/>.
/// Tests for <see cref="ConvertibleExtensions.ToOrNull{T}(System.IConvertible, System.IFormatProvider)" />.
/// </summary>
[TestMethod]
public void ToOrNull()
{
Assert.IsFalse("foo".ToOrNull(out ConvertibleTests t));
Assert.IsNull(t);
}
/// <summary>
/// Tests for <see cref="ConvertibleExtensions.ToOrOther{T}(System.IConvertible, T, System.IFormatProvider)" />.
/// </summary>
[TestMethod]
public void ToOrOther()
@ -44,15 +54,5 @@ namespace X10D.Tests
Assert.IsFalse("Foo".ToOrOther(out var d, 2.0));
Assert.AreEqual(2.0, d);
}
/// <summary>
/// Tests for <see cref="ConvertibleExtensions.ToOrNull{T}(System.IConvertible, System.IFormatProvider)"/>.
/// </summary>
[TestMethod]
public void ToOrNull()
{
Assert.IsFalse("foo".ToOrNull(out ConvertibleTests t));
Assert.IsNull(t);
}
}
}

View File

@ -1,30 +1,30 @@
namespace X10D.Tests
namespace X10D.Tests.Core
{
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
/// <summary>
/// Tests for <see cref="DateTimeExtensions"/>.
/// Tests for <see cref="DateTimeExtensions" />.
/// </summary>
[TestClass]
public class DateTimeTests
{
/// <summary>
/// Tests for <see cref="DateTimeExtensions.Age(DateTime)"/>.
/// Tests for <see cref="DateTimeExtensions.Age(DateTime)" />.
/// </summary>
[TestMethod]
public void Age()
{
// no choice but to create dynamic based on today's date.
// age varies with time
DateTime now = DateTime.Now;
var now = DateTime.Now;
var dt = new DateTime(now.Year - 18, 1, 1);
Assert.AreEqual(18, dt.Age());
}
/// <summary>
/// Tests for <see cref="DateTimeExtensions.First"/>.
/// Tests for <see cref="DateTimeExtensions.First" />.
/// </summary>
[TestMethod]
public void First()
@ -35,13 +35,13 @@ namespace X10D.Tests
}
/// <summary>
/// Tests for <see cref="DateTimeExtensions.FirstDayOfMonth"/>.
/// Tests for <see cref="DateTimeExtensions.FirstDayOfMonth" />.
/// </summary>
[TestMethod]
public void FirstDayOfMonth()
{
var dt = new DateTime(2018, 6, 20);
DateTime first = dt.FirstDayOfMonth();
var first = dt.FirstDayOfMonth();
Assert.AreEqual(dt.Year, first.Year);
Assert.AreEqual(dt.Month, first.Month);
@ -49,14 +49,14 @@ namespace X10D.Tests
}
/// <summary>
/// Tests for <see cref="DateTimeExtensions.Last"/>.
/// Tests for <see cref="DateTimeExtensions.Last" />.
/// </summary>
[TestMethod]
public void Last()
{
{
var dt = new DateTime(2019, 12, 1);
DateTime last = dt.Last(DayOfWeek.Wednesday);
var last = dt.Last(DayOfWeek.Wednesday);
Assert.AreEqual(dt.Year, last.Year);
Assert.AreEqual(dt.Month, last.Month);
@ -65,7 +65,7 @@ namespace X10D.Tests
{
var dt = new DateTime(2020, 4, 14);
DateTime last = dt.Last(DayOfWeek.Friday);
var last = dt.Last(DayOfWeek.Friday);
Assert.AreEqual(dt.Year, last.Year);
Assert.AreEqual(dt.Month, last.Month);
@ -79,13 +79,13 @@ namespace X10D.Tests
}
/// <summary>
/// Tests for <see cref="DateTimeExtensions.LastDayOfMonth"/>.
/// Tests for <see cref="DateTimeExtensions.LastDayOfMonth" />.
/// </summary>
[TestMethod]
public void LastDayOfMonth()
{
var dt = new DateTime(2016, 2, 4);
DateTime last = dt.LastDayOfMonth();
var last = dt.LastDayOfMonth();
Assert.AreEqual(dt.Year, last.Year);
Assert.AreEqual(dt.Month, last.Month);
@ -93,7 +93,7 @@ namespace X10D.Tests
}
/// <summary>
/// Tests for <see cref="DateTimeExtensions.ToUnixTimeStamp"/>.
/// Tests for <see cref="DateTimeExtensions.ToUnixTimeStamp" />.
/// </summary>
[TestMethod]
public void ToUnixTimestamp()

View File

@ -1,16 +1,16 @@
namespace X10D.Tests
namespace X10D.Tests.Core
{
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
/// <summary>
/// Tests for <see cref="DictionaryExtensions"/>.
/// Tests for <see cref="DictionaryExtensions" />.
/// </summary>
[TestClass]
public class DictionaryTests
{
/// <summary>
/// Tests for <see cref="DictionaryExtensions.ToConnectionString{T1,T2}(IDictionary{T1,T2})"/>.
/// Tests for <see cref="DictionaryExtensions.ToConnectionString{T1,T2}(IDictionary{T1,T2})" />.
/// </summary>
[TestMethod]
public void ToConnectionString()
@ -25,7 +25,7 @@ namespace X10D.Tests
}
/// <summary>
/// Tests for <see cref="DictionaryExtensions.ToGetParameters{T1,T2}(IDictionary{T1,T2})"/>.
/// Tests for <see cref="DictionaryExtensions.ToGetParameters{T1,T2}(IDictionary{T1,T2})" />.
/// </summary>
[TestMethod]
public void ToGetParameters()

View File

@ -1,16 +1,16 @@
namespace X10D.Tests
namespace X10D.Tests.Core
{
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
/// <summary>
/// Tests for <see cref="DoubleExtensions"/>.
/// Tests for <see cref="DoubleExtensions" />.
/// </summary>
[TestClass]
public class DoubleTests
{
/// <summary>
/// Tests for <see cref="DoubleExtensions.Clamp"/>.
/// Tests for <see cref="DoubleExtensions.Clamp" />.
/// </summary>
[TestMethod]
public void Clamp()
@ -20,7 +20,7 @@ namespace X10D.Tests
}
/// <summary>
/// Tests for <see cref="DoubleExtensions.DegreesToRadians"/>.
/// Tests for <see cref="DoubleExtensions.DegreesToRadians" />.
/// </summary>
[TestMethod]
public void DegreesToRadians()
@ -30,7 +30,7 @@ namespace X10D.Tests
}
/// <summary>
/// Tests for <see cref="DoubleExtensions.GetBytes"/>.
/// Tests for <see cref="DoubleExtensions.GetBytes" />.
/// </summary>
[TestMethod]
public void GetBytes()
@ -41,7 +41,7 @@ namespace X10D.Tests
}
/// <summary>
/// Tests for <see cref="DoubleExtensions.IsEven"/>.
/// Tests for <see cref="DoubleExtensions.IsEven" />.
/// </summary>
[TestMethod]
public void IsEven()
@ -51,7 +51,7 @@ namespace X10D.Tests
}
/// <summary>
/// Tests for <see cref="DoubleExtensions.IsOdd"/>.
/// Tests for <see cref="DoubleExtensions.IsOdd" />.
/// </summary>
[TestMethod]
public void IsOdd()
@ -61,7 +61,7 @@ namespace X10D.Tests
}
/// <summary>
/// Tests for <see cref="DoubleExtensions.RadiansToDegrees"/>.
/// Tests for <see cref="DoubleExtensions.RadiansToDegrees" />.
/// </summary>
[TestMethod]
public void RadiansToDegrees()
@ -71,7 +71,7 @@ namespace X10D.Tests
}
/// <summary>
/// Tests for <see cref="DoubleExtensions.Round"/>.
/// Tests for <see cref="DoubleExtensions.Round" />.
/// </summary>
[TestMethod]
public void Round()

View File

@ -1,17 +1,17 @@
namespace X10D.Tests
namespace X10D.Tests.Core
{
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
/// <summary>
/// Tests for <see cref="EnumerableExtensions"/>.
/// Tests for <see cref="EnumerableExtensions" />.
/// </summary>
[TestClass]
public class EnumerableTests
{
/// <summary>
/// Tests for <see cref="EnumerableExtensions.Split{T}"/> using an array of <see cref="byte"/>.
/// Tests for <see cref="EnumerableExtensions.Split{T}" /> using an array of <see cref="byte" />.
/// </summary>
[TestMethod]
public void SplitByte()
@ -32,7 +32,7 @@
}
/// <summary>
/// Tests for <see cref="EnumerableExtensions.Split{T}"/> using an array of <see cref="int"/>.
/// Tests for <see cref="EnumerableExtensions.Split{T}" /> using an array of <see cref="int" />.
/// </summary>
[TestMethod]
public void SplitInt32()

View File

@ -1,17 +1,17 @@
namespace X10D.Tests
namespace X10D.Tests.Core
{
using System;
using System.ComponentModel;
using Microsoft.VisualStudio.TestTools.UnitTesting;
/// <summary>
/// Tests for <see cref="ReflectionExtensions"/>.
/// Tests for <see cref="ReflectionExtensions" />.
/// </summary>
[TestClass]
public class ReflectionTests
{
/// <summary>
/// Test for <see cref="ReflectionExtensions.GetDefaultValue{T}(System.Reflection.MemberInfo)"/>.
/// Test for <see cref="ReflectionExtensions.GetDefaultValue{T}(System.Reflection.MemberInfo)" />.
/// </summary>
[TestMethod]
public void GetDefaultValue()
@ -25,7 +25,7 @@
}
/// <summary>
/// Test for <see cref="ReflectionExtensions.GetDescription(System.Reflection.MemberInfo)"/>.
/// Test for <see cref="ReflectionExtensions.GetDescription(System.Reflection.MemberInfo)" />.
/// </summary>
[TestMethod]
public void GetDescription()
@ -39,7 +39,7 @@
}
/// <summary>
/// Test for <see cref="ReflectionExtensions.GetDescription(System.Reflection.MemberInfo)"/>.
/// Test for <see cref="ReflectionExtensions.GetDescription(System.Reflection.MemberInfo)" />.
/// </summary>
[TestMethod]
public void SelectFromCustomAttribute()

View File

@ -1,16 +1,16 @@
namespace X10D.Tests
namespace X10D.Tests.Core
{
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
/// <summary>
/// Tests for <see cref="StringExtensions"/>.
/// Tests for <see cref="StringExtensions" />.
/// </summary>
[TestClass]
public class StringTests
{
/// <summary>
/// Tests for <see cref="StringExtensions.Repeat"/>.
/// Tests for <see cref="StringExtensions.Repeat" />.
/// </summary>
[TestMethod]
public void Repeat()
@ -19,7 +19,7 @@
}
/// <summary>
/// Tests for <see cref="StringExtensions.Split"/>.
/// Tests for <see cref="StringExtensions.Split" />.
/// </summary>
[TestMethod]
public void Split()

View File

@ -1,16 +1,16 @@
namespace X10D.Tests
namespace X10D.Tests.Core
{
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
/// <summary>
/// Tests for <see cref="TimeSpanParser"/>.
/// Tests for <see cref="TimeSpanParser" />.
/// </summary>
[TestClass]
public class TimeSpanParserTests
{
/// <summary>
/// Tests for <see cref="TimeSpanParser.Parse"/>.
/// Tests for <see cref="TimeSpanParser.Parse" />.
/// </summary>
[TestMethod]
public void TestParser()