public void RoleBasedInvite()
        {
            string randomEmail = "lukeskywalker" + DateTime.Now.ToBinary().ToString() + "@mailinator.com";
            User user = new User();
            user.Email = randomEmail;
            user.Password = "******";
            user.FirstName = "firstName";
            user.LastName = "LastName";

            User resultUser = cudasign.userService.Create(user);

            Assert.IsNotNull("No user id from creating user", resultUser.Id);
            resultUser.Password = "******";

            Oauth2Token requestedToken = cudasign.authenticationService.RequestToken(resultUser);
            Assert.IsNotNull("Access Token", requestedToken.AccessToken);

            Document doc = new Document();
            if (Directory.Exists(InputdirPath))
            {
                string[] DocFilePath = Directory.GetFiles(@InputdirPath);
                doc.FilePath = DocFilePath[0];
            }

            Document document = cudasign.documentService.Create(requestedToken, doc);
            Assert.IsNotNull("DocumentId", document.Id);

            // Build the data for Texts Test
            Text text = new Text();
            text.Size = 30;
            text.X = 61;
            text.Y = 72;
            text.PageNumber = 0;
            text.Font = "Arial";
            text.Data = "A SAMPLE TEXT FIELD";
            text.LineHeight = 9.075;

            Text text1 = new Text();
            text1.Size = 30;
            text1.X = 61;
            text1.Y = 72;
            text1.PageNumber = 1;
            text1.Font = "Arial";
            text1.Data = "A SAMPLE TEXT FIELD 2";
            text1.LineHeight = 9.075;

            List<Fields> textsList = new List<Fields>();
            textsList.Add(text);
            textsList.Add(text1);

            // Build the data for Checks
            Checkbox checks = new Checkbox();
            checks.Width = 20;
            checks.Height = 20;
            checks.X = 234;
            checks.Y = 500;
            checks.PageNumber = 0;

            Checkbox checks1 = new Checkbox();
            checks1.Width = 20;
            checks1.Height = 20;
            checks1.X = 200;
            checks1.Y = 53;
            checks.PageNumber = 1;

            List<Fields> checksList = new List<Fields>();
            checksList.Add(checks);
            checksList.Add(checks1);

            // Creating the Fields

            Radio radiobutton = new Radio();
            radiobutton.PageNumber = 1;
            radiobutton.X = 150;
            radiobutton.Y = 65;
            radiobutton.Width = 40;
            radiobutton.Height = 40;
            radiobutton.Check = 0;
            radiobutton.Value = "apple";
            radiobutton.Created = "123456789";

            Radio radiobutton1 = new Radio();
            radiobutton1.PageNumber = 1;
            radiobutton1.X = 250;
            radiobutton1.Y = 55;
            radiobutton1.Width = 40;
            radiobutton1.Height = 40;
            radiobutton1.Check = 0;
            radiobutton1.Value = "cherry";
            radiobutton1.Created = "123456789";

            List<Fields> radioList = new List<Fields>();
            radioList.Add(radiobutton);
            radioList.Add(radiobutton1);

            Fields fields = new Fields();
            fields.X = 13;
            fields.Y = 133;
            fields.Width = 25;
            fields.Height = 121;
            fields.PageNumber = 1;
            fields.Role = "signer";
            fields.Required = true;
            fields.Type = "radiobutton";
            fields.Radio = radioList;

            Fields fields1 = new Fields();
            fields1.X = 20;
            fields1.Y = 133;
            fields1.Width = 122;
            fields1.Height = 60;
            fields1.PageNumber = 0;
            fields1.Role = "buyer";
            fields1.Required = true;
            fields1.Type = "initials";

            Fields fields2 = new Fields();
            fields2.X = 35;
            fields2.Y = 133;
            fields2.Width = 122;
            fields2.Height = 60;
            fields2.PageNumber = 1;
            fields2.Role = "TestingRole";
            fields2.Required = true;
            fields2.Type = "text";

            List<Fields> fieldsList = new List<Fields>();
            fieldsList.Add(fields);
            fieldsList.Add(fields1);
            fieldsList.Add(fields2);

            Dictionary<string, List<Fields>> fieldsMap = new Dictionary<string, List<Fields>>();
            fieldsMap.Add("texts", textsList);
            fieldsMap.Add("checks", checksList);
            fieldsMap.Add("fields", fieldsList);

            Document resultDoc = cudasign.documentService.UpdateDocument(requestedToken, fieldsMap, document.Id);
            Document getDoc = cudasign.documentService.GetDocumentbyId(requestedToken, resultDoc.Id);

            Fields[] flds = getDoc.Fields;
            List<System.Collections.Hashtable> roleMapList = new List<System.Collections.Hashtable>();
            EmailSignature emailSignature = new EmailSignature();
            int counter = 0;
            //iterate over fields
            for(int i=0;i<flds.Length;i++)
            {
                string toEmail = "deepak" + DateTime.Now.ToBinary().ToString() + "@mailinator.com";
                    System.Collections.Hashtable roleMap = new System.Collections.Hashtable();
                    roleMap.Add("email", toEmail);
                    roleMap.Add("role_id", flds[i].RoleId);
                    roleMap.Add("role", flds[i].Role);
                    roleMap.Add("order", ++counter);
                 roleMapList.Add(roleMap);
            }
            emailSignature.To = roleMapList;
            emailSignature.From = resultUser.Email;
            string[] ccuser = new string[] { "*****@*****.**", "*****@*****.**" };
            emailSignature.CC = ccuser;
            emailSignature.Message = resultUser.Email + " asked you to sign this document";
            emailSignature.Subject = "SignNow Invitation";

            string resinvite = cudasign.documentService.RoleBasedInvite(requestedToken, emailSignature, document.Id);
            Assert.AreEqual("success", resinvite);
        }
        public void UpdateDocument()
        {
            string randomEmail = "lukeskywalker" + DateTime.Now.ToBinary().ToString() + "@mailinator.com";
            User user = new User();
            user.Email = randomEmail;
            user.Password = "******";
            user.FirstName = "firstName";
            user.LastName = "LastName";

            User resultUser = cudasign.userService.Create(user);

            Assert.IsNotNull("No user id from creating user", resultUser.Id);
            resultUser.Password = "******";

            Oauth2Token requestedToken = cudasign.authenticationService.RequestToken(resultUser);
            Assert.IsNotNull("Access Token", requestedToken.AccessToken);

            Document doc = new Document();
            if (Directory.Exists(InputdirPath))
            {
                string[] DocFilePath = Directory.GetFiles(@InputdirPath);
                doc.FilePath = DocFilePath[0];
            }

            Document document = cudasign.documentService.Create(requestedToken, doc);
            Assert.IsNotNull("DocumentId", document.Id);

            // Build the data for Texts Test
            Text text = new Text();
            text.Size = 30;
            text.X = 61;
            text.Y = 72;
            text.PageNumber = 0;
            text.Font = "Arial";
            text.Data = "A SAMPLE TEXT FIELD";
            text.LineHeight = 9.075;

            Text text1 = new Text();
            text1.Size = 30;
            text1.X = 61;
            text1.Y = 72;
            text1.PageNumber = 1;
            text1.Font = "Arial";
            text1.Data = "A SAMPLE TEXT FIELD 2";
            text1.LineHeight = 9.075;

            List<Fields> textsList = new List<Fields>();
            textsList.Add(text);
            textsList.Add(text1);

            // Build the data for Checks
            Checkbox checks = new Checkbox();
            checks.Width = 20;
            checks.Height = 20;
            checks.X = 234;
            checks.Y = 500;
            checks.PageNumber = 0;

            Checkbox checks1 = new Checkbox();
            checks1.Width = 20;
            checks1.Height = 20;
            checks1.X = 200;
            checks1.Y = 53;
            checks.PageNumber = 1;

            List<Fields> checksList = new List<Fields>();
            checksList.Add(checks);
            checksList.Add(checks1);

            // Creating the Fields

            Radio radiobutton = new Radio();
            radiobutton.PageNumber = 1;
            radiobutton.X = 150;
            radiobutton.Y = 65;
            radiobutton.Width = 40;
            radiobutton.Height = 40;
            radiobutton.Check = 0;
            radiobutton.Value = "apple";
            radiobutton.Created = "123456789";

            Radio radiobutton1 = new Radio();
            radiobutton1.PageNumber = 1;
            radiobutton1.X = 250;
            radiobutton1.Y = 55;
            radiobutton1.Width = 40;
            radiobutton1.Height = 40;
            radiobutton1.Check = 0;
            radiobutton1.Value = "cherry";
            radiobutton1.Created = "123456789";

            List<Fields> radioList = new List<Fields>();
            radioList.Add(radiobutton);
            radioList.Add(radiobutton1);

            Fields fields = new Fields();
            fields.X = 13;
            fields.Y = 133;
            fields.Width = 25;
            fields.Height = 121;
            fields.PageNumber = 1;
            fields.Role = "buyer";
            fields.Required = true;
            fields.Type = "radiobutton";
            fields.Radio = radioList;

            List<Fields> fieldsList = new List<Fields>();
            fieldsList.Add(fields);

            Dictionary<string, List<Fields>> fieldsMap = new Dictionary<string, List<Fields>>();
            fieldsMap.Add("texts", textsList);
            fieldsMap.Add("checks", checksList);
            fieldsMap.Add("fields", fieldsList);

            Document resultDoc = cudasign.documentService.UpdateDocument(requestedToken, fieldsMap, document.Id);

            Assert.IsNotNull("DocumentId", document.Id);
        }