Exemplo n.º 1
0
        public async Task ReturnsBadRequestWithInvalidCategory()
        {
            var fixture = new Fixture();

            var testShift = fixture.Build <NewJob>()
                            .With(j => j.Age, 1)
                            .With(j => j.Category, 10)
                            .Create();

            var body       = JsonConvert.SerializeObject(testShift);
            var bodyArray  = Encoding.UTF8.GetBytes(body);
            var bodyStream = new MemoryStream(bodyArray);

            var shiftService = new Mock <IShiftService>(MockBehavior.Strict).Object;

            var function = new LogJob(shiftService, AuthenticationHelperMock.GetAuthenticationHelper());

            var request = new DefaultHttpRequest(new DefaultHttpContext());

            request.Headers.Add("Authorization", AuthenticationHelperMock.GoodHeader);
            request.Body = bodyStream;

            var result = await function.Run(request, NullLogger.Instance);

            result.Should().BeOfType <BadRequestResult>();
        }
Exemplo n.º 2
0
        public async Task ReturnsUnauthorisedWithNoClaims()
        {
            var shiftService = new Mock <IShiftService>(MockBehavior.Strict).Object;

            var function = new LogJob(shiftService, AuthenticationHelperMock.GetAuthenticationHelper());

            var request = new DefaultHttpRequest(new DefaultHttpContext());

            var result = await function.Run(request, NullLogger.Instance);

            result.Should().BeOfType <UnauthorizedResult>();
        }