Ejemplo n.º 1
0
 public void ListFromTask()
 {
     using (var sut = ChangeSetCreation.FromTask().AsObservableList())
     {
         sut.Items.Should().BeEquivalentTo(Enumerable.Range(1, 10));
     }
 }
Ejemplo n.º 2
0
        public void WithRetry()
        {
            int loadCount   = 0;
            int failedCount = 0;

            Task <IEnumerable <int> > Loader()
            {
                loadCount++;

                if (loadCount < 3)
                {
                    failedCount++;
                    throw new Exception("Failed");
                }
                return(Task.FromResult(Enumerable.Range(1, 10)));
            }

            using (var sut = ChangeSetCreation.FromTask(Loader)
                             .Retry(3) //in an enterprise app, would probably use a backoff retry strategy
                             .AsObservableList())
            {
                sut.Items.Should().BeEquivalentTo(Enumerable.Range(1, 10));
                loadCount.Should().Be(3);
                failedCount.Should().Be(2);
            }
        }