Пример #1
0
        public void TestResponse_Constructor_SetsFields()
        {
            var expectedFields = new TestResponseFields();
            var response       = new IsResponse <TestResponseFields>(expectedFields);

            Assert.AreSame(expectedFields, response.Fields);
        }
Пример #2
0
        public void TestResponse_Constructor_SetsBehavior()
        {
            var behavior = new Behavior();
            var response = new IsResponse <TestResponseFields>(new TestResponseFields(), behavior);

            Assert.AreSame(behavior, response.Behavior);
        }
Пример #3
0
        /// <summary>
        /// Adds a response to the stub that will return the specified HTTP status code.
        /// </summary>
        /// <param name="statusCode">The status code to be returned</param>
        /// <returns>The stub that the response was added to</returns>
        public HttpStub ReturnsStatus(HttpStatusCode statusCode)
        {
            var fields = new HttpResponseFields
            {
                StatusCode = statusCode
            };

            var response = new IsResponse <HttpResponseFields>(fields);

            return(Returns(response));
        }
Пример #4
0
        /// <summary>
        /// Adds a response to the stub that will return the specified data.
        /// </summary>
        /// <param name="data">The data to be returned</param>
        /// <returns>The stub that the response was added to</returns>
        public TcpStub ReturnsData(string data)
        {
            var fields = new TcpResponseFields
            {
                Data = data
            };

            var response = new IsResponse <TcpResponseFields>(fields);

            return(Returns(response));
        }
Пример #5
0
        /// <summary>
        /// Adds a response to the stub that will return the specified data.
        /// </summary>
        /// <param name="data">The data to be returned</param>
        /// <returns>The stub that the response was added to</returns>
        public TcpStub ReturnsData(string data)
        {
            var fields = new TcpResponseFields
            {
                Data = data
            };

            var response = new IsResponse<TcpResponseFields>(fields);

            return Returns(response);
        }
Пример #6
0
        public void HttpStub_Returns_AddsResponse()
        {
            var expectedResponse = new IsResponse <HttpResponseFields>(new HttpResponseFields());

            var stub = new HttpStub();

            stub.Returns(expectedResponse);

            var response = stub.Responses.First() as IsResponse <HttpResponseFields>;

            Assert.AreEqual(expectedResponse, response);
        }
Пример #7
0
        /// <summary>
        /// Adds a response to the stub with the specified content type
        /// </summary>
        /// <param name="statusCode">The status code to be returned</param>
        /// <param name="headers">The headers for the response</param>
        /// <param name="responseObject">The response object that will be returned as the specified content type</param>
        /// <returns></returns>
        public HttpStub Returns(HttpStatusCode statusCode, IDictionary <string, string> headers, object responseObject)
        {
            var fields = new HttpResponseFields
            {
                StatusCode     = statusCode,
                ResponseObject = responseObject,
                Headers        = headers
            };

            var response = new IsResponse <HttpResponseFields>(fields);

            return(Returns(response));
        }
Пример #8
0
        public void Returns_AddsResponse()
        {
            var headers = new Dictionary <string, string> {
                { "Content-Type", "application/json" }
            };
            var expectedResponse = new IsResponse <HttpResponseFields>(new HttpResponseFields());

            var stub = new HttpStub();

            stub.Returns(expectedResponse);

            var response = stub.Responses.First() as IsResponse <HttpResponseFields>;

            Assert.AreEqual(expectedResponse, response);
        }
Пример #9
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (ServiceId != 0)
            {
                hash ^= ServiceId.GetHashCode();
            }
            if (MethodId != 0)
            {
                hash ^= MethodId.GetHashCode();
            }
            if (Token != 0)
            {
                hash ^= Token.GetHashCode();
            }
            if (ObjectId != 0UL)
            {
                hash ^= ObjectId.GetHashCode();
            }
            if (Size != 0)
            {
                hash ^= Size.GetHashCode();
            }
            if (Status != 0)
            {
                hash ^= Status.GetHashCode();
            }
            hash ^= error_.GetHashCode();
            if (Timeout != 0UL)
            {
                hash ^= Timeout.GetHashCode();
            }
            if (IsResponse != false)
            {
                hash ^= IsResponse.GetHashCode();
            }
            hash ^= forwardTargets_.GetHashCode();
            if (ServiceHash != 0)
            {
                hash ^= ServiceHash.GetHashCode();
            }
            return(hash);
        }
Пример #10
0
        public override bool Equals(object o)
        {
            if (this == o)
            {
                return(true);
            }

            if (o == null || GetType() != o.GetType())
            {
                return(false);
            }

            var that = (DiffContextBO)o;

            return(IsResponse.Equals(that.IsResponse) &&
                   IsRequest.Equals(that.IsRequest) &&
                   URL.Equals(that.URL) &&
                   Parameters.Equals(that.Parameters) &&
                   Method.Equals(that.Method) &&
                   IsRequired.Equals(that.IsRequired));
        }
Пример #11
0
        /// <summary>
        /// Adds a response to the stub with the specified content type
        /// </summary>
        /// <param name="statusCode">The status code to be returned</param>
        /// <param name="headers">The headers for the response</param>
        /// <param name="responseObject">The response object that will be returned as the specified content type</param>
        /// <param name="mode">Response mode: text of binary. Text mode is default</param>
        /// <param name="latencyInMilliseconds">The number of milliseconds to be waiting before response will be returned</param>
        /// <returns>The stub that the response was added to</returns>
        public HttpStub Returns(HttpStatusCode statusCode, IDictionary <string, object> headers, object responseObject,
                                string mode = "text", int?latencyInMilliseconds = null)
        {
            var fields = new HttpResponseFields
            {
                StatusCode     = statusCode,
                ResponseObject = responseObject,
                Headers        = headers,
                Mode           = mode
            };

            var behavior = latencyInMilliseconds.HasValue
                ? new Behavior
            {
                LatencyInMilliseconds = latencyInMilliseconds
            }
                : null;

            var response = new IsResponse <HttpResponseFields>(fields, behavior);

            return(Returns(response));
        }
Пример #12
0
 public void Constructor_SetsStatusCode()
 {
     var expectedFields = new TestResponseFields();
     var response = new IsResponse<TestResponseFields>(expectedFields);
     Assert.AreSame(expectedFields, response.Fields);
 }
Пример #13
0
        public void Returns_AddsResponse()
        {
            var headers = new Dictionary<string, string> { { "Content-Type", "application/json" } };
            var expectedResponse = new IsResponse<HttpResponseFields>(new HttpResponseFields());

            var stub = new HttpStub();
            stub.Returns(expectedResponse);

            var response = stub.Responses.First() as IsResponse<HttpResponseFields>;
            Assert.AreEqual(expectedResponse, response);
        }