Esempio n. 1
0
        public async Task cannot_delete_existing_state_with_invalid_etag()
        {
            // Arrange
            var state = new StateDocument <string>()
            {
                Content = "foo",
                ETag    = ETAG
            };
            var request = DeleteStateRequest.Create(state);

            request.ActivityId = new Uri(ACTIVITY_ID);
            request.Agent      = new Agent()
            {
                Name = AGENT_NAME,
                MBox = new Uri(AGENT_MBOX)
            };
            request.Registration = REGISTRATION;
            request.StateId      = STATE_ID;
            this._mockHttp
            .When(HttpMethod.Delete, this.GetApiUrl("activities/state"))
            .WithQueryString("activityId", ACTIVITY_ID)
            .WithQueryString("agent", AGENT_QS)
            .WithQueryString("registration", REGISTRATION.ToString())
            .WithQueryString("stateId", STATE_ID)
            .WithHeaders("If-Match", ETAG)
            .Respond(HttpStatusCode.PreconditionFailed);

            // Act
            bool result = await this._client.States.Delete(request);

            // Assert
            result.Should().BeFalse();
        }
Esempio n. 2
0
        public async Task can_delete_existing_state()
        {
            // Arrange
            var state = new StateDocument <string>()
            {
                Content = "foo"
            };
            var request = DeleteStateRequest.Create(state);

            request.ActivityId = new Uri(ACTIVITY_ID);
            request.Agent      = new Agent()
            {
                Name = AGENT_NAME,
                MBox = new Uri(AGENT_MBOX)
            };
            request.Registration = REGISTRATION;
            request.StateId      = STATE_ID;
            this._mockHttp
            .When(HttpMethod.Delete, this.GetApiUrl("activities/state"))
            .WithQueryString("activityId", ACTIVITY_ID)
            .WithQueryString("agent", AGENT_QS)
            .WithQueryString("registration", REGISTRATION.ToString())
            .WithQueryString("stateId", STATE_ID)
            .With(x => x.Headers.IfNoneMatch.Count == 0 && x.Headers.IfMatch.Count == 0)
            .Respond(HttpStatusCode.NoContent);

            // Act
            bool result = await this._client.States.Delete(request);

            // Assert
            result.Should().BeTrue();
        }