diff --git a/Test.GBase/Helpers/EnumerablesTest.cs b/Test.GBase/Helpers/EnumerablesTest.cs new file mode 100644 index 0000000..e8dfdec --- /dev/null +++ b/Test.GBase/Helpers/EnumerablesTest.cs @@ -0,0 +1,137 @@ +// Author: Gockner, Simon +// Created: 2020-02-14 +// Copyright(c) 2020 SimonG. All Rights Reserved. + +using System.Collections.Generic; +using GBase.Exceptions; +using GBase.Helpers; +using NUnit.Framework; +using Test.GBase.TestClasses; + +namespace Test.GBase.Helpers +{ + [TestFixture] + public class EnumerablesTest + { + [Test] + public void TestToGBaseStringStringList() + { + List list = new List() + { + "SomeString", + "AnotherString", + "ThirdString" + }; + + string expectedString = $"{list[0]},{list[1]},{list[2]}"; + + Assert.AreEqual(expectedString, list.ToGBaseString()); + } + + [Test] + public void TestToGBaseStringIntList() + { + List list = new List() + { + 1, + 2, + 3 + }; + + string expectedString = $"{list[0]},{list[1]},{list[2]}"; + + Assert.AreEqual(expectedString, list.ToGBaseString()); + } + + [Test] + public void TestToGBaseUserTypeList() + { + List list = new List() + { + new UserType(1), + new UserType(2), + new UserType(3) + }; + + string expectedString = $"{list[0]},{list[1]},{list[2]}"; + + Assert.AreEqual(expectedString, list.ToGBaseString()); + } + + [Test] + public void TestToGBaseUserTypeInterfaceList() + { + List list = new List() + { + new UserType(1), + new UserType(2), + new UserType(3) + }; + + string expectedString = $"{list[0]},{list[1]},{list[2]}"; + + Assert.AreEqual(expectedString, list.ToGBaseString()); + } + + [Test] + public void TestConvertToGBaseEnumerableStringList() + { + List list = new List() + { + "SomeString", + "AnotherString", + "ThirdString" + }; + + string @string = $"{list[0]},{list[1]},{list[2]}"; + + Assert.AreEqual(list, Enumerables.ConvertToGBaseEnumerable>(@string)); + } + + [Test] + public void TestConvertToGBaseEnumerableIntList() + { + List list = new List() + { + 1, + 2, + 3 + }; + + string @string = $"{list[0]},{list[1]},{list[2]}"; + + Assert.AreEqual(list, Enumerables.ConvertToGBaseEnumerable>(@string)); + } + + [Test] + public void TestConvertToGBaseEnumerableUserTypeList() + { + List list = new List() + { + new UserType(1), + new UserType(2), + new UserType(3) + }; + + string @string = $"{list[0]},{list[1]},{list[2]}"; + + Assert.AreEqual(list, Enumerables.ConvertToGBaseEnumerable>(@string)); + } + + [Test] + public void TestConvertToGBaseEnumerableUserTypeInterfaceList() + { + List list = new List() + { + new UserType(1), + new UserType(2), + new UserType(3) + }; + + string @string = $"{list[0]},{list[1]},{list[2]}"; + + InterfaceEnumerablePassedException exception = Assert.Throws(() => Enumerables.ConvertToGBaseEnumerable>(@string)); + Assert.AreEqual(typeof(IUserType), exception.InterfaceType); + } + } +} \ No newline at end of file