vlingo-net / xoom-net-common

These are just a few common tools shared across various vlingo .NET projects.
Mozilla Public License 2.0
7 stars 9 forks source link

Repeat on RepeatableCompletes doesn't execute at all time #54

Open tjaskula opened 4 years ago

tjaskula commented 4 years ago

This can be easily demonstrated by the following UT:

[Fact]
        public void TestOnClientAndServerSetupWhenClientIsFaster()
        {
            var ints = new List<int>();
            var completeInteger = NewEmptyCompletes<int>().AndThen(i =>
            {
                ints.Add(i);
                return i;
            }).Repeat();
            var expected = Enumerable.Range(0, 1000).ToList();

            var server = new Thread(() => expected.ForEach(i => completeInteger.With(i)));

            server.Start();
            server.Join();

            var intHashSet = new HashSet<int>(ints);
            var expectedHashSet = new HashSet<int>(expected);

            expectedHashSet.RemoveWhere(h => intHashSet.Contains(h));
            Assert.Empty(expectedHashSet);
        }

Here Repeat() is only executed one time where it should be executed every time an output is set.