public void TestMe()
        {
            var mockedLoanId       = Guid.NewGuid().ToString();
            var mockedDocumentId   = Guid.NewGuid().ToString();
            var mockedLoanDocument = Payloads.Helper.GetLoanDocument();
            // Mock client and
            var source = _mockedEncompassClient
                         //.SetClientApiResponse((sender, args) =>
                         //{
                         //    args.Should().NotBeNull(because: "Response is null!");
                         //})
                         .SetupResponseMessage(resp =>
            {
                resp.StatusCode = System.Net.HttpStatusCode.OK;
                resp.Content    = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(mockedLoanDocument));
            }, testHeader: new KeyValuePair <string, string>("TestHeader", Faker.Lorem.GetFirstWord()))
                         .SetDocumentsApiResponseCallback(mockedLoanId, (sender, args) =>
            {
                args.Should().NotBeNull(because: "Response is null!");
            })
                         .GetDocumentAsync(mockedDocumentId).ConfigureAwait(false);

            source.Should()
            .NotBeNull();
        }
        public async Task CreateDocumentTestAsync()
        {
            var seed   = Seeds.LoanDocuments.GetLoanDocumentSeed();
            var target = seed.Should <EncompassApi.Loans.Documents.LoanDocument>()
                         .BeSerializable <EncompassApi.Loans.Documents.LoanDocument>(seed);

            target.Should().NotBeNull(because: "Target is null!");
            var documentId = target.DocumentId;

            target.DocumentId = null;
            var mockedLoanId = Guid.NewGuid().ToString();
            var source       = _mockedEncompassClient
                               .SetupResponseMessage(resp =>
            {
                resp.StatusCode       = System.Net.HttpStatusCode.OK;
                resp.Content          = new StringContent(documentId);
                resp.Headers.Location = new Uri("https://www.example.com/" + "xxx.pdf");
            }, testHeader: new KeyValuePair <string, string>("TestHeader", Faker.Lorem.GetFirstWord()))
                               .GetDocumentsApiAsync(mockedLoanId);

            source.ApiResponseEventHandler += (object sender, ApiResponseEventArgs e) =>
            {
            };

            var d = await source.CreateDocumentAsync(target);
        }
        public async Task GetEventsAsyncTestAsync(string methodName, params JObject[] objs)
        {
            _outputWriter.WriteLine("### Starting {0}! ###", methodName);
            var target = objs.Should().BeSerializable <JObject, WebhookEvent>(objs);
            var source = await _mockedEncompassClient.SetupResponseMessage(resp =>
            {
                resp.StatusCode = System.Net.HttpStatusCode.OK;
                resp.Content    = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(target));
            }, testHeader : new KeyValuePair <string, string>("TestHeader", Faker.Lorem.GetFirstWord()))
                         .MockedEncompassClient.Webhook.GetEventsAsync().ConfigureAwait(false);

            source.Should()
            .HaveCount(target.Count())
            .And
            .BeEqual(target, source, (t, s) =>
            {
                return(t.Id.Equals(s.Id));
            });
        }
        public async Task GetResourceEventsByEnumAsyncTestAsync(string methodName, string resourceType, params JObject[] objs)
        {
            _outputWriter.WriteLine("### Starting {0}! with resourcetype {1} ###", methodName, resourceType);
            Enum.TryParse <EncompassApi.Webhook.WebhookResourceType>(resourceType, out WebhookResourceType resourceTypeEnum).Should().Be(true);
            var target = objs.Should().BeSerializable <JObject, WebhookResourceEventObject>(objs);
            var source = await(_mockedEncompassClient.SetupResponseMessage(resp =>
            {
                resp.StatusCode = System.Net.HttpStatusCode.OK;
                resp.Content    = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(target));
            }, testHeader: new KeyValuePair <string, string>("TestResponseHeader", Faker.RandomNumber.Next(10, 9999).ToString())))
                         .MockedEncompassClient.Webhook.GetResourceEventsAsync(resourceTypeEnum).ConfigureAwait(false);


            source.Should()
            .AllBeOfType <WebhookResourceEventObject>()
            .And
            .HaveCount(target.Count())
            .And
            .BeEqual(target, source, (t, s) =>
            {
                return(s.Name.Value.Equals(t.Name.Value, StringComparison.OrdinalIgnoreCase));
            });
        }
Exemple #5
0
        public async Task GetResourcesAsyncTestAsync(string methodName, params JObject[] objs)
        {
            _outputWriter.WriteLine("### Starting {0}! ###", methodName);
            var target = objs.Should().BeSerializable <JObject, WebhookResource>(objs);
            // SET THE EXPECTED RESPONSE AND A HEADER FOR TESTING
            // CALL THE API
            // RETURN THE EXPECTED RESPONSE OBJECT
            var source = await(_mockedEncompassClient.SetupResponseMessage((response) =>
            {
                response.StatusCode = HttpStatusCode.OK;
                response.Content    = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(objs));
            }, testHeader: new KeyValuePair <string, string>("TestResponseHeader", Faker.RandomNumber.Next(10, 9999).ToString())))
                         .MockedEncompassClient.Webhook.GetResourcesAsync();

            source.Should()
            .AllBeOfType <WebhookResource>()
            .And
            .HaveCount(target.Count())
            .And
            .BeEqual(target, source, (t, s) =>
            {
                return(s.Description.Equals(t.Description, StringComparison.OrdinalIgnoreCase));
            });
        }