public static ITestFixture StopServer(this ITestFixture fixture) { MiruTest.Log.Debug("Stopping App's Server"); fixture.Get <IHost>().StopAsync().GetAwaiter().GetResult(); fixture.Get <IHost>().Dispose(); MiruTest.Log.Debug("App's Server stopped"); return(fixture); }
public static ITestFixture StartServer2(this ITestFixture fixture) { var host2 = fixture.Get <IHost>(); try { host2.Start(); } catch (Exception exception) { throw new MiruTestConfigException( "Could not start host for the App. Check the Inner Exception and your Program.cs/Startup.cs configurations", exception.InnerException ?? exception); } // var server = fixture.Get<IServer>(); // // var addresses = server.Features.Get<IServerAddressesFeature>().Addresses; // // if (addresses.Count == 0) // throw new MiruTestConfigException( // "The App's Server has no http addresses associated to it. Maybe the App is already running in another process?"); return(fixture); }
public static int EnqueuedCount(this ITestFixture fixture) { return(fixture.Get <JobStorage>() .GetMonitoringApi() .EnqueuedJobs("default", 0, 1000) .Count); }
public static bool EnqueuedOneJobFor <TJob>(this ITestFixture fixture) where TJob : IJob { return(fixture.Get <JobStorage>() .As <MemoryStorage>() .Data .GetEnumeration <JobDto>() .Count(job => job.InvocationData.Contains(typeof(TJob).FullName !)) == 1); }
public static int EnqueuedCount(this ITestFixture fixture) { return(fixture.Get <JobStorage>() .As <MemoryStorage>() .Data .GetEnumeration <JobDto>() .Count()); }
public static IEnumerable <TJob> EnqueuedJobs <TJob>(this ITestFixture fixture) where TJob : IMiruJob => fixture.Get <JobStorage>() .GetMonitoringApi() .EnqueuedJobs("default", 0, 1000) .Select(result => result.Value) .Where(enqueueJob => enqueueJob.Job.Args[0].GetType() == typeof(TJob)) .Select(enqueueJob => (TJob)enqueueJob.Job.Args[0]) .ToList();
public static ITestFixture ClearFabricator(this ITestFixture fixture) { MiruTest.Log.Information($"Running _.{nameof(ClearFabricator)}()"); fixture.Get <Fabricator>().Clear(); return(fixture); }
public static ITestFixture MigrateDatabase(this ITestFixture fixture) { MiruTest.Log.Information($"Running _.{nameof(MigrateDatabase)}()"); fixture.Get <IDatabaseMigrator>().UpdateSchema(); return(fixture); }
public static bool EnqueuedOneJobFor <TJob>(this ITestFixture fixture) where TJob : IMiruJob { return(fixture.Get <JobStorage>() .GetMonitoringApi() .EnqueuedJobs("default", 0, 1000) .Select(result => result.Value) .Count(enqueueJob => enqueueJob.Job.Args[0].GetType() == typeof(TJob)) == 1); }
public HtmlGeneratorTest() { _ = new ServiceCollection() .AddMiruHtml() .AddMiruTestFixture() .BuildServiceProvider() .GetRequiredService <ITestFixture>(); _htmlGenerator = _.Get <HtmlGenerator>(); }
public static T Make <T>(this ITestFixture fixture, params Action <T>[] customizations) where T : class { var made = fixture.Get <Fabricator>().Make <T>(); foreach (var customization in customizations) { customization(made); } return(made); }
public static ITestFixture ClearQueue(this ITestFixture fixture) { MiruTest.Log.Information($"Running _.{nameof(ClearQueue)}()"); var storage = fixture.Get <JobStorage>().As <MemoryStorage>(); var jobs = storage.Data.GetEnumeration <JobDto>(); storage.Data.Delete(jobs); return(fixture); }
public static IEnumerable <T> MakeManySaving <T>(this ITestFixture fixture, int howMany = 3, Action <T> customizations = null) where T : class { MiruTest.Log.Information($"Making and saving {howMany} {typeof(T).FullName}"); var entities = fixture.Get <Fabricator>().MakeMany(howMany, customizations); MiruTest.Log.Debug(() => $"Made:{Environment.NewLine}{entities.Inspect()}"); MiruTest.Log.Debug(() => $"Saving the {howMany} entities"); fixture.Save(entities); return(entities); }
public static string EnqueuedRawJob <TJob>(this ITestFixture fixture) where TJob : IJob { var job = fixture.Get <JobStorage>().As <MemoryStorage>() .Data .GetEnumeration <JobDto>() .FirstOrDefault(job => job.InvocationData.Contains(typeof(TJob).FullName !)); if (job == null) { throw new ShouldAssertException($"No job queued found of type {typeof(TJob).FullName}"); } return(job.InvocationData); }
public static bool ScheduledOneTaskFor <TTask>(this ITestFixture fixture) where TTask : ScheduledTask { var scheduler = fixture.Get <Quartz.IScheduler>(); var triggerKeys = scheduler.GetTriggerKeys(GroupMatcher <TriggerKey> .AnyGroup()); // triggerKeys.Result.Where(r => scheduler.GetTrigger(r)) foreach (var triggerKey in triggerKeys.Result) { var triggerdetails = scheduler.GetTrigger(triggerKey); var Jobdetails = scheduler.GetJobDetail(triggerdetails.Result.JobKey); } //Pegar o Jobdetails e filtar por tipo == typeof(TTask) return(true); }
public static TJob EnqueuedJob <TJob>(this ITestFixture fixture) where TJob : IMiruJob { var entry = fixture.Get <JobStorage>() .GetMonitoringApi() .EnqueuedJobs("default", 0, 1000) .Select(result => result.Value) .FirstOrDefault(enqueueJob => enqueueJob.Job.Args[0].GetType() == typeof(TJob)); if (entry == null) { throw new ShouldAssertException($"No job queued found of type {typeof(TJob).FullName}"); } return((TJob)entry.Job.Args[0]); }
public static IEnumerable <string> EnqueuedRawJobs <TJob>(this ITestFixture fixture) where TJob : IJob { var jobs = fixture.Get <JobStorage>().As <MemoryStorage>() .Data .GetEnumeration <JobDto>() .Where(job => job.InvocationData.Contains(typeof(TJob).FullName !)) .Select(job => job.InvocationData) .ToList(); if (jobs.Count == 0) { throw new ShouldAssertException($"No job queued found of type {typeof(TJob).FullName}"); } return(jobs); }
public static IEnumerable <TJob> EnqueuedJobs <TJob>(this ITestFixture fixture) where TJob : IMiruJob { var entry = fixture.Get <JobStorage>() .GetMonitoringApi() .EnqueuedJobs("default", 0, 1000) .Select(result => result.Value) .Where(enqueueJob => enqueueJob.Job.Args[0].GetType() == typeof(TJob)) .Select(enqueueJob => (TJob)enqueueJob.Job.Args[0]) .ToList(); if (entry.Count == 0) { throw new ShouldAssertException($"No job queued found of type {typeof(TJob).FullName}"); } return(entry); }
public static async Task <TUser> MakeUserAsync <TUser>( this ITestFixture fixture, string password = "******", Action <TUser> customizations = null) where TUser : UserfyUser { using var scope = fixture.Get <IMiruApp>().WithScope(); var userManager = scope.Get <UserManager <TUser> >(); var user = scope.Get <Fabricator>().Make(customizations); user.UserName = user.Email; await userManager.CreateAsync(user, password); return(user); }
public static SelfImprovFabricator Fab(this ITestFixture fixture) { return(fixture.Get <SelfImprovFabricator>()); }
public static void Logout(this ITestFixture fixture) { MiruTest.Log.Information("Logging out the current user"); fixture.Get <IUserSession>().Logout(); }
public static MongFabricator Fab(this ITestFixture fixture) { return(fixture.Get <MongFabricator>()); }
public static TUser CurrentUser <TUser>(this ITestFixture fixture) where TUser : IUser { return(fixture.Get <IUserSession <TUser> >().User().GetAwaiter().GetResult()); }
public static EmailSent LastEmailSent(this ITestFixture fixture) { return(fixture.Get <MemorySender>().Last()); }
public static long CurrentUserId(this ITestFixture fixture) { return(fixture.Get <IUserSession>().CurrentUserId); }
public static IEnumerable <T> MakeMany <T>(this ITestFixture fixture, Action <T> customizations) where T : class { return(fixture.Get <Fabricator>().MakeMany(3, customizations)); }
public static T Make <T>(this ITestFixture fixture, Action <T> customizations = null) where T : class { return(fixture.Get <Fabricator>().Make(customizations)); }
public static Faker Faker(this ITestFixture fixture) { return(fixture.Get <Faker>()); }
public static SkeletonFabricator Fab(this ITestFixture fixture) { return(fixture.Get <SkeletonFabricator>()); }
public static IEnumerable <EmailSent> AllEmailsSent(this ITestFixture fixture) { return(fixture.Get <MemorySender>().All()); }