コード例 #1
0
        public void SendingRequest_WithGivenResource_CallsRequestCorrectly()
        {
            var expected = new ResourceBaseBuilder().Build();
            var request  = new ApiRequestStubBuilder().Build();
            var sut      = new SignClientBuilder().WithRequest(request).Build();

            sut.SendRequest <object>(expected).Wait();

            request.Received(1).Create(expected);
        }
コード例 #2
0
        public void Creating_WithResource_SetsRequestValuesCorrectly()
        {
            var resource = new ResourceBaseBuilder().WithMethod(HttpMethod.Delete).WithRequestBody(new { Value = true });
            var sut      = new PartnerApiRequestBuilder().Build();

            var actual = sut.Create(resource).Result;

            Assert.AreEqual(HttpMethod.Delete, actual.Method);
            Assert.AreEqual("{\"Value\":true}", actual.Content.ReadAsStringAsync().Result);
        }
コード例 #3
0
        public void SendingRequest_WithResponse_ReturnsExpected()
        {
            var expected = new ResourceBaseBuilder().Build();
            var sut      = new SignClientBuilder()
                           .WithResponse(new ApiResponseStubBuilder <ResourceBase>().WithGetResponse(expected).Build())
                           .Build();

            var actual = sut.SendRequest <ResourceBase>(new ResourceBaseBuilder()).Result;

            Assert.AreEqual(expected, actual);
        }
        public void Creating_WithEndpointAndResource_SetsUriCorrectly()
        {
            var resource = new ResourceBaseBuilder().WithResourceUri("api/v1/document");
            var sut      = new OrganizationApiRequestBuilder()
                           .WithEndpoint(new EndpointStubBuilder().WithUri("https://sign.visma.net").Build())
                           .Build();

            var actual = sut.Create(resource).Result.RequestUri.ToString();

            Assert.AreEqual("https://sign.visma.net/api/v1/document", actual);
        }
        public void Creating_WithResourceHavingContent_SetsAuthorizationCorrectly()
        {
            var resource = new ResourceBaseBuilder().WithMethod(HttpMethod.Post).WithResourceUri("api/v1/document").WithRequestBody(new { message = "example" });
            var sut      = new OrganizationApiRequestBuilder()
                           .WithCredentials(new CredentialsStubBuilder().WithIdentifier("identifier").WithSecret("").Build())
                           .WithTime(new TimeProviderStubBuilder().WithUtcNow(new DateTime(2019, 1, 1)).Build())
                           .Build();

            var actual = sut.Create(resource).Result.Headers.Authorization.ToString();

            Assert.AreEqual("Onnistuu identifier:+cnVjVc6+cj39lQ7MpJi4SgPaxqW+AsEU6ndAouSPGWVU5DoU9GUeIgAQih+rbktFE4jV6+r91WnG2mfnkdDmA==", actual);
        }