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 }); }
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); }
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); }
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); } }
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); }
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); }
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); } }
public IObjectFacade GetObjectFacadeByOid(IOidTranslation objectId) { var adapter = GetAdapterByOidTranslation(objectId); return(adapter == null ? null : ObjectFacade.Wrap(adapter, FrameworkFacade, framework)); }
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); }