Example #1
0
        public void Creating_WithGivenBusinessId_GetsCorrectToken()
        {
            var token = new OrganizationTokenStubBuilder().Build();
            var sut   = new PartnerApiRequestBuilder()
                        .WithCurrentOrganization(new CurrentOrganizationStubBuilder().WithBusinessId("1234567-1").Build())
                        .WithOrganizationToken(token)
                        .Build();

            sut.Create(new ResourceBaseBuilder()).Wait();

            token.Received(1).Get("1234567-1");
        }
        public void AskingOrganization_WithFirstTime_GetsItFromDecorated()
        {
            var decorated = new OrganizationTokenStubBuilder().WithGet("xxx").Build();
            var sut       = new MemoryCachedOrganizationTokenBuilder()
                            .WithOrganization(decorated)
                            .Build();

            var actual = sut.Get("6136813-2").Result;

            Assert.AreEqual("xxx", actual);
            decorated.Received(1).Get("6136813-2");
        }
Example #3
0
        public void Creating_WithoutOrganizationBeingDefined_SetsUriCorrectly(string businessId)
        {
            var token = new OrganizationTokenStubBuilder().Build();
            var sut   = new PartnerApiRequestBuilder()
                        .WithEndpoint(new EndpointStubBuilder().WithUri("https://sign.visma.net/").Build())
                        .WithCurrentOrganization(new CurrentOrganizationStubBuilder().WithBusinessId(businessId).Build())
                        .Build();

            var actual = sut.Create(new ResourceBaseBuilder().WithResourceUri("api/v1/organization?business_id=1234567-1")).Result.RequestUri.ToString();

            Assert.AreEqual("https://sign.visma.net/api/v1/organization?business_id=1234567-1", actual);
            token.Received(0).Get(Arg.Any <string>());
        }