Beispiel #1
0
        public void SendFabricOauthError()
        {
            FabOauthError foe = new FabOauthError();

            foe.error             = "Test";
            foe.error_description = "Desc";

            var wr = new TestWebResponse(GetStream(foe));
            var we = new WebException("Error", null, WebExceptionStatus.UnknownError, wr);

            vMoqHttpProv
            .Setup(x => x.GetResponse(vHttpReq))
            .Throws(we);

            var req = NewFabricRequest <FabOauthAccess>();

            try {
                req.Send(vContext, SessionType.Default);
                Assert.Fail("WebException expected, but not thrown.");
            }
            catch (FabricErrorException errEx) {
                Assert.Null(errEx.RespError, "Error should be null.");
                Assert.NotNull(errEx.OauthError, "OauthError should be filled.");
                Assert.AreEqual(foe.error, errEx.OauthError.error, "Incorrect OauthError.error.");
                Assert.AreEqual(foe.error_description, errEx.OauthError.error_description,
                                "Incorrect OauthError.error_description.");
            }
            catch (Exception e) {
                Assert.Fail("WebException expected: " + e);
            }
        }
Beispiel #2
0
        public void EnqueueThisFileAsNextResponse(string sampleData)
        {
            Stream responseStream = new FileStream(sampleData, FileMode.Open);

            var webResponse = new TestWebResponse(responseStream);

            _responses.Enqueue(webResponse);
        }
Beispiel #3
0
        public void SendFabricError()
        {
            var fe = new FabError();

            fe.Name    = "Test";
            fe.Message = "Desc";
            fe.Code    = 500;

            var fr = new FabResponse();

            fr.Error = fe;

            var wr = new TestWebResponse(GetStream(fr.ToJson()));
            var we = new WebException("Error", null, WebExceptionStatus.UnknownError, wr);

            vMoqHttpProv
            .Setup(x => x.GetResponse(vHttpReq))
            .Throws(we);

            var req = NewFabricRequest <FabResponse <FabApp> >();

            try {
                req.Send(vContext, SessionType.Default);
                Assert.Fail("WebException expected, but not thrown.");
            }
            catch (FabricErrorException errEx) {
                Assert.NotNull(errEx.RespError, "Error should be filled.");
                Assert.Null(errEx.OauthError, "OauthError should be null.");
                Assert.AreEqual(fe.Code, errEx.RespError.Error.Code, "Incorrect Error.Code.");
                Assert.AreEqual(fe.Name, errEx.RespError.Error.Name, "Incorrect Error.Name.");
                Assert.AreEqual(fe.Message, errEx.RespError.Error.Message, "Incorrect Error.Message.");
            }
            catch (Exception e) {
                Assert.Fail("WebException expected: " + e);
            }
        }
Beispiel #4
0
        public void EnqueueThisDocumentAsNextResponse(XDocument document)
        {
            var webResponse = new TestWebResponse(document);

            _responses.Enqueue(webResponse);
        }