Ejemplo n.º 1
0
        public void OutcallRestrictionTable_ErrorResponse_Null()
        {
            ClassOfService   oCos   = new ClassOfService(_mockServer);
            RestrictionTable oTable = oCos.OutcallRestrictionTable(true);

            Assert.IsNull(oTable, "Fetching restriction table on empty instance should return null");
        }
Ejemplo n.º 2
0
        public void RestrictionTable_Constructor_EmptyObjectId_Failure()
        {
            Reset();
            RestrictionTable oTest = new RestrictionTable(_mockServer, "", "bogusDisplayName");

            Console.WriteLine(oTest);
        }
Ejemplo n.º 3
0
        public void GetRestrictionTables_NullConnectionServer_Failure()
        {
            //static fetch failures
            List <RestrictionTable> oTables;
            var res = RestrictionTable.GetRestrictionTables(null, out oTables);

            Assert.IsFalse(res.Success, "Static restriction table creation did not fail with null ConnectionServer");
        }
        public void GetRestrictionTables_WithQueryThatReturnsNoResults_Success()
        {
            List <RestrictionTable> oTables;

            var res = RestrictionTable.GetRestrictionTables(_connectionServer, out oTables, 1, 2, "query=(ObjectId is Bogus)");

            Assert.IsTrue(res.Success, "fetching RTs with invalid query should not fail:" + res);
            Assert.IsTrue(oTables.Count == 0, "Invalid query string should return an empty RT list:" + oTables.Count);
        }
        private RestrictionTable HelperGetRestrictionTable()
        {
            List <RestrictionTable> oTables;
            WebCallResult           res = RestrictionTable.GetRestrictionTables(_connectionServer, out oTables, 1, 2);

            Assert.IsTrue(res.Success, "Fetching restriction tables failed:" + res);
            Assert.IsTrue(oTables.Count > 0, "No restriction tables fetched");
            return(oTables[0]);
        }
        public void RestrictionTable_ConstructorWithDisplayName_Success()
        {
            var oTable = HelperGetRestrictionTable();

            try
            {
                RestrictionTable oNewTable = new RestrictionTable(_connectionServer, "", oTable.DisplayName);
                Console.WriteLine(oNewTable);
            }
            catch (Exception ex)
            {
                Assert.Fail("RestrictionTable class creation failed with valid name:" + ex);
            }
        }
Ejemplo n.º 7
0
        public void GetRestrictionTables_GarbageResponse_Success()
        {
            //garbage response
            _mockTransport.Setup(x => x.GetCupiResponse(It.IsAny <string>(), MethodType.GET, It.IsAny <ConnectionServerRest>(),
                                                        It.IsAny <string>(), true)).Returns(new WebCallResult
            {
                Success      = true,
                ResponseText = "garbage result"
            });
            List <RestrictionTable> oTables;
            var res = RestrictionTable.GetRestrictionTables(_mockServer, out oTables, 1, 2, "InvalidResultText");

            Assert.IsTrue(res.Success, "Calling GetRestrictionTables with InvalidResultText should not fail:" + res);
            Assert.IsTrue(oTables.Count == 0, "Invalid response text should result in an empty list");
        }
Ejemplo n.º 8
0
        public void GetRestrictionTables_ErrorResponse_Failure()
        {
            //error response
            _mockTransport.Setup(x => x.GetCupiResponse(It.IsAny <string>(), MethodType.GET, It.IsAny <ConnectionServerRest>(),
                                                        It.IsAny <string>(), true)).Returns(new WebCallResult
            {
                Success      = false,
                ResponseText = "error text",
                StatusCode   = 404
            });
            List <RestrictionTable> oTables;
            var res = RestrictionTable.GetRestrictionTables(_mockServer, out oTables, 1, 2, "ErrorResponse");

            Assert.IsFalse(res.Success, "Calling GetRestrictionTables with ErrorResponse should fail");
            Assert.IsTrue(oTables.Count == 0, "Error response should result in an empty list");
        }
Ejemplo n.º 9
0
        public void GetRestrictionTables_EmptyResponse_Failure()
        {
            //empty results
            _mockTransport.Setup(x => x.GetCupiResponse(It.IsAny <string>(), It.IsAny <MethodType>(), It.IsAny <ConnectionServerRest>(),
                                                        It.IsAny <string>(), true)).Returns(new WebCallResult
            {
                Success      = true,
                ResponseText = ""
            });

            List <RestrictionTable> oTables;
            var res = RestrictionTable.GetRestrictionTables(_mockServer, out oTables, 1, 2, "EmptyResultText");

            Assert.IsFalse(res.Success, "Calling GetRestrictionTables with empty result text should fail");
            Assert.IsTrue(oTables.Count == 0, "Empty response text should result in an empty list");
        }
Ejemplo n.º 10
0
        public void RestrictionTable_Test()
        {
            _errorString = "";
            List <RestrictionTable> oRestrictionTables;
            var res = RestrictionTable.GetRestrictionTables(_connectionServer, out oRestrictionTables, 1, 2);

            Assert.IsTrue(res.Success & oRestrictionTables.Count > 0, "Failed to fetch restrictiontable:" + res);
            Assert.IsTrue(string.IsNullOrEmpty(_errorString), _errorString);

            //Restriction table pattern
            List <RestrictionPattern> oRestrictionPatterns;

            res = RestrictionPattern.GetRestrictionPatterns(_connectionServer, oRestrictionTables[0].ObjectId,
                                                            out oRestrictionPatterns);
            Assert.IsTrue(res.Success & oRestrictionTables.Count > 0, "Failed to fetch restrictiontablepattern:" + res);
            Assert.IsTrue(string.IsNullOrEmpty(_errorString), _errorString);
        }
Ejemplo n.º 11
0
        public void RestrictionTable_Constructor_GarbageResponse_Failure()
        {
            //garbage response
            _mockTransport.Setup(x => x.GetCupiResponse(It.IsAny <string>(), MethodType.GET, It.IsAny <ConnectionServerRest>(),
                                                        It.IsAny <string>(), true)).Returns(new WebCallResult
            {
                Success      = true,
                ResponseText = "garbage result"
            });

            try
            {
                RestrictionTable oTable = new RestrictionTable(_mockServer, "InvalidResultText");
                Assert.Fail("Creating restriction table with garbage response text should fail");
            }
            catch { }
        }
        public void GetRestrictionTables_NullQuery_Success()
        {
            List <RestrictionTable> oTables;
            WebCallResult           res = RestrictionTable.GetRestrictionTables(_connectionServer, out oTables, 1, 2, null);

            Assert.IsTrue(res.Success, "Fetching restriction tables failed:" + res);
            Assert.IsTrue(oTables.Count > 0, "No restriction tables fetched");

            try
            {
                RestrictionPattern oPattern = new RestrictionPattern(_connectionServer, oTables[0].ObjectId);
            }
            catch (Exception ex)
            {
                Assert.Fail("Creating new pattern object without an objectId should not fail:" + ex);
            }
        }
Ejemplo n.º 13
0
        public void RestrictionTable_Constructor_ErrorResponse_Failure()
        {
            //error response
            _mockTransport.Setup(x => x.GetCupiResponse(It.IsAny <string>(), MethodType.GET, It.IsAny <ConnectionServerRest>(),
                                                        It.IsAny <string>(), true)).Returns(new WebCallResult
            {
                Success      = false,
                ResponseText = "error text",
                StatusCode   = 404
            });

            try
            {
                RestrictionTable oTable = new RestrictionTable(_mockServer, "ErrorResponse");
                Assert.Fail("Creating restriction table with error response text should fail");
            }
            catch { }
        }
Ejemplo n.º 14
0
        public static CLandblockInfo ReadFromDat(uint landblockId)
        {
            // Check if landblockId is a full dword. We just need the hiword for the landblockId
            if ((landblockId >> 16) != 0)
            {
                landblockId = landblockId >> 16;
            }

            // The file index is CELL + 0xFFFF. e.g. a cell of 1234, the file index would be 0x1234FFFE.
            uint landblockFileIndex = (landblockId << 16) + 0xFFFE;

            // Check the FileCache so we don't need to hit the FileSystem repeatedly
            if (DatManager.CellDat.FileCache.ContainsKey(landblockFileIndex))
            {
                return((CLandblockInfo)DatManager.CellDat.FileCache[landblockFileIndex]);
            }
            else
            {
                CLandblockInfo c = new CLandblockInfo();
                if (DatManager.CellDat.AllFiles.ContainsKey(landblockFileIndex))
                {
                    DatReader datReader = DatManager.CellDat.GetReaderForFile(landblockFileIndex);

                    uint file_id = datReader.ReadUInt32();
                    c.NumCells = datReader.ReadUInt32();

                    uint num_objects = datReader.ReadUInt32();
                    for (uint i = 0; i < num_objects; i++)
                    {
                        c.ObjectIds.Add(datReader.ReadUInt32());

                        Position objPosition = new Position();
                        objPosition.PositionX = datReader.ReadSingle();
                        objPosition.PositionY = datReader.ReadSingle();
                        objPosition.PositionZ = datReader.ReadSingle();
                        objPosition.RotationW = datReader.ReadSingle();
                        objPosition.RotationX = datReader.ReadSingle();
                        objPosition.RotationY = datReader.ReadSingle();
                        objPosition.RotationZ = datReader.ReadSingle();
                        c.ObjectFrames.Add(objPosition);
                    }

                    ushort num_buildings = datReader.ReadUInt16();
                    c.PackMask = datReader.ReadUInt16();

                    for (uint i = 0; i < num_buildings; i++)
                    {
                        BuildInfo b = new BuildInfo();
                        b.ModelId = datReader.ReadUInt32();

                        // position
                        b.Frame.PositionX = datReader.ReadSingle();
                        b.Frame.PositionY = datReader.ReadSingle();
                        b.Frame.PositionZ = datReader.ReadSingle();
                        b.Frame.RotationW = datReader.ReadSingle();
                        b.Frame.RotationX = datReader.ReadSingle();
                        b.Frame.RotationY = datReader.ReadSingle();
                        b.Frame.RotationZ = datReader.ReadSingle();

                        b.NumLeaves = datReader.ReadUInt32();
                        uint num_portals = datReader.ReadUInt32();

                        for (uint j = 0; j < num_portals; j++)
                        {
                            CBldPortal cbp = new CBldPortal();
                            cbp.Flags      = datReader.ReadUInt16();
                            cbp.ExactMatch = (ushort)(cbp.Flags & 1);
                            cbp.PortalSide = (ushort)((cbp.Flags >> 1) & 1);

                            cbp.OtherCellId   = (landblockId << 16) + datReader.ReadUInt16();
                            cbp.OtherPortalId = (landblockId << 16) + datReader.ReadUInt16();

                            ushort num_stabs = datReader.ReadUInt16();
                            for (ushort k = 0; k < num_stabs; k++)
                            {
                                cbp.StabList.Add((landblockId << 16) + datReader.ReadUInt16());
                            }

                            datReader.AlignBoundary();
                            b.Portals.Add(cbp);
                        }

                        c.Buildings.Add(b);
                    }

                    if ((c.PackMask & 1) == 1)
                    {
                        ushort num_restiction_table = datReader.ReadUInt16();
                        c.UnknownShort = datReader.ReadUInt16(); // seems to always be 0x0008 ... packed val?
                        for (ushort i = 0; i < num_restiction_table; i++)
                        {
                            RestrictionTable r = new RestrictionTable();
                            r.Landblock = datReader.ReadUInt32();
                            r.Iid       = datReader.ReadUInt32();
                            c.Restriction_table.Add(r);
                        }
                    }

                    // Store this object in the FileCache
                    DatManager.CellDat.FileCache[landblockFileIndex] = c;
                }

                return(c);
            }
        }
Ejemplo n.º 15
0
        public void RestrictionTable_Constructor_NullConnectionServer_Failure()
        {
            RestrictionTable oTest = new RestrictionTable(null);

            Console.WriteLine(oTest);
        }
        public void RestrictionTable_Constructor_InvalidDisplayName_Failure()
        {
            RestrictionTable oTest = new RestrictionTable(_connectionServer, "", "bogusDisplayName");

            Console.WriteLine(oTest);
        }
        public void RestritionTable_Constructor_InvalidObjectId_Failure()
        {
            RestrictionTable oTest = new RestrictionTable(_connectionServer, "ObjectId");

            Console.WriteLine(oTest);
        }