public async Task Can_be_cancelled()
        {
            this.InitializeClientWithCollection(TestAccounts.GalacticEmpire);
            var cts          = new CancellationTokenSource();
            var reachedIndex = -1;

            try
            {
                await this.Queryable.ForEachAsync(
                    acct =>
                {
                    reachedIndex++;

                    if (reachedIndex == 2)
                    {
                        cts.Cancel();
                    }
                }, cts.Token);

                Assertly.Fail("Should not reach here!");
            }
            catch (OperationCanceledException)
            {
                reachedIndex.ShouldBe(2);
            }
        }
Ejemplo n.º 2
0
        private static string GetGeneratedHref <T>(IQueryable <T> queryable)
        {
            var resourceQueryable = queryable as CollectionResourceQueryable <T>;

            if (resourceQueryable == null)
            {
                Assertly.Fail("This queryable is not a CollectionResourceQueryable.");
            }

            return(resourceQueryable.CurrentHref);
        }
Ejemplo n.º 3
0
        public void Equal_numbers_of_Csharp_and_Vb_tests(string @namespace)
        {
            var csharpTests = typeof(Tests.Integration.IntegrationTestCollection).Assembly
                              .GetTypes()
                              .Where(x => x.Namespace == $"Stormpath.SDK.Tests.Integration.{@namespace}")
                              .SelectMany(x => x.GetMethods())
                              .Where(m => m.GetCustomAttributes().OfType <TheoryAttribute>().Any() || m.GetCustomAttributes().OfType <FactAttribute>().Any())
                              .Select(x => Helpers.GetQualifiedMethodName(x));

            var vbAssembly = Helpers.GetVisualBasicIntegrationTestAssembly();

            if (vbAssembly == null)
            {
                if (Debugger.IsAttached)
                {
                    Assertly.Fail("Could not locate VB IT assembly.");
                }

                return;
            }

            var vbTests = vbAssembly
                          .GetTypes()
                          .Where(x => x.Namespace == $"Stormpath.SDK.Tests.Integration.VB.{@namespace}")
                          .SelectMany(x => x.GetMethods())
                          .Where(m => m.GetCustomAttributes().OfType <TheoryAttribute>().Any() || m.GetCustomAttributes().OfType <FactAttribute>().Any())
                          .Select(x => Helpers.GetQualifiedMethodName(x));

            var csharpButNotVb = csharpTests
                                 .Except(vbTests)
                                 .ToList();

            var vbButNotCsharp = vbTests
                                 .Except(csharpTests)
                                 .ToList();

            csharpButNotVb.Count.ShouldBe(
                0,
                $"These {@namespace} C# tests do not have a corresponding VB test:{Helpers.NL}{string.Join(", ", csharpButNotVb)}");

            vbButNotCsharp.Count.ShouldBe(
                0,
                $"These {@namespace} VB tests do not have a corresponding C# test:{Helpers.NL}{string.Join(", ", vbButNotCsharp)}");
        }