Exemple #1
0
        public void GetCollectionNakedObjectFromId()
        {
            IList <Claim>       claims = NakedObjectsFramework.GetService <ClaimRepository>().FindMyClaims(null, "");
            INakedObjectAdapter no     = NakedObjectsFramework.NakedObjectManager.CreateAdapter(claims, null, null);

            INakedObjectAdapter service = NakedObjectsFramework.ServicesManager.GetService("ClaimRepository");
            IActionSpec         action  = service.Spec.GetActions().Single(a => a.Id == "FindMyClaims");

            INakedObjectAdapter[] parms = new[] { null, "" }.Select(o => NakedObjectsFramework.NakedObjectManager.CreateAdapter(o, null, null)).ToArray();

            var cm    = CollectionMementoHelper.TestMemento(NakedObjectsFramework.LifecycleManager, NakedObjectsFramework.NakedObjectManager, NakedObjectsFramework.MetamodelManager, service, action, parms);

            no.SetATransientOid(cm);

            string id = NakedObjectsFramework.GetObjectId(no);

            INakedObjectAdapter no2 = NakedObjectsFramework.GetNakedObjectFromId(id);

            List <Claim> claims2 = no2.GetDomainObject <IEnumerable <Claim> >().ToList();

            Assert.AreEqual(claims.Count(), claims2.Count());

            int index = 0;
            Dictionary <Claim, Claim> dict = claims.ToDictionary(x => x, y => claims2.Skip(index++).First());

            dict.ForEach(kvp => Assert.AreSame(kvp.Key, kvp.Value));
        }
Exemple #2
0
        public void GetNakedObjectFromId()
        {
            Claim claim1 = NakedObjectsFramework.Persistor.Instances <Claim>().First();
            var   id     = NakedObjectsFramework.GetObjectId(claim1);

            INakedObjectAdapter claim2 = NakedObjectsFramework.GetNakedObjectFromId(objectId);

            Assert.AreSame(claim1, claim2.Object);
        }