Пример #1
22
        public void DoisOkResultIntDiferentesDevemRetornarEqualIgualAFalse()
        {
            OkResult<int> resultDest = new OkResult<int>(0);
            OkResult<int> resultSource = new OkResult<int>(1);

            Assert.IsFalse(resultDest.Equals(resultSource));
        }
Пример #2
0
        public void DoisOkResultIntIguaisDevemRetornarEqualIgualATrue()
        {
            OkResult<int> resultDest = new OkResult<int>(1);
            OkResult<int> resultSource = new OkResult<int>(1);

            Assert.IsTrue(resultDest.Equals(resultSource));
        }
Пример #3
0
        public void SetUp()
        {
            fixture = new MPAuthTester();

            actionWhenAuthorized = new Mock<Func<string, IHttpActionResult>>(MockBehavior.Strict);
            actionWhenNotAuthorized = new Mock<Func<IHttpActionResult>>(MockBehavior.Strict);
            okResult = new OkResult(fixture);

            authType = "auth_type";
            authToken = "auth_token";
            fixture.Request = new HttpRequestMessage();
            fixture.Request.Headers.Authorization = new AuthenticationHeaderValue(authType, authToken);
            fixture.RequestContext = new HttpRequestContext();
        }
Пример #4
0
        public static IHttpActionResult CreateResponse(Session session, HttpRequestMessage request)
        {
            IHttpActionResult response = new OkResult(request);

            if (request.Headers.Accept.Contains(new MediaTypeWithQualityHeaderValue("application/hal+json")))
            {
                response = response.WithContent(CreateHalContent(session,request));
            }
            else
            {
                response = response
                    .WithContent(new StringContent(session.Title + Environment.NewLine + session.Description))
                    .WithLinkHeaders(new List<Link> {SpeakerLinkHelper.CreateLink(request, session.SpeakerId)});
            
                
            }
            return response;
        }