Esempio n. 1
0
        private ServerSubGridTreeLeaf CreateADefaultEmptyLeaf()
        {
            // Add a cell pass and check the CellHasValue flags the cell as having a value
            ServerSubGridTree tree = new ServerSubGridTree(SubGridTreeConsts.SubGridTreeLevels, 1.0, new SubGridFactory <NodeSubGrid, ServerSubGridTreeLeaf>(), StorageMutability.Mutable);
            var leaf = tree.CreateNewSubGrid(SubGridTreeConsts.SubGridTreeLevels) as ServerSubGridTreeLeaf;

            leaf.Clear();
            leaf.AllocateLeafFullPassStacks();
            leaf.CreateDefaultSegment();
            leaf.AllocateFullPassStacks(leaf.Directory.SegmentDirectory.First());
            leaf.AllocateLeafLatestPassGrid();

            return(leaf);
        }
Esempio n. 2
0
        public void LoadDirectoryFromFile_FailureModes_StreamDoesNotExist()
        {
            var tree = new ServerSubGridTree(SubGridTreeConsts.SubGridTreeLevels, 1.0, new SubGridFactory <NodeSubGrid, ServerSubGridTreeLeaf>(), StorageMutability.Mutable);
            var leaf = tree.CreateNewSubGrid(SubGridTreeConsts.SubGridTreeLevels) as ServerSubGridTreeLeaf;

            var mockStorage = new Mock <IStorageProxy>();

            MemoryStream stream;

            mockStorage.Setup(x => x.ReadSpatialStreamFromPersistentStore(It.IsAny <Guid>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <long>(), It.IsAny <long>(), It.IsAny <long>(),
                                                                          FileSystemStreamType.SubGridDirectory, out stream)).Returns(FileSystemErrorStatus.FileDoesNotExist);

            leaf.LoadDirectoryFromFile(mockStorage.Object, "filename").Should().BeFalse();
        }
Esempio n. 3
0
        public void Test_ServerSubGridTreeLeaf_CreateDefaultSegment()
        {
            ServerSubGridTree tree = new ServerSubGridTree(SubGridTreeConsts.SubGridTreeLevels, 1.0, new SubGridFactory <NodeSubGrid, ServerSubGridTreeLeaf>(), StorageMutability.Mutable);
            var leaf = tree.CreateNewSubGrid(SubGridTreeConsts.SubGridTreeLevels) as ServerSubGridTreeLeaf;

            Assert.True(0 == leaf.Directory.SegmentDirectory.Count);

            leaf.CreateDefaultSegment();

            Assert.True(1 == leaf.Directory.SegmentDirectory.Count);

            Assert.True(leaf.Directory.SegmentDirectory.First().StartTime == Consts.MIN_DATETIME_AS_UTC &&
                        leaf.Directory.SegmentDirectory.First().EndTime == Consts.MAX_DATETIME_AS_UTC,
                        "Default segment does not have history spanning time range");
        }
Esempio n. 4
0
        public void Test_ServerSubGridTreeLeaf_ServerSubGridTreeLeaf()
        {
            ServerSubGridTree tree = new ServerSubGridTree(SubGridTreeConsts.SubGridTreeLevels, 1.0, new SubGridFactory <NodeSubGrid, ServerSubGridTreeLeaf>(), StorageMutability.Mutable);
            var leaf = tree.CreateNewSubGrid(SubGridTreeConsts.SubGridTreeLevels) as ServerSubGridTreeLeaf;

            leaf.Clear();

            Assert.True(leaf.Cells == null &&
                        leaf.Directory != null &&
                        leaf.Dirty == false &&
                        leaf.LeafEndTime == Consts.MIN_DATETIME_AS_UTC &&
                        leaf.LeafStartTime == Consts.MAX_DATETIME_AS_UTC &&
                        leaf.Level == SubGridTreeConsts.SubGridTreeLevels &&
                        leaf.IsLeafSubGrid(),
                        "Leaf not initialized as expected");
        }
Esempio n. 5
0
        public void Test_ServerSubGridTreeLeaf_AllocateFullPassStacks()
        {
            ServerSubGridTree tree = new ServerSubGridTree(SubGridTreeConsts.SubGridTreeLevels, 1.0, new SubGridFactory <NodeSubGrid, ServerSubGridTreeLeaf>(), StorageMutability.Mutable);
            var leaf = tree.CreateNewSubGrid(SubGridTreeConsts.SubGridTreeLevels) as ServerSubGridTreeLeaf;

            leaf.Clear();
            leaf.AllocateLeafFullPassStacks();
            leaf.CreateDefaultSegment();
            leaf.AllocateFullPassStacks(leaf.Directory.SegmentDirectory.First());

            Assert.True(leaf.Cells != null &&
                        leaf.Directory != null &&
                        leaf.Dirty == false &&
                        leaf.LeafEndTime == Consts.MIN_DATETIME_AS_UTC &&
                        leaf.LeafStartTime == Consts.MAX_DATETIME_AS_UTC &&
                        leaf.Level == SubGridTreeConsts.SubGridTreeLevels &&
                        leaf.IsLeafSubGrid(),
                        "Leaf not initialized as expected after AllocateFullPassStacks");
        }