示例#1
0
        public void TestPauseCapOk()
        {
            var capId = Guid.NewGuid();

            TestAddCap.AddCap(capId);
            var response = PauseCap(capId);

            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode, "Bad Status:\n\n" + response.Content);
        }
示例#2
0
        public void TestPauseCapBadAdminTokenBadRequest()
        {
            var capId = Guid.NewGuid();

            TestAddCap.AddCap(capId);
            var response = PauseCap(capId, "badToken");

            Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode, "Bad Status:\n\n" + response.Content);
        }
示例#3
0
        public void TestRemoveCapTwiceBadRequest()
        {
            var capId = Guid.NewGuid();

            TestAddCap.AddCap(capId);
            RemoveCap(capId);
            var response = RemoveCap(capId);

            Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode, "Bad Status:\n\n" + response.Content);
        }
示例#4
0
        public void Setup()
        {
            CleanupCache();

            _capId = Guid.NewGuid();
            TestAddCap.AddCap(_capId);

            // Using hardcoded GUIDs to make debugging easier.

            _knownTextureAsset = CreateAndCacheAsset(
                "_knownTextureAsset",
                0,
                new byte[] { 0x00, 0x00, 0x00, 0x0C, 0x6A, 0x50, 0x20, 0x20, 0x0D, 0x0A, 0x87, 0x0A },                 // JPEG-2000 magic numbers
                Guid.Parse("01000000-0000-0000-0000-000000000000")
                );

            _knownTextureTGAAsset = CreateAndCacheAsset(
                "_knownTextureTGAAsset",
                12,
                new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x54, 0x52, 0x55, 0x45, 0x56, 0x49, 0x53, 0x49, 0x4f, 0x4e, 0x2d, 0x58, 0x46, 0x49, 0x4c, 0x45, 0x2e, 0x00 },                 // TGA uses a footer for some silly historical/legacy reason.  I made some educated guesses for making this a minimal valid TGA, but i've not verified.
                Guid.Parse("02000000-0000-0000-0000-000000000000")
                );

            _knownImageTGAAsset = CreateAndCacheAsset(
                "_knownImageTGAAsset",
                18,
                new byte[] { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x54, 0x52, 0x55, 0x45, 0x56, 0x49, 0x53, 0x49, 0x4f, 0x4e, 0x2d, 0x58, 0x46, 0x49, 0x4c, 0x45, 0x2e, 0x00 },                 // TGA uses a footer for some silly historical/legacy reason.  I made some educated guesses for making this a minimal valid TGA, but i've not verified.
                Guid.Parse("03000000-0000-0000-0000-000000000000")
                );

            _knownImageJPEGAsset = CreateAndCacheAsset(
                "_knownImageJPEGAsset",
                19,
                new byte[] { 0xFF, 0xD8, 0xFF, 0xE1, 0x00, 0x00, 0x45, 0x78, 0x69, 0x66, 0x00 },                 // JPEG-EXIF magic numbers, guessing that's what is used but I could totally be wrong.
                Guid.Parse("04000000-0000-0000-0000-000000000000")
                );

            _knownMeshAsset = CreateAndCacheAsset(
                "_knownMeshAsset",
                49,
                new byte[] { 0xfa },                 // TODO: find out what mesh's header is if any.
                Guid.Parse("05000000-0000-0000-0000-000000000000")
                );

            _knownNotecardAsset = CreateAndCacheAsset(
                "_knownNotecardAsset",
                7,
                Encoding.UTF8.GetBytes("Just some text."),
                Guid.Parse("06000000-0000-0000-0000-000000000000")
                );
        }
示例#5
0
        public void TestPauseCapBlocksGetAsset()
        {
            var capId = Guid.NewGuid();

            TestAddCap.AddCap(capId);
            PauseCap(capId);

            try {
                var response = TestGetAsset.GetAsset(capId, Guid.NewGuid(), timeout: TimeSpan.FromMilliseconds(200));
                Assert.Fail();
            }
            catch (WebException e) {
                Assert.AreEqual(WebExceptionStatus.Timeout, e.Status);                 // It timed out
            }
        }
示例#6
0
        public void TestResumeCapAllowsGet()
        {
            var capId = Guid.NewGuid();

            TestAddCap.AddCap(capId);
            TestPauseCap.PauseCap(capId);
            ResumeCap(capId);
            try {
                var response = TestGetAsset.GetAsset(capId, _knownTextureAsset.Id, timeout: TimeSpan.FromMilliseconds(100));
                Assert.Pass();
            }
            catch (WebException e) {
                Assert.AreEqual(WebExceptionStatus.Timeout, e.Status);                 // It timed out
            }
        }
示例#7
0
        public void TestResumeCapContinuesResponse()
        {
            var capId = Guid.NewGuid();

            TestAddCap.AddCap(capId);
            TestPauseCap.PauseCap(capId);

            var getStatus = HttpStatusCode.Unused;

            TestGetAsset.GetAsset(capId, _knownTextureAsset.Id, getResponse => getStatus = getResponse.StatusCode);
            Assert.AreEqual(HttpStatusCode.Unused, getStatus);

            ResumeCap(capId);

            Assert.That(() => getStatus, Is.EqualTo(HttpStatusCode.OK).After(200).MilliSeconds);
        }