public void GetStatusOfEnvelopesTest()
        {
            try
            {
                // make sure we have at least one result.
                RequestSignatureOnADocumentTest();

                DateTime fromDate = DateTime.UtcNow;
                fromDate = fromDate.AddDays(-30);
                string fromDateStr = fromDate.ToString("o");

                EnvelopesApi.ListStatusChangesOptions ops = new EnvelopesApi.ListStatusChangesOptions()
                {
                    count = "10",
                    fromDate = fromDateStr
                };
                EnvelopesApi envelopesApi = new EnvelopesApi();
                EnvelopesInformation envInfo = envelopesApi.ListStatusChanges(TestConfig.AccountId, ops);
                Assert.IsNotNull(envInfo);
                Assert.IsNotNull(envInfo.ResultSetSize);
                int resultSetSize = int.Parse(envInfo.ResultSetSize);
                Assert.IsTrue(resultSetSize > 0);
                Trace.WriteLine(envInfo.ToJson());
            }
            catch (DocuSign.eSign.Client.ApiException apiEx)
            {
                Assert.IsNotNull(apiEx.ErrorCode);
                Assert.IsTrue(!string.IsNullOrWhiteSpace(apiEx.Message));
                Assert.IsTrue(false, "Failed with ErrorCode: " + apiEx.ErrorCode + ", Message: " + apiEx.Message);
            }
        }
        public void GetDocumentListDownloadDocumentTest()
        {
            try
            {
                RequestSignatureOnADocumentTest();
                Assert.IsNotNull(TestConfig.AccountId);
                Assert.IsNotNull(TestConfig.EnvelopeId);

                EnvelopesApi envelopesApi = new EnvelopesApi();

                DateTime fromDate = DateTime.UtcNow;
                fromDate = fromDate.AddDays(-5);

                EnvelopesApi.ListStatusChangesOptions ops = new EnvelopesApi.ListStatusChangesOptions()
                {
                    count = "10",
                    fromDate = fromDate.ToString()
                };

                EnvelopesInformation eInfo = envelopesApi.ListStatusChanges(TestConfig.AccountId, ops);
                Assert.IsNotNull(eInfo);
                Assert.IsTrue(!string.IsNullOrEmpty(eInfo.ResultSetSize) && int.Parse(eInfo.ResultSetSize) > 0);

                string envelopeId = eInfo.Envelopes[0].EnvelopeId;
                EnvelopeDocumentsResult envDocsResult = envelopesApi.ListDocuments(TestConfig.AccountId, envelopeId);
                Assert.IsNotNull(envDocsResult);
                int docCount = envDocsResult.EnvelopeDocuments.Count;
                Assert.IsTrue(docCount > 0);

                MemoryStream docStream = (MemoryStream)envelopesApi.GetDocument(TestConfig.AccountId, envelopeId, envDocsResult.EnvelopeDocuments[0].DocumentId);

                string filePath = Path.GetTempPath() + Path.GetRandomFileName() + ".pdf";

                FileStream fs = new FileStream(filePath, FileMode.Create);
                docStream.Seek(0, SeekOrigin.Begin);
                docStream.CopyTo(fs);
                fs.Close();
                System.Diagnostics.Process.Start(filePath);

            }

            catch (DocuSign.eSign.Client.ApiException apiEx)
            {
                Assert.IsNotNull(apiEx.ErrorCode);
                Assert.IsTrue(!string.IsNullOrWhiteSpace(apiEx.Message));
                Assert.IsTrue(false, "Failed with ErrorCode: " + apiEx.ErrorCode + ", Message: " + apiEx.Message);
            }
        }