public static void BaseFetchExistingAssetDataTest(AssetBase asset, BaseGetAssetStreamHandler handler, OSHttpResponse response)
        {
            Assert.AreEqual(asset.Data, handler.Handle("/assets/" + asset.ID + "/data", null, null, response), "Failed on fetching data without trailing slash.");
            Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on first fetch.");
            Assert.AreEqual(EXPECTED_CONTENT_TYPE, response.ContentType, "Wrong http content type on first fetch.");

            Assert.AreEqual(asset.Data, handler.Handle("/assets/" + asset.ID + "/data/", null, null, response), "Failed on fetching data with trailing slash.");
            Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on second fetch.");
            Assert.AreEqual(EXPECTED_CONTENT_TYPE, response.ContentType, "Wrong http content type on second fetch.");
        }
        public static void BaseFetchExistingAssetMetaDataTest(AssetBase asset, BaseGetAssetStreamHandler handler, OSHttpResponse response)
        {
            XmlSerializer xs = new XmlSerializer(typeof(AssetMetadata));

            byte[] expected = ServerUtils.SerializeResult(xs, asset.Metadata);

            Assert.AreEqual(expected, handler.Handle("/assets/" + asset.ID + "/metadata", null, null, response), "Failed on fetching data without trailing slash.");
            Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on first fetch.");
            Assert.AreEqual(EXPECTED_CONTENT_TYPE, response.ContentType, "Wrong http content type on first fetch.");

            Assert.AreEqual(expected, handler.Handle("/assets/" + asset.ID + "/metadata/", null, null, response), "Failed on fetching data with trailing slash.");
            Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on second fetch.");
            Assert.AreEqual(EXPECTED_CONTENT_TYPE, response.ContentType, "Wrong http content type on second fetch.");
        }
        public static void BaseFetchExistingAssetXmlTest(AssetBase asset, BaseGetAssetStreamHandler handler, OSHttpResponse response)
        {
            byte[] expected = BaseGetAssetStreamHandler.GetXml(asset);

            byte[] actual = handler.Handle("/assets/" + asset.ID , null, null, response);

            Assert.Greater(actual.Length, 10, "Too short xml on fetching xml without trailing slash.");
            Assert.AreEqual(expected, actual, "Failed on fetching xml without trailing slash.");            
            // Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on first fetch."); 

            actual = handler.Handle("/assets/" + asset.ID + "/", null, null, response);
            Assert.Greater(actual.Length, 10, "Too short xml on fetching xml with trailing slash.");
            Assert.AreEqual(expected, actual, "Failed on fetching xml with trailing slash.");
            // Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on second fetch.");
            
            actual = handler.Handle("/assets/" + asset.ID + "/badData", null, null, response);
            Assert.Greater(actual.Length, 10, "Too short xml on fetching xml with bad trailing data.");
            Assert.AreEqual(expected, actual, "Failed on fetching xml with bad trailing trailing slash.");
            // Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on second fetch.");
        }
 public static void BaseFetchMissingAsset(BaseGetAssetStreamHandler handler, OSHttpResponse response)
 {
     Assert.AreEqual(
         BaseRequestHandlerTestHelper.EmptyByteArray, 
         handler.Handle("/assets/" + Guid.NewGuid(), null, null, response), "Failed on bad guid.");
     Assert.AreEqual((int)HttpStatusCode.NotFound, response.StatusCode, "Response code wrong in BaseFetchMissingAsset");
 }
 public static void BaseTestHandleMalformedGuid(BaseGetAssetStreamHandler handler, string assetsPath)
 {
     Assert.AreEqual(EmptyByteArray, handler.Handle(assetsPath + "/badGuid", null, null, null), "Failed on bad guid.");
 }
 public static void BaseTestHandleNoParams(BaseGetAssetStreamHandler handler, string assetsPath)
 {
     Assert.AreEqual(EmptyByteArray, handler.Handle(assetsPath, null, null, null), "Failed on empty params.");
     Assert.AreEqual(EmptyByteArray, handler.Handle(assetsPath + "/", null, null, null), "Failed on single slash.");
 }