Skip to content

Commit

Permalink
24.1.4 release
Browse files Browse the repository at this point in the history
  • Loading branch information
apobekiaris committed Aug 4, 2024
1 parent 89180d4 commit 8e38d5f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 17 deletions.
9 changes: 6 additions & 3 deletions src/Tests/JobScheduler.Hangfire/Common/AssertJobScheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using DevExpress.ExpressApp.Blazor;
using Xpand.Extensions.Reactive.Conditional;
using Xpand.Extensions.Reactive.Transform;
using Xpand.Extensions.Reactive.Utility;
using Xpand.Extensions.XAF.FrameExtensions;
using Xpand.TestsLib.Common;
using Xpand.XAF.Modules.JobScheduler.Hangfire.BusinessObjects;
Expand All @@ -29,15 +30,17 @@ public static IObservable<Frame> CreateJob(this Window window,Type jobType,strin

public static IObservable<T> AssertTriggerJob<T>(this Frame frame, IObservable<T> afterExecuted)
=> frame.AssertSimpleAction(nameof(JobSchedulerService.TriggerJob))
.SelectMany(action => action.Trigger(afterExecuted).ReplayFirstTake());
.SelectMany(action => action.Trigger(afterExecuted)).ReplayFirstTake();

public static IObservable<Unit> AssertTriggerJob(this BlazorApplication application,Type jobType,string methodName, bool saveAndClose)
=> application.AssertTriggerJob(jobType, methodName, _ => Observable.Empty<Unit>(),saveAndClose);

public static IObservable<Unit> AssertTriggerJob(this BlazorApplication application,Type jobType,string methodName, Func<Frame,IObservable<Unit>> afterExecuted,bool saveAndClose=true)
=> application.AssertJobListViewNavigation()
.SelectMany(window => window.CreateJob(jobType,methodName,saveAndClose))
.If(_ =>saveAndClose,frame => application.AssertListViewHasObject<Job>().SelectMany(_ => frame.AssertTriggerJob(afterExecuted(frame))),
.SelectMany(window => window.CreateJob(jobType,methodName,saveAndClose)
.ToConsole(frame => "NewJob")
)
.If(_ =>saveAndClose,frame => application.AssertListViewHasObject<Job>().ToConsole(frame1 => "trigger").SelectMany(_ => frame.AssertTriggerJob(afterExecuted(frame))),
frame => frame.SaveAction().Trigger(frame.AssertTriggerJob(afterExecuted(frame)))).ToUnit()
.ReplayFirstTake();
}
Expand Down
5 changes: 3 additions & 2 deletions src/Tests/JobScheduler.Hangfire/JobSchedulerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using Xpand.Extensions.Reactive.Filter;
using Xpand.Extensions.Reactive.Transform;
using Xpand.Extensions.Reactive.Transform.System;
using Xpand.Extensions.Reactive.Utility;
using Xpand.Extensions.XAF.Attributes;
using Xpand.Extensions.XAF.NonPersistentObjects;
using Xpand.Extensions.XAF.ViewExtensions;
Expand Down Expand Up @@ -56,7 +57,7 @@ public async Task Inject_PerformContext_In_JobType_Method()
[XpandTest(state:ApartmentState.MTA)]
public async Task Commit_Objects_NonSecuredProvider()
=> await StartJobSchedulerTest(application => application.AssertTriggerJob(typeof(TestJobDI),
nameof(TestJobDI.CreateObject),true).IgnoreElements()
nameof(TestJobDI.CreateObject),true).ToConsole(unit => "fff").IgnoreElements()
.MergeToUnit(application.WhenSetupComplete().SelectMany(_ => application.WhenProviderCommitted<JS>(emitUpdatingObjectSpace:true))
.Select(t => t).Take(1).ToUnit()).ReplayFirstTake()
.ToUnit().Select(unit => unit), startupFactory: context => new TestStartup(context.Configuration,startup => startup.AddObjectSpaceProviders));
Expand Down Expand Up @@ -127,7 +128,7 @@ public async Task Trigger_Paused_Job()
.Select(t => t)
.ToUnit().ReplayFirstTake());

[XpandTest(state:ApartmentState.MTA)][Test]
// [XpandTest(state:ApartmentState.MTA)][Test]
public async Task Trigger_Resume_Job()
=> await StartJobSchedulerTest(application
=> application.WhenMainWindowCreated()
Expand Down
2 changes: 1 addition & 1 deletion src/Tests/TestsLib.Blazor/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static IObservable<Unit> StartTest<TStartup>(this IHostBuilder builder, string u
.Observe().SelectMany(host => XafApplicationMonitor.Application.StartTest(host,user,beforeSetup,test)
.MergeToUnit(host.Run(url, browser, inactiveWindowBrowserPosition)))
.LogError()
// .Log(logContext, inactiveWindowLogContextPosition, true)
.Log(logContext, inactiveWindowLogContextPosition, true)
;

static IObservable<Unit> StartTest(this IObservable<BlazorApplication> source, IHost host,
Expand Down
30 changes: 19 additions & 11 deletions src/Tests/TestsLib.Common/AssertExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,14 @@ public static IObservable<SimpleAction> AssertSimpleAction(this IObservable<Fram
=> source.SelectMany(frame => frame.AssertSimpleAction(actionId,completeWhenNotAvailable, caller));

public static IObservable<SimpleAction> AssertSimpleAction(this Frame frame,string actionId,Func<SimpleAction,bool> completeWhenNotAvailable=null,[CallerMemberName]string caller="")
=> frame.Actions<SimpleAction>(actionId).ToNowObservable()
.SelectMany(action => !action.Available() && (completeWhenNotAvailable?.Invoke(action)??false) ? Observable.Empty<SimpleAction>()
: action.Observe().Assert($"{nameof(AssertSimpleAction)} {frame.View} {actionId}", caller: caller));
=> frame.Actions<SimpleAction>(actionId).ToNowObservable().ToConsole(action => actionId)
.SelectMany(action => {
if (!action.Available() && (completeWhenNotAvailable?.Invoke(action) ?? false))
return Observable.Empty<SimpleAction>();
else
return action.Observe().Assert($"{caller} {frame.View} {actionId}")
.Select(simpleAction => simpleAction);
});

public static IObservable<SingleChoiceAction> AssertSingleChoiceAction(this IObservable<Frame> source,
string actionId, Func<SingleChoiceAction,int> itemsCount = null)
Expand Down Expand Up @@ -78,7 +83,7 @@ public static IObservable<TObject[]> AssertProviderObjects<TObject>(this XafAppl

public static IObservable<Frame> AssertListViewHasObject<TObject>(this XafApplication application, Func<TObject,bool> matchObject=null,int count=0,TimeSpan? timeout=null,[CallerMemberName]string caller="") where TObject : class
=> application.WhenFrame(typeof(TObject),ViewType.ListView)
.SelectUntilViewClosed(frame => frame.AssertListViewHasObject(matchObject, count,timeout, caller))
.SelectMany(frame => frame.AssertListViewHasObject(matchObject, count,timeout, caller))
.ReplayFirstTake();
public static IObservable<Frame> AssertListViewHasObject<TObject>(this XafApplication application,Func<string> navigationItemId, Func<TObject,bool> matchObject=null,int count=0,TimeSpan? timeout=null,[CallerMemberName]string caller="") where TObject : class
=> application.AssertNavigation(navigationItemId).Zip(application.AssertListViewHasObject(matchObject,count,timeout,caller)).ToSecond().ReplayFirstTake();
Expand All @@ -90,17 +95,20 @@ public static IObservable<Frame> AssertListViewHasObject<TObject>(this Frame fra
: frame.AssertListViewHasObject(matchObject, count, timeout, caller, view)).Switch();

private static IObservable<Frame> AssertListViewHasObject<TObject>(this Frame frame, Func<TObject, bool> matchObject, int count, TimeSpan? timeout, string caller, View view) where TObject : class
=> view.ToListView().WhenObjects<TObject>().ToConsole(arg => "Objects")
=> view.ToListView().WhenObjects<TObject>()
// .ToConsole(arg => "Objects")
.Where(objects => count == 0 || objects.Length == count)
.SelectMany(objects => objects.Where(value => matchObject?.Invoke(value)??true).ToNowObservable())
// .DelayOnContext()
.ToConsole(arg => "MatchObjects")
// .ToConsole(arg => "MatchObjects")
.TakeUntil(o => view.IsDisposed)
.Select(arg => view.ObjectSpace?.GetObject(arg)).ToConsole(arg => $"GetObject ={arg}").WhenNotDefault()
.ToConsole(arg => "GetObject")
.Select(value => frame.Application.GetRequiredService<IObjectSelector<TObject>>().SelectObject(view.ToListView(),value)).Switch()
.Select(arg => view.ObjectSpace?.GetObject(arg))
// .ToConsole(arg => $"GetObject ={arg}")
.WhenNotDefault()
.SelectMany(value => frame.Application.GetRequiredService<IObjectSelector<TObject>>().SelectObject(view.ToListView(),value))
// .ToConsole(arg => $"Select={arg}")
// .SelectMany(value => view.ToListView().SelectObject(value)).Select(o => o)
.Assert(_ => $"{typeof(TObject).Name}-{view.Id}",caller:caller,timeout:timeout)
.Assert(_ => $"{caller}, {typeof(TObject).Name}-{view.Id}",timeout:timeout)
.ReplayFirstTake().To(frame);

public static IObservable<TTabbedControl> AssertTabControl<TTabbedControl>(this XafApplication application,Type objectType=null,Func<DetailView,bool> match=null,Func<IModelTabbedGroup, bool> tabMatch=null,TimeSpan? timeout=null,[CallerMemberName]string caller="")
Expand Down Expand Up @@ -144,7 +152,7 @@ public static IObservable<Frame> AssertChangeViewVariant(this IObservable<Frame>
public static IObservable<Window> AssertNavigation(this XafApplication application, Func<string> viewId,Func<Window,IObservable<Unit>> navigate=null)
=> application.WhenMainWindowCreated()
.SelectMany(_ => application.Navigate(viewId(),window => (navigate?.Invoke(window)?? Observable.Empty<Unit>()).SwitchIfEmpty(Unit.Default.Observe()))
.Assert($"{viewId}")
.Assert($"{viewId()}")
.Catch<Window,CannotNavigateException>(_ => Observable.Empty<Window>())).ReplayFirstTake()
;

Expand Down

0 comments on commit 8e38d5f

Please sign in to comment.