private void RoundTrip(CollectionMemento memento) {
            string[] strings1 = memento.ToEncodedStrings();
            var newMemento = new CollectionMemento(strings1);
            string[] strings2 = newMemento.ToEncodedStrings();
            Assert.IsTrue(strings1.SequenceEqual(strings2), "memento failed roundtrip");

            var copyMemento = new CollectionMemento(memento, new object[] {});
            string[] strings3 = copyMemento.ToEncodedStrings();
            Assert.IsTrue(strings1.SequenceEqual(strings3), "memento failed copy");
        }
Exemple #2
0
        public void CollectionMementoToStringWithNull() {
            var mocks = new ContextMocks(controller);
            mocks.ViewDataContainer.Object.ViewData["Services"] = FrameworkHelper.GetServices();

            INakedObject service = NakedObjectsContext.ObjectPersistor.GetService("ClaimRepository");
            INakedObjectAction action = service.Specification.GetObjectActions().Where(a => a.Id == "Find").SelectMany(a => a.Actions).Single(a => a.Id == "FindMyClaims");
            INakedObject[] parms = new[] { null, "" }.Select(PersistorUtils.CreateAdapter).ToArray();

            var cm = new CollectionMemento(service, action, parms);
            string[] strings = cm.ToEncodedStrings();
            var cm2 = new CollectionMemento(strings);
            var claims = (IEnumerable)cm2.RecoverCollection().Object;
            Assert.AreEqual(5, claims.Cast<object>().Count());
            Assert.AreEqual(cm2, cm2.RecoverCollection().Oid);
        }