예제 #1
0
        public async Task cannot_delete_existing_agent_profile_with_invalid_etag()
        {
            // Arrange
            var state = new AgentProfileDocument <string>()
            {
                Content = "foo",
                ETag    = ETAG
            };
            var request = DeleteAgentProfileRequest.Create(state);

            request.Agent = new Agent()
            {
                Name = AGENT_NAME,
                MBox = new Uri(AGENT_MBOX)
            };
            request.ProfileId = PROFILE_ID;
            this._mockHttp
            .When(HttpMethod.Delete, this.GetApiUrl("agents/profile"))
            .WithQueryString("agent", AGENT_QS)
            .WithQueryString("profileId", PROFILE_ID)
            .WithHeaders("If-Match", ETAG)
            .Respond(HttpStatusCode.PreconditionFailed);

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

            // Assert
            result.Should().BeFalse();
        }
예제 #2
0
        public async Task can_delete_existing_agent_profile()
        {
            // Arrange
            var state = new AgentProfileDocument <string>()
            {
                Content = "foo"
            };
            var request = DeleteAgentProfileRequest.Create(state);

            request.Agent = new Agent()
            {
                Name = AGENT_NAME,
                MBox = new Uri(AGENT_MBOX)
            };
            request.ProfileId = PROFILE_ID;
            this._mockHttp
            .When(HttpMethod.Delete, this.GetApiUrl("agents/profile"))
            .WithQueryString("agent", AGENT_QS)
            .WithQueryString("profileId", PROFILE_ID)
            .With(x => x.Headers.IfNoneMatch.Count == 0 && x.Headers.IfMatch.Count == 0)
            .Respond(HttpStatusCode.NoContent);

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

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