コード例 #1
0
 public ListContextFacade ToListContextFacade(IFrameworkFacade facade, INakedObjectsFramework framework)
 {
     return(new ListContextFacade {
         ElementType = new TypeFacade(ElementType, facade, framework),
         List = List.Select(no => ObjectFacade.Wrap(no, facade, framework)).Cast <IObjectFacade>().ToArray(),
         IsListOfServices = IsListOfServices
     });
 }
コード例 #2
0
 public void SetUp()
 {
     objectId       = ObjectId.NewUniqueId();
     objectTypeId   = new ObjectTypeId(new Guid(objectTypeIdValue));
     changeSetId    = ChangeSetId.NewUniqueId();
     typeRepository = new ObjectTypeDescriptorRepository().RegisterUsingReflection <TestingObject>();
     dataFacadeMock = new Mock <IDataFacade>();
     objectFacade   = new ObjectFacade(dataFacadeMock.Object, typeRepository, new Mock <ICommandExecutor>().Object);
 }
コード例 #3
0
        protected T ToContextFacade <T>(T context, IFrameworkFacade facade, INakedObjectsFramework framework) where T : ContextFacade
        {
            context.Target               = ObjectFacade.Wrap(Target, facade, framework);
            context.Reason               = Reason;
            context.ErrorCause           = ErrorCause;
            context.ProposedObjectFacade = ObjectFacade.Wrap(ProposedNakedObject, facade, framework);
            context.ProposedValue        = ProposedValue;

            return(context);
        }
コード例 #4
0
        public void It_can_handle_1000_objects_with_10_changes_each()
        {
            var dataStore = new InMemoryDataStore();

            var objectIds = GenerateObjectIds(1000);

            ChangeSetId?previousChangeSetId = null;
            ChangeSetId currentChangeSetId  = ChangeSetId.NewUniqueId();

            dataStore.ChangeSets.Add(new ChangeSet(currentChangeSetId, previousChangeSetId, "Some comment", GenerateCreateCommands(objectIds)));
            previousChangeSetId = currentChangeSetId;

            for (int i = 0; i < 9; i++)
            {
                currentChangeSetId = ChangeSetId.NewUniqueId();
                dataStore.ChangeSets.Add(new ChangeSet(currentChangeSetId, previousChangeSetId, "Some comment", GenerateUpdateCommands(i, objectIds)));
                previousChangeSetId = currentChangeSetId;
            }

            var commandExecutor = new CommandExecutor()
                                  .RegisterCommandHandler(new CreateObjectCommandHandler())
                                  .RegisterCommandHandler(new ModifyAttributeCommandHandler());
            var objectTypeRepository = new ObjectTypeDescriptorRepository()
                                       .RegisterUsingReflection <TestingObject>();
            var dataFacade   = new DataFacade(commandExecutor, dataStore, new IncrementalCachingSnapshotFactory());
            var objectFacade = new ObjectFacade(dataFacade, objectTypeRepository, commandExecutor);

            var stopwatch = new Stopwatch();

            stopwatch.Start();
            var currentView = objectFacade.GetSnapshot(currentChangeSetId);
            var allObjects  = currentView.List <TestingObject>().ToList();

            stopwatch.Stop();
            Console.WriteLine(stopwatch.ElapsedMilliseconds);
            Assert.AreEqual(1000, allObjects.Count);
            foreach (var testingObject in allObjects)
            {
                Assert.AreEqual("8", testingObject.TextValue);
            }
        }
コード例 #5
0
        public void SetUp()
        {
            var dataStore       = new InMemoryDataStore();
            var commandExecutor = new CommandExecutor()
                                  .RegisterCommandHandler(new CreateUnitCommandHandler())
                                  .RegisterCommandHandler(new CreateHierarchyCommandHandler())
                                  .RegisterCommandHandler(new SetHierarchyRootCommandHandler())
                                  .RegisterCommandHandler(new MoveUnitCommandHandler())
                                  .RegisterCommandHandler(new CreateHierarchyNodeCommandHandler())
                                  .RegisterCommandHandler(new AttachToHierarchyCommandHandler())
                                  .RegisterCommandHandler(new AttachChildCommandHandler())
                                  .RegisterCommandHandler(new DetachChildCommandHandler())
                                  .RegisterCommandHandler(new SetParentCommandHandler());

            var typeRepository = new ObjectTypeDescriptorRepository()
                                 .RegisterUsingReflection <Unit>()
                                 .RegisterUsingReflection <HierarchyNode>()
                                 .RegisterUsingReflection <Hierarchy>();

            dataFacade   = new DataFacade(commandExecutor, dataStore, new IncrementalCachingSnapshotFactory());
            objectFacade = new ObjectFacade(dataFacade, typeRepository, commandExecutor);
        }
コード例 #6
0
        public void SetUp()
        {
            var dataStore = new InMemoryDataStore();
            var commandExecutor = new CommandExecutor()
                .RegisterCommandHandler(new CreateUnitCommandHandler())
                .RegisterCommandHandler(new CreateHierarchyCommandHandler())
                .RegisterCommandHandler(new SetHierarchyRootCommandHandler())
                .RegisterCommandHandler(new MoveUnitCommandHandler())
                .RegisterCommandHandler(new CreateHierarchyNodeCommandHandler())
                .RegisterCommandHandler(new AttachToHierarchyCommandHandler())
                .RegisterCommandHandler(new AttachChildCommandHandler())
                .RegisterCommandHandler(new DetachChildCommandHandler())
                .RegisterCommandHandler(new SetParentCommandHandler());

            var typeRepository = new ObjectTypeDescriptorRepository()
                .RegisterUsingReflection<Unit>()
                .RegisterUsingReflection<HierarchyNode>()
                .RegisterUsingReflection<Hierarchy>();

            dataFacade = new DataFacade(commandExecutor, dataStore, new IncrementalCachingSnapshotFactory());
            objectFacade = new ObjectFacade(dataFacade, typeRepository, commandExecutor);
        }
コード例 #7
0
        public void It_can_handle_1000_objects_with_10_changes_each()
        {
            var dataStore = new InMemoryDataStore();

            var objectIds = GenerateObjectIds(1000);

            ChangeSetId? previousChangeSetId = null;
            ChangeSetId currentChangeSetId = ChangeSetId.NewUniqueId();
            dataStore.ChangeSets.Add(new ChangeSet(currentChangeSetId, previousChangeSetId, "Some comment", GenerateCreateCommands(objectIds)));
            previousChangeSetId = currentChangeSetId;

            for (int i = 0; i < 9; i++)
            {
                currentChangeSetId = ChangeSetId.NewUniqueId();
                dataStore.ChangeSets.Add(new ChangeSet(currentChangeSetId, previousChangeSetId, "Some comment", GenerateUpdateCommands(i, objectIds)));
                previousChangeSetId = currentChangeSetId;
            }

            var commandExecutor = new CommandExecutor()
                .RegisterCommandHandler(new CreateObjectCommandHandler())
                .RegisterCommandHandler(new ModifyAttributeCommandHandler());
            var objectTypeRepository = new ObjectTypeDescriptorRepository()
                .RegisterUsingReflection<TestingObject>();
            var dataFacade = new DataFacade(commandExecutor, dataStore, new IncrementalCachingSnapshotFactory());
            var objectFacade = new ObjectFacade(dataFacade, objectTypeRepository, commandExecutor);

            var stopwatch = new Stopwatch();
            stopwatch.Start();
            var currentView = objectFacade.GetSnapshot(currentChangeSetId);
            var allObjects = currentView.List<TestingObject>().ToList();
            stopwatch.Stop();
            Console.WriteLine(stopwatch.ElapsedMilliseconds);
            Assert.AreEqual(1000, allObjects.Count);
            foreach (var testingObject in allObjects)
            {
                Assert.AreEqual("8", testingObject.TextValue);
            }
        }
コード例 #8
0
        public IObjectFacade GetObjectFacadeByOid(IOidTranslation objectId)
        {
            var adapter = GetAdapterByOidTranslation(objectId);

            return(adapter == null ? null : ObjectFacade.Wrap(adapter, FrameworkFacade, framework));
        }
コード例 #9
0
 public void SetUp()
 {
     objectId = ObjectId.NewUniqueId();
     objectTypeId = new ObjectTypeId(new Guid(objectTypeIdValue));
     changeSetId = ChangeSetId.NewUniqueId();
     typeRepository = new ObjectTypeDescriptorRepository().RegisterUsingReflection<TestingObject>();
     dataFacadeMock = new Mock<IDataFacade>();
     objectFacade = new ObjectFacade(dataFacadeMock.Object, typeRepository, new Mock<ICommandExecutor>().Object);
 }