Пример #1
0
        public async Task can_request_activity_that_does_not_exist()
        {
            // Arrange
            var request = new GetActivityRequest()
            {
                ActivityId = new Uri(ACTIVITY_ID)
            };

            this._mockHttp
            .When(HttpMethod.Get, this.GetApiUrl("activities"))
            .WithQueryString("activityId", ACTIVITY_ID)
            .Respond(HttpStatusCode.NotFound);

            // Act
            Activity activity = await this._client.Activities.Get(request);

            // Assert
            activity.Should().BeNull();
        }
Пример #2
0
        public void cannot_get_activity_when_unauthorized()
        {
            // Arrange
            var request = new GetActivityRequest()
            {
                ActivityId = new Uri(ACTIVITY_ID)
            };

            this._mockHttp
            .When(HttpMethod.Get, this.GetApiUrl("activities"))
            .WithQueryString("activityId", ACTIVITY_ID)
            .Respond(HttpStatusCode.Forbidden);

            // Act
            Func <Task> action = async() =>
            {
                await this._client.Activities.Get(request);
            };

            // Assert
            action.ShouldThrow <ForbiddenException>();
        }
Пример #3
0
        public async Task can_get_activity()
        {
            // Arrange
            var request = new GetActivityRequest()
            {
                ActivityId = new Uri(ACTIVITY_ID)
            };

            this._mockHttp
            .When(HttpMethod.Get, this.GetApiUrl("activities"))
            .WithQueryString("activityId", ACTIVITY_ID)
            .Respond(HttpStatusCode.OK, "application/json", this.ReadDataFile(Constants.ACTIVITY));

            // Act
            Activity activity = await this._client.Activities.Get(request);

            // Assert
            activity.Should().NotBeNull();
            activity.Id.Should().Be(request.ActivityId);
            activity.Definition.Should().NotBeNull();
            activity.Definition.Extensions.Should().NotBeNull().And.NotBeEmpty();
        }
Пример #4
0
        public async Task <List <Activity> > Activity(GetActivityRequest req)
        {
            //var userId = (string)HttpContext.Items["User"];
            //UserDetailsRequest userDetailsRequest2 = new UserDetailsRequest();
            //userDetailsRequest2.id = userId;

            //var userDetails = await _kistService.UsersDetails(userDetailsRequest2);


            //userDetailsRequest.id = userDetails.ID.ToString();


            ////UserDetailsRequest userDetailsRequest3 = new UserDetailsRequest();
            //    userDetailsRequest.id = userDetails.ID.ToString();

            /*var req = new GetActivityRequest();
             */
            req.operatorId = 1;
            //  req.maxrows = 2;
            req.fromDate = DateTime.Now;
            req.toDate   = DateTime.Now;
            return(await _kistService.GetActivity(req));
        }
Пример #5
0
        async Task <Activity> IActivitiesApi.Get(GetActivityRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            request.Validate();

            var options = new RequestOptions(ENDPOINT);

            options.QueryStringParameters.Add("activityId", request.ActivityId.ToString());

            try
            {
                HttpResponseMessage response = await this._client.GetJson(options);

                return(await response.Content.ReadAsAsync <Activity>(new[] { new StrictJsonMediaTypeFormatter() }));
            }
            catch (NotFoundException)
            {
                return(null);
            }
        }
        public GetActivityResponse getActivity()
        {
            GetActivityRequest request = new GetActivityRequest();

            return(client.Execute(request));
        }