diff --git a/X10D.Tests/src/Core/DateTimeTests.cs b/X10D.Tests/src/Core/DateTimeTests.cs deleted file mode 100644 index a670af9..0000000 --- a/X10D.Tests/src/Core/DateTimeTests.cs +++ /dev/null @@ -1,107 +0,0 @@ -namespace X10D.Tests.Core -{ - using System; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - /// - /// Tests for . - /// - [TestClass] - public class DateTimeTests - { - /// - /// Tests for . - /// - [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()); - } - - /// - /// Tests for . - /// - [TestMethod] - public void First() - { - var dt = new DateTime(2018, 6, 20); - - Assert.AreEqual(4, dt.First(DayOfWeek.Monday).Day); - } - - /// - /// Tests for . - /// - [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); - } - - /// - /// Tests for . - /// - [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); - } - } - - /// - /// Tests for . - /// - [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 - } - - /// - /// Tests for . - /// - [TestMethod] - public void ToUnixTimestamp() - { - var dt = new DateTime(2015, 10, 21, 1, 0, 0, DateTimeKind.Utc); - var unix = dt.ToUnixTimeStamp(); - - Assert.AreEqual(1445389200L, unix); - } - } -} diff --git a/X10D.Tests/src/Core/DictionaryTests.cs b/X10D.Tests/src/Core/DictionaryTests.cs deleted file mode 100644 index 983fc9b..0000000 --- a/X10D.Tests/src/Core/DictionaryTests.cs +++ /dev/null @@ -1,42 +0,0 @@ -namespace X10D.Tests.Core -{ - using System.Collections.Generic; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - /// - /// Tests for . - /// - [TestClass] - public class DictionaryTests - { - /// - /// Tests for . - /// - [TestMethod] - public void ToConnectionString() - { - var dictionary = new Dictionary - { - { "username", "Foo" }, { "password", "Foo Bar" }, { "port", 3306 }, - }; - - var connectionString = dictionary.ToConnectionString(); - Assert.AreEqual("username=Foo;password=\"Foo Bar\";port=3306", connectionString); - } - - /// - /// Tests for . - /// - [TestMethod] - public void ToGetParameters() - { - var dictionary = new Dictionary - { - { "username", "Foo" }, { "password", "Foo Bar" }, { "port", 3306 }, - }; - - var getParameterString = dictionary.ToGetParameters(); - Assert.AreEqual("username=Foo&password=Foo+Bar&port=3306", getParameterString); - } - } -} diff --git a/X10D.Tests/src/Core/EnumerableTests.cs b/X10D.Tests/src/Core/EnumerableTests.cs deleted file mode 100644 index 6da9ac3..0000000 --- a/X10D.Tests/src/Core/EnumerableTests.cs +++ /dev/null @@ -1,55 +0,0 @@ -namespace X10D.Tests.Core -{ - using System.Collections.Generic; - using System.Linq; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - /// - /// Tests for . - /// - [TestClass] - public class EnumerableTests - { - /// - /// Tests for using an array of . - /// - [TestMethod] - public void SplitByte() - { - byte[] foo = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 }; - IEnumerable> 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()); - } - - /// - /// Tests for using an array of . - /// - [TestMethod] - public void SplitInt32() - { - int[] foo = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 }; - IEnumerable> 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()); - } - } -} diff --git a/X10D.Tests/src/Core/ReflectionTests.cs b/X10D.Tests/src/Core/ReflectionTests.cs deleted file mode 100644 index b182a4b..0000000 --- a/X10D.Tests/src/Core/ReflectionTests.cs +++ /dev/null @@ -1,70 +0,0 @@ -namespace X10D.Tests.Core -{ - using System; - using System.ComponentModel; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - /// - /// Tests for . - /// - [TestClass] - public class ReflectionTests - { - /// - /// Test for . - /// - [TestMethod] - public void GetDefaultValue() - { - var klass = new TestClass(); - - foreach (var property in klass.GetType().GetProperties()) - { - Assert.AreEqual("Foo", property.GetDefaultValue()); - } - } - - /// - /// Test for . - /// - [TestMethod] - public void GetDescription() - { - var klass = new TestClass(); - - foreach (var property in klass.GetType().GetProperties()) - { - Assert.AreEqual("Test description", property.GetDescription()); - } - } - - /// - /// Test for . - /// - [TestMethod] - public void SelectFromCustomAttribute() - { - var klass = new TestClass(); - - foreach (var property in klass.GetType().GetProperties()) - { - var value = property.SelectFromCustomAttribute(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; } - } - } -} diff --git a/X10D.Tests/src/Core/TimeSpanParserTests.cs b/X10D.Tests/src/Core/TimeSpanParserTests.cs deleted file mode 100644 index bbbb5e7..0000000 --- a/X10D.Tests/src/Core/TimeSpanParserTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -namespace X10D.Tests.Core -{ - using System; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - /// - /// Tests for . - /// - [TestClass] - public class TimeSpanParserTests - { - /// - /// Tests for . - /// - [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()); - } - } -}