public void TestActionNoParmsWithSelected() { TestDomainObject target = NakedObjectsFramework.Persistor.Instances <TestDomainObject>().Single(i => i.Id == 1); INakedObjectAdapter targetNo = NakedObjectsFramework.NakedObjectManager.CreateAdapter(target, null, null); IActionSpec actionSpec = targetNo.Spec.GetActions().Single(a => a.Id == "Action1"); var memento = new CollectionMemento(NakedObjectsFramework.LifecycleManager, NakedObjectsFramework.NakedObjectManager, NakedObjectsFramework.MetamodelManager, targetNo, actionSpec, new INakedObjectAdapter[] {}); var selectedMemento = new CollectionMemento(NakedObjectsFramework.LifecycleManager, NakedObjectsFramework.NakedObjectManager, NakedObjectsFramework.MetamodelManager, memento, new object[] { target }); RoundTrip(selectedMemento); IEnumerable <TestDomainObject> recoveredCollection = selectedMemento.RecoverCollection().GetAsEnumerable(NakedObjectsFramework.NakedObjectManager).Select(AdapterUtils.GetDomainObject <TestDomainObject>); Assert.IsFalse(target.Action1().SequenceEqual(recoveredCollection), "recovered selected collection same as original"); IEnumerable <TestDomainObject> selectedCollection = target.Action1().Where(tdo => tdo.Id == target.Id); Assert.IsTrue(selectedCollection.SequenceEqual(recoveredCollection), "recovered selected collection not same as original selected collection"); }
public void TestActionNoParms() { TestDomainObject target = NakedObjectsFramework.Persistor.Instances <TestDomainObject>().Single(i => i.Id == 1); INakedObjectAdapter targetNo = NakedObjectsFramework.NakedObjectManager.CreateAdapter(target, null, null); IActionSpec actionSpec = targetNo.Spec.GetActions().Single(a => a.Id == "Action1"); var memento = new CollectionMemento(NakedObjectsFramework.LifecycleManager, NakedObjectsFramework.NakedObjectManager, NakedObjectsFramework.MetamodelManager, targetNo, actionSpec, new INakedObjectAdapter[] {}); RoundTrip(memento); RecoverCollection(target.Action1(), memento, NakedObjectsFramework.NakedObjectManager); }