Skip to content

Commit

Permalink
Rest: ViewTests fail
Browse files Browse the repository at this point in the history
  • Loading branch information
apobekiaris committed Oct 1, 2021
1 parent 5b484b9 commit 4a33ff8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/Modules/Reactive.Rest/RestService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private static IObservable<Unit> ObjectStringLookup(this XafApplication applicat
.SelectMany(frame => frame.View.AsListView().CollectionSource is NonPersistentPropertyCollectionSource source
? source.MasterObjectType.RestListMembers().Where(t => t.attribute.PropertyName == source.MemberInfo.Name)
.SelectMany(_ => frame.GetController<NewObjectViewController>().NewObjectAction.WhenExecute()
.Merge(frame.GetController<ListViewProcessCurrentObjectController>().ProcessCurrentObjectAction.WhenExecute())
.Merge(frame.GetController<ListViewProcessCurrentObjectController>().ProcessCurrentObjectAction.WhenExecuted())
.SelectMany(e => {
var dataSourceProperty = source.MemberInfo.FindAttribute<DataSourcePropertyAttribute>().DataSourceProperty;
var datasourceMember = source.MemberInfo.Owner.FindMember(dataSourceProperty);
Expand Down
8 changes: 4 additions & 4 deletions src/Tests/Reactive.Rest/ViewTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ public class ViewTests : RestCommonAppTest {
public async Task TestListViewProcessSelectedItem() {
HandlerMock.SetupRestPropertyObject(Application.CreateObjectSpace(typeof(RestPropertyObject)),
o => o.StringArray = new[] {"a"});

await Application.TestListViewProcessSelectedItem(typeof(RestPropertyObject));
}

[Test]
public async Task Arrays_BindingList_Lookup_Datasource() {
HandlerMock.SetupRestPropertyObject(Application.CreateObjectSpace(typeof(RestPropertyObject)),
o => o.StringArray = new[] {"a"});
var detailViewFrame = await Application.TestListViewProcessSelectedItem(typeof(RestPropertyObject));
var nestedFrame = detailViewFrame.View.AsDetailView()
.GetListPropertyEditor<RestPropertyObject>(o => o.StringArrayList).Frame;
var detailView = await Application.TestListViewProcessSelectedItem(typeof(RestPropertyObject));
var nestedFrame = detailView.GetListPropertyEditor<RestPropertyObject>(o => o.StringArrayList).Frame;
var whenDetailViewCreated =
Application.WhenDetailViewCreated(typeof(ObjectString)).FirstAsync().SubscribeReplay();
var newObjectAction = nestedFrame.GetController<NewObjectViewController>().NewObjectAction;
Expand All @@ -40,7 +40,7 @@ public async Task Arrays_BindingList_Lookup_Datasource() {
var t = await whenDetailViewCreated;

var currentObject = ((ObjectString) t.e.View.CurrentObject);
var restPropertyObject = ((RestPropertyObject) detailViewFrame.View.CurrentObject);
var restPropertyObject = ((RestPropertyObject) detailView.CurrentObject);
currentObject.DataSource.Count.ShouldBe(restPropertyObject.StringArraySource.Count);
currentObject.DataSource.Select(s => s.Name).First()
.ShouldBe(restPropertyObject.StringArraySource.Select(s => s.Name).First());
Expand Down
12 changes: 4 additions & 8 deletions src/Tests/TestsLib.Common/CommonTestScenario.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.SystemModule;
using Fasterflect;
using Shouldly;
using Xpand.Extensions.Reactive.Transform;
using Xpand.Extensions.Reactive.Utility;
using Xpand.Extensions.XAF.CollectionSourceExtensions;
Expand All @@ -15,21 +14,18 @@

namespace Xpand.TestsLib.Common {
public static class CommonTestScenario {
public static async Task<Frame> TestListViewProcessSelectedItem(this XafApplication application,Type objectType) {
public static async Task<DetailView> TestListViewProcessSelectedItem(this XafApplication application,Type objectType) {
var window = await TestListView(application, objectType);
var action = window.GetController<ListViewProcessCurrentObjectController>().ProcessCurrentObjectAction;
var frameViewChanged = application.WhenFrameViewChanged().Select(frame1 => frame1)
.WhenFrame(ViewType.DetailView).FirstAsync().SubscribeReplay();
var frameViewChanged = application.WhenViewCreated().OfType<DetailView>()
.FirstAsync().SubscribeReplay();

action.DoExecute(objectSpace => {
var objects = window.View.AsListView().CollectionSource.Objects().Take(1).ToArray();
return objects.Select(objectSpace.GetObject).ToArray();
},true);

var frame = await frameViewChanged;

frame.View.ShouldBeOfType<DetailView>();
return frame;
return await frameViewChanged.ToTaskWithoutConfigureAwait();
}

public static async Task<Window> TestListView(this XafApplication application, Type objectType) {
Expand Down

0 comments on commit 4a33ff8

Please sign in to comment.