Exemplo n.º 1
0
        public void Equivalent_BothEmpty()
        {
            var expected = new List <string>();
            var actual   = new List <string>();

            EnumerableAssert.AreEquivalent(expected, actual);
        }
        public void StartNew_Multiple()
        {
            const int threadCount = 32;

            var nums    = new ConcurrentBag <int>();
            var threads = new Thread[threadCount];

            for (int i = 0; i < threadCount; i++)
            {
                threads[i] = ThreadFactory.StartNew(i, nums.Add);
            }
            for (int i = 0; i < threadCount; i++)
            {
                threads[i].Join();
            }

            EnumerableAssert.AreEquivalent(Enumerable.Range(0, threadCount), nums);

            nums = new ConcurrentBag <int>();

            Enumerable.Range(0, threadCount)
            .Select(i => ThreadFactory.StartNew(() => nums.Add(i)))
            .ToList()
            .ForEach(thread => thread.Join());

            EnumerableAssert.AreEquivalent(Enumerable.Range(0, threadCount), nums);
        }
        public void Equivalent_BothEmpty()
        {
            var expected = new List <string>();
            var actual   = new List <string>();

            EnumerableAssert.AreEquivalent(expected, actual, (e, a) => throw new Exception("Shouldn't get this"));
        }
Exemplo n.º 4
0
        public void Equivalent_SameReference()
        {
            var enumerable = new List <string> {
                "test"
            };

            EnumerableAssert.AreEquivalent(enumerable, enumerable);
        }
Exemplo n.º 5
0
        public void SecondIsNull()
        {
            var ex = Assert.ThrowsException <AssertFailedException>(() => EnumerableAssert.AreEquivalent(new List <string> {
                "test"
            }, null));

            Assert.AreEqual("EnumerableAssert.AreEquivalent failed. Actual enumerable is null.", ex.Message);
        }
Exemplo n.º 6
0
        public void FirstIsNull()
        {
            var ex = Assert.ThrowsException <AssertFailedException>(() => EnumerableAssert.AreEquivalent(null, new List <string> {
                "test"
            }));

            Assert.AreEqual("EnumerableAssert.AreEquivalent failed. Expected enumerable is null.", ex.Message);
        }
        public void Equivalent_SameReference()
        {
            var enumerable = new List <string> {
                "test"
            };

            EnumerableAssert.AreEquivalent(enumerable, enumerable, (e, a) => throw new Exception("Shouldn't get this"));
        }
        public void PredicateNull()
        {
            var ex = Assert.ThrowsException <ArgumentNullException>(() => EnumerableAssert.AreEquivalent(new List <string> {
                "test"
            }, new List <string> {
                "test"
            }, null as Func <string, string, bool>));

            Assert.AreEqual($"Value cannot be null.{Environment.NewLine}Parameter name: predicate", ex.Message);
        }
Exemplo n.º 9
0
        public void Equivalent_DifferentOrder()
        {
            var expected = new List <TestType>
            {
                new TestType(0, "0"),
                new TestType(1, "1")
            };
            var actual = new List <TestType>
            {
                expected[1],
                expected[0]
            };

            EnumerableAssert.AreEquivalent(expected, actual);
        }
        public void Equivalent_DifferentOrder()
        {
            var expected = new List <TestType>
            {
                new TestType(0, "0"),
                new TestType(1, "1")
            };
            var actual = new List <TestType>
            {
                new TestType(1, "not1"),
                new TestType(0, "0")
            };

            EnumerableAssert.AreEquivalent(expected, actual, (e, a) => e.Id == a.Id);
        }
Exemplo n.º 11
0
        public void NotEquivalent_OneElementDifference()
        {
            var expected = new List <TestType>
            {
                new TestType(0, "0"),
                new TestType(1, "1")
            };
            var actual = new List <TestType>
            {
                new TestType(2, "not1"),
                new TestType(0, "0")
            };
            var ex = Assert.ThrowsException <AssertFailedException>(() => EnumerableAssert.AreEquivalent(expected, actual));

            Assert.AreEqual("EnumerableAssert.AreEquivalent failed. Expected and actual enumerables do not match.", ex.Message);
        }
Exemplo n.º 12
0
        public void TestTcpMultiPartyNetworkSession()
        {
            Task <TcpMultiPartyNetworkSession> firstSessionTask  = CreateMultiPartySessionAsync(FirstParty, 3);
            Task <TcpMultiPartyNetworkSession> secondSessionTask = CreateMultiPartySessionAsync(SecondParty, 3);
            Task <TcpMultiPartyNetworkSession> thirdSessionTask  = CreateMultiPartySessionAsync(ThirdParty, 3);

            using TcpMultiPartyNetworkSession firstSession  = firstSessionTask.Result;
            using TcpMultiPartyNetworkSession secondSession = secondSessionTask.Result;
            using TcpMultiPartyNetworkSession thirdSession  = thirdSessionTask.Result;

            Assert.AreEqual(FirstParty, firstSession.LocalParty);
            Assert.AreEqual(SecondParty, secondSession.LocalParty);
            Assert.AreEqual(ThirdParty, thirdSession.LocalParty);

            EnumerableAssert.AreEquivalent(new[] { SecondParty, ThirdParty }, GetRemoteParties(firstSession));
            EnumerableAssert.AreEquivalent(new[] { FirstParty, ThirdParty }, GetRemoteParties(secondSession));
            EnumerableAssert.AreEquivalent(new[] { FirstParty, SecondParty }, GetRemoteParties(thirdSession));
        }
Exemplo n.º 13
0
 public void FirstAndSecondNull()
 {
     EnumerableAssert.AreEquivalent <string>(null, null);
 }
 public void FirstAndSecondNull()
 {
     EnumerableAssert.AreEquivalent <string>(null, null, (e, a) => e.IndexOf("t") == a.IndexOf("t"));
 }