public void Init()
 {
     _repoCreator = A.Fake<INodeRepoCreator>();
     _idGenerator = new IdGenerator (_repoCreator);
     _idRepoService= A.Fake<INeo4NodeRepository<IdGeneratorNode>>();
     A.CallTo(() => _repoCreator.CreateNode<IdGroupNodeRelationship, IdReferenceNode, IdGeneratorNode>("",typeof(IdGeneratorRefNodeRelationship))).Returns(_idRepoService);
 }
        public void Init()
        {
            try
            {

            _graphClient = new GraphClient(new Uri("http://localhost:7474/db/data"));
            _graphClient.Connect();

            }
            catch (Exception)
            {

                throw new Exception("Not Connected To Neo4j Server");
            }

            _relationshipManager = new Neo4jRelationshipManager();

            //Chicken and Egg...
            INodeRepoCreator repoCreator = new NodeRepoCreator(_graphClient,_relationshipManager);

            var idGenerator = new IdGenerator(repoCreator);
            idGenerator.LoadGenerator(50);

            _ownedByService = repoCreator.CreateNode<OwnedBy, StorageLocation>("Name");

            _initialAddRef = _ownedByService.UpdateOrInsert(new StorageLocation { Id = 1, Name = "Main WH" }, _graphClient.RootNode);
        }
        public void LoadGenerator(int cacheSize)
        {
            _idRepoService = _repoCreator.CreateNode<IdGroupNodeRelationship, IdReferenceNode, IdGeneratorNode>("", typeof(IdGeneratorRefNodeRelationship));

            _cacheSize = cacheSize;
            //Update ndoes with current plus cache
            _idList = new ConcurrentDictionary<string, IdContainer>();

            var allIds = _idRepoService.GetAll().ToList();

            _isLoaded = true;

            foreach (var id in allIds)
            {
                _idList.Add(id.GroupName, new IdContainer {CurrentValue = id.CurrentId, StartValue = id.CurrentId, Id = id.Id});
                CreateOrUpdateIdNode(id.GroupName, id.CurrentId + _cacheSize, id.Id);
            }

            CreateIdNodeToKeepTrackOfIdsForIds(allIds);
        }