public ICollection <TestDomainObject> Action3(TestDomainObject filter)
 {
     if (filter != null)
     {
         return(Container.Instances <TestDomainObject>().Where(tdo => tdo.Id != filter.Id).ToList());
     }
     return(new TestDomainObject[] {});
 }
        public void TestActionValueParmString()
        {
            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 == "Action6");

            var memento = new CollectionMemento(NakedObjectsFramework.LifecycleManager, NakedObjectsFramework.NakedObjectManager, NakedObjectsFramework.MetamodelManager, targetNo, actionSpec, new[] { NakedObjectsFramework.NakedObjectManager.CreateAdapter("1", null, null) });

            RoundTrip(memento);
            RecoverCollection(target.Action6("1"), memento, NakedObjectsFramework.NakedObjectManager);
        }
        public void TestActionObjectCollectionParmEmpty()
        {
            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 == "Action5");

            var rawParm = new List <TestDomainObject>();
            INakedObjectAdapter parm = NakedObjectsFramework.NakedObjectManager.CreateAdapter(rawParm, null, null);

            var memento = new CollectionMemento(NakedObjectsFramework.LifecycleManager, NakedObjectsFramework.NakedObjectManager, NakedObjectsFramework.MetamodelManager, targetNo, actionSpec, new[] { parm });

            RoundTrip(memento);
            RecoverCollection(target.Action5(rawParm), memento, NakedObjectsFramework.NakedObjectManager);
        }
        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 ICollection<TestDomainObject> Action3(TestDomainObject filter) {
     if (filter != null) {
         return Container.Instances<TestDomainObject>().Where(tdo => tdo.Id != filter.Id).ToList();
     }
     return new TestDomainObject[] {};
 }