using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Utils; using Xunit; namespace Tests.Utils_UTs { public class EnumerablesTest { [Fact] public void TestFeedListsToDict() { // Arrange string str1 = "blah"; string str2 = "blahblah"; string str3 = "azfyoaz"; int int1 = 5; int int2 = 12; int int3 = 3; Dictionary expected = new() { { str1, int1 }, { str2, int2 }, { str3, int3 } }; List strings = new() { str2, str3 }; List ints = new() { int2, int3 }; Dictionary actual = new() { {str1, int1 } }; // we will add on top of this // Act actual = Enumerables.FeedListsToDict(actual, strings, ints); // Assert Assert.Equal(expected, actual); } [Fact] public void TestGetDictFromLists() { // Arrange string str1 = "blah"; string str2 = "blahblah"; int int1 = 5; int int2 = 12; Dictionary expected = new() { { str1, int1 }, { str2, int2 } }; List strings = new() { str1, str2 }; List ints = new() { int1, int2 }; // Act Dictionary actual = Enumerables.GetDictFromLists(strings, ints); // Assert Assert.Equal(expected, actual); } public static IEnumerable EmptyList() { yield return new object[] { new List() }; } [Theory] [InlineData(null)] [MemberData(nameof(EmptyList))] public void TestGetDictFromListsWhenKeysNullOrEmptyThenNew(List strings) { // Arrange int int1 = 5; int int2 = 12; Dictionary expected = new(); List ints = new() { int1, int2 }; // Act Dictionary actual = Enumerables.GetDictFromLists(strings, ints); // Assert Assert.Equal(expected, actual); } [Theory] [InlineData(null)] [MemberData(nameof(EmptyList))] public void TestGetDictFromListsWhenValuesNullOrEmptyThenNew(List stringsB) { // Arrange string str1 = "blah"; string str2 = "blahblah"; Dictionary expected = new(); List strings = new() { str1, str2 }; // Act Dictionary actual = Enumerables.GetDictFromLists(strings, stringsB); // Assert Assert.Equal(expected, actual); } } }