mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-09 23:25:43 +00:00
Remove legacy tests
This commit is contained in:
parent
64bcb34a11
commit
1c0768c472
@ -1,107 +0,0 @@
|
||||
namespace X10D.Tests.Core
|
||||
{
|
||||
using System;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
/// <summary>
|
||||
/// Tests for <see cref="DateTimeExtensions" />.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class DateTimeTests
|
||||
{
|
||||
/// <summary>
|
||||
/// 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
|
||||
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" />.
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void First()
|
||||
{
|
||||
var dt = new DateTime(2018, 6, 20);
|
||||
|
||||
Assert.AreEqual(4, dt.First(DayOfWeek.Monday).Day);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests for <see cref="DateTimeExtensions.FirstDayOfMonth" />.
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void FirstDayOfMonth()
|
||||
{
|
||||
var dt = new DateTime(2018, 6, 20);
|
||||
var first = dt.FirstDayOfMonth();
|
||||
|
||||
Assert.AreEqual(dt.Year, first.Year);
|
||||
Assert.AreEqual(dt.Month, first.Month);
|
||||
Assert.AreEqual(1, first.Day);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests for <see cref="DateTimeExtensions.Last" />.
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void Last()
|
||||
{
|
||||
{
|
||||
var dt = new DateTime(2019, 12, 1);
|
||||
var last = dt.Last(DayOfWeek.Wednesday);
|
||||
|
||||
Assert.AreEqual(dt.Year, last.Year);
|
||||
Assert.AreEqual(dt.Month, last.Month);
|
||||
Assert.AreEqual(25, last.Day);
|
||||
}
|
||||
|
||||
{
|
||||
var dt = new DateTime(2020, 4, 14);
|
||||
var last = dt.Last(DayOfWeek.Friday);
|
||||
|
||||
Assert.AreEqual(dt.Year, last.Year);
|
||||
Assert.AreEqual(dt.Month, last.Month);
|
||||
Assert.AreEqual(24, last.Day);
|
||||
|
||||
last = dt.Last(DayOfWeek.Thursday);
|
||||
Assert.AreEqual(dt.Year, last.Year);
|
||||
Assert.AreEqual(dt.Month, last.Month);
|
||||
Assert.AreEqual(30, last.Day);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests for <see cref="DateTimeExtensions.LastDayOfMonth" />.
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void LastDayOfMonth()
|
||||
{
|
||||
var dt = new DateTime(2016, 2, 4);
|
||||
var last = dt.LastDayOfMonth();
|
||||
|
||||
Assert.AreEqual(dt.Year, last.Year);
|
||||
Assert.AreEqual(dt.Month, last.Month);
|
||||
Assert.AreEqual(29, last.Day); // 2016 is a leap year
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests for <see cref="DateTimeExtensions.ToUnixTimeStamp" />.
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void ToUnixTimestamp()
|
||||
{
|
||||
var dt = new DateTime(2015, 10, 21, 1, 0, 0, DateTimeKind.Utc);
|
||||
var unix = dt.ToUnixTimeStamp();
|
||||
|
||||
Assert.AreEqual(1445389200L, unix);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
namespace X10D.Tests.Core
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
/// <summary>
|
||||
/// Tests for <see cref="DictionaryExtensions" />.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class DictionaryTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Tests for <see cref="DictionaryExtensions.ToConnectionString{T1,T2}(IDictionary{T1,T2})" />.
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void ToConnectionString()
|
||||
{
|
||||
var dictionary = new Dictionary<string, object>
|
||||
{
|
||||
{ "username", "Foo" }, { "password", "Foo Bar" }, { "port", 3306 },
|
||||
};
|
||||
|
||||
var connectionString = dictionary.ToConnectionString();
|
||||
Assert.AreEqual("username=Foo;password=\"Foo Bar\";port=3306", connectionString);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests for <see cref="DictionaryExtensions.ToGetParameters{T1,T2}(IDictionary{T1,T2})" />.
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void ToGetParameters()
|
||||
{
|
||||
var dictionary = new Dictionary<string, object>
|
||||
{
|
||||
{ "username", "Foo" }, { "password", "Foo Bar" }, { "port", 3306 },
|
||||
};
|
||||
|
||||
var getParameterString = dictionary.ToGetParameters();
|
||||
Assert.AreEqual("username=Foo&password=Foo+Bar&port=3306", getParameterString);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
namespace X10D.Tests.Core
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
/// <summary>
|
||||
/// 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" />.
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void SplitByte()
|
||||
{
|
||||
byte[] foo = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
|
||||
IEnumerable<IEnumerable<byte>> chunks = foo.Split(2).ToArray();
|
||||
|
||||
Assert.AreEqual(4, chunks.Count());
|
||||
CollectionAssert.AreEqual(new byte[] { 0x01, 0x02 }, chunks.ElementAt(0).ToList());
|
||||
CollectionAssert.AreEqual(new byte[] { 0x03, 0x04 }, chunks.ElementAt(1).ToList());
|
||||
CollectionAssert.AreEqual(new byte[] { 0x05, 0x06 }, chunks.ElementAt(2).ToList());
|
||||
CollectionAssert.AreEqual(new byte[] { 0x07, 0x08 }, chunks.ElementAt(3).ToList());
|
||||
|
||||
// test exceeding chunk size
|
||||
chunks = foo.Split(foo.Length + 10).ToArray();
|
||||
Assert.AreEqual(1, chunks.Count());
|
||||
CollectionAssert.AreEqual(foo, chunks.SelectMany(c => c).ToList());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests for <see cref="EnumerableExtensions.Split{T}" /> using an array of <see cref="int" />.
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void SplitInt32()
|
||||
{
|
||||
int[] foo = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
|
||||
IEnumerable<IEnumerable<int>> chunks = foo.Split(2).ToArray();
|
||||
|
||||
Assert.AreEqual(4, chunks.Count());
|
||||
CollectionAssert.AreEqual(new[] { 0x01, 0x02 }, chunks.ElementAt(0).ToList());
|
||||
CollectionAssert.AreEqual(new[] { 0x03, 0x04 }, chunks.ElementAt(1).ToList());
|
||||
CollectionAssert.AreEqual(new[] { 0x05, 0x06 }, chunks.ElementAt(2).ToList());
|
||||
CollectionAssert.AreEqual(new[] { 0x07, 0x08 }, chunks.ElementAt(3).ToList());
|
||||
|
||||
// test exceeding chunk size
|
||||
chunks = foo.Split(foo.Length + 10).ToArray();
|
||||
Assert.AreEqual(1, chunks.Count());
|
||||
CollectionAssert.AreEqual(foo, chunks.SelectMany(c => c).ToList());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
namespace X10D.Tests.Core
|
||||
{
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
/// <summary>
|
||||
/// Tests for <see cref="ReflectionExtensions" />.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class ReflectionTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Test for <see cref="ReflectionExtensions.GetDefaultValue{T}(System.Reflection.MemberInfo)" />.
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void GetDefaultValue()
|
||||
{
|
||||
var klass = new TestClass();
|
||||
|
||||
foreach (var property in klass.GetType().GetProperties())
|
||||
{
|
||||
Assert.AreEqual("Foo", property.GetDefaultValue<string>());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test for <see cref="ReflectionExtensions.GetDescription(System.Reflection.MemberInfo)" />.
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void GetDescription()
|
||||
{
|
||||
var klass = new TestClass();
|
||||
|
||||
foreach (var property in klass.GetType().GetProperties())
|
||||
{
|
||||
Assert.AreEqual("Test description", property.GetDescription());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test for <see cref="ReflectionExtensions.GetDescription(System.Reflection.MemberInfo)" />.
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void SelectFromCustomAttribute()
|
||||
{
|
||||
var klass = new TestClass();
|
||||
|
||||
foreach (var property in klass.GetType().GetProperties())
|
||||
{
|
||||
var value = property.SelectFromCustomAttribute<TestAttribute, string>(a => a.TestValue);
|
||||
Assert.AreEqual("Bar", value);
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
private sealed class TestAttribute : Attribute
|
||||
{
|
||||
public string TestValue { get; set; }
|
||||
}
|
||||
|
||||
private sealed class TestClass
|
||||
{
|
||||
[System.ComponentModel.Description("Test description")]
|
||||
[DefaultValue("Foo")]
|
||||
[Test(TestValue = "Bar")]
|
||||
public string TestProperty { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
namespace X10D.Tests.Core
|
||||
{
|
||||
using System;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
/// <summary>
|
||||
/// Tests for <see cref="TimeSpanParser" />.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class TimeSpanParserTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Tests for <see cref="TimeSpanParser.Parse" />.
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void TestParser()
|
||||
{
|
||||
Assert.AreEqual(TimeSpan.FromHours(3), "3h".ToTimeSpan());
|
||||
Assert.AreEqual(TimeSpan.FromMinutes(2.5), "2.5m".ToTimeSpan());
|
||||
Assert.AreEqual(TimeSpan.FromHours(1), "60m".ToTimeSpan());
|
||||
Assert.AreEqual(TimeSpan.FromDays(1), "1d".ToTimeSpan());
|
||||
Assert.AreEqual(TimeSpan.FromDays(8), "1w 1d".ToTimeSpan());
|
||||
Assert.AreEqual(TimeSpan.FromDays(8), "1w1d".ToTimeSpan());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user