public void JwtLoginTest()
        {
            testConfig.ApiClient = new ApiClient(testConfig.Host);
            testConfig.ApiClient.ConfigureJwtAuthorizationFlow(testConfig.IntegratorKey, testConfig.UserId, testConfig.OAuthBasePath, testConfig.PrivateKeyFilename, testConfig.ExpiresInHours);

            // the authentication api uses the apiClient (and X-DocuSign-Authentication header) that are set in Configuration object
            AuthenticationApi authApi   = new AuthenticationApi(testConfig.ApiClient.Configuration);
            LoginInformation  loginInfo = authApi.Login();

            Assert.IsNotNull(loginInfo);
            Assert.IsNotNull(loginInfo.LoginAccounts);

            // find the default account for this user
            foreach (LoginAccount loginAcct in loginInfo.LoginAccounts)
            {
                if (loginAcct.IsDefault == "true" || testConfig.AccountId == null)
                {
                    testConfig.AccountId = loginAcct.AccountId;

                    string[] separatingStrings = { "/v2" };

                    // Update ApiClient with the new base url from login call
                    testConfig.ApiClient = new ApiClient(loginAcct.BaseUrl.Split(separatingStrings, StringSplitOptions.RemoveEmptyEntries)[0]);
                    //testConfig.Configuration = config;
                    break;
                }
            }
            Assert.IsNotNull(testConfig.AccountId);
        }
Exemple #2
0
        public void JwtRequestSignatureFromTemplateTest()
        {
            EnvelopeDefinition envDef = new EnvelopeDefinition();

            envDef.EmailSubject = "[DocuSign C# SDK] - Please sign this doc";

            // assign recipient to template role by setting name, email, and role name.  Note that the
            // template role name must match the placeholder role name saved in your account template.
            TemplateRole tRole = new TemplateRole();

            tRole.Email    = testConfig.RecipientEmail;
            tRole.Name     = testConfig.RecipientName;
            tRole.RoleName = testConfig.TemplateRoleName;

            List <TemplateRole> rolesList = new List <TemplateRole>()
            {
                tRole
            };

            // add the role to the envelope and assign valid templateId from your account
            envDef.TemplateRoles = rolesList;
            envDef.TemplateId    = testConfig.TemplateId;

            // set envelope status to "sent" to immediately send the signature request
            envDef.Status = "sent";

            // |EnvelopesApi| contains methods related to creating and sending Envelopes (aka signature requests)
            EnvelopesApi    envelopesApi    = new EnvelopesApi(testConfig.ApiClient.Configuration);
            EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(testConfig.AccountId, envDef);

            Assert.IsNotNull(envelopeSummary);
            Assert.IsNotNull(envelopeSummary.EnvelopeId);

            testConfig.EnvelopeId = envelopeSummary.EnvelopeId;
        }
        public IEnumerator JohnCanLogIn()
        {
            yield return(OnFacet <AuthenticationFacet> .Call(
                             nameof(AuthenticationFacet.Login),
                             "John"
                             ).AsCoroutine());

            yield return(OnFacet <AuthenticationFacet> .Call <PlayerEntity>(
                             nameof(AuthenticationFacet.GetPlayer)
                             ).Then(p => {
                Assert.AreEqual("John", p.name);
            }).AsCoroutine());

            yield return(OnFacet <AuthenticationFacet> .Call <bool>(
                             nameof(AuthenticationFacet.Check)
                             ).Then(c => {
                Assert.IsTrue(c);
            }).AsCoroutine());

            yield return(OnFacet <AuthenticationFacet> .Call <string>(
                             nameof(AuthenticationFacet.Id)
                             ).Then(id => {
                Assert.IsNotNull(id);
            }).AsCoroutine());
        }
Exemple #4
0
        public void JwtLoginTest()
        {
            testConfig.ApiClient = new ApiClient(testConfig.Host);
            string privateKey = File.ReadAllText(testConfig.PrivateKeyFilename);

            OAuth.OAuthToken tokenInfo = testConfig.ApiClient.ConfigureJwtAuthorizationFlowByKey(testConfig.IntegratorKey, testConfig.UserId, testConfig.OAuthBasePath, privateKey, testConfig.ExpiresInHours);

            // the authentication api uses the apiClient (and X-DocuSign-Authentication header) that are set in Configuration object
            OAuth.UserInfo userInfo = testConfig.ApiClient.GetUserInfo(tokenInfo.access_token);

            Assert.IsNotNull(userInfo);
            Assert.IsNotNull(userInfo.GetAccounts());

            foreach (var item in userInfo.GetAccounts())
            {
                if (item.GetIsDefault() == "true")
                {
                    testConfig.AccountId = item.AccountId();
                    testConfig.ApiClient = new ApiClient(item.GetBaseUri() + "/restapi");
                    break;
                }
            }

            Assert.IsNotNull(testConfig.AccountId);
        }
Exemple #5
0
        public void DefaultProjectionIsWgs84Test()
        {
            Map map = new Map();

            Assert.IsNotNull(map.Projection);
            Assert.AreEqual(map.Projection, KnownCoordinateSystems.Geographic.World.WGS1984);
        }
        public void LegacyLoginTest()
        {
            string authHeader = "{\"Username\":\"" + testConfig.Username + "\", \"Password\":\"" + testConfig.Password + "\", \"IntegratorKey\":\"" + testConfig.IntegratorKey + "\"}";

            testConfig.ApiClient = new ApiClient(testConfig.Host);
            if (testConfig.ApiClient.Configuration.DefaultHeader.ContainsKey("X-DocuSign-Authentication"))
            {
                testConfig.ApiClient.Configuration.DefaultHeader.Remove("X-DocuSign-Authentication");
            }
            testConfig.ApiClient.Configuration.AddDefaultHeader("X-DocuSign-Authentication", authHeader);

            // the authentication api uses the apiClient (and X-DocuSign-Authentication header) that are set in Configuration object

            AuthenticationApi authApi   = new AuthenticationApi(testConfig.ApiClient.Configuration);
            LoginInformation  loginInfo = authApi.Login();

            Assert.IsNotNull(loginInfo);
            Assert.IsNotNull(loginInfo.LoginAccounts);

            // find the default account for this user
            foreach (LoginAccount loginAcct in loginInfo.LoginAccounts)
            {
                if (loginAcct.IsDefault == "true" || testConfig.AccountId == null)
                {
                    testConfig.AccountId = loginAcct.AccountId;

                    string[] separatingStrings = { "/v2" };

                    // Update ApiClient with the new base url from login call
                    testConfig.ApiClient = new ApiClient(loginAcct.BaseUrl.Split(separatingStrings, StringSplitOptions.RemoveEmptyEntries)[0]);
                    break;
                }
            }
            Assert.IsNotNull(testConfig.AccountId);
        }
Exemple #7
0
        public void Constructor_Name_Value()
        {
            // This function tests a constructor that accepts
            // a name and initial value.

            vCardProperty property = new vCardProperty("NAME", "VALUE");

            Assert.AreEqual(
                "NAME",
                property.Name,
                "The name is incorrect.");

            Assert.AreEqual(
                "VALUE",
                property.Value,
                "The value is incorrect.");

            Assert.IsNotNull(
                property.Subproperties,
                "The subproperties collection was not created.");

            Assert.IsEmpty(
                property.Subproperties,
                "The subproperties collection should be empty.");
        }
Exemple #8
0
        public void JwtCreateEmbeddedSigningViewTest()
        {
            JwtRequestSignatureOnDocumentTest();

            // |EnvelopesApi| contains methods related to creating and sending Envelopes (aka signature requests)
            EnvelopesApi envelopesApi = new EnvelopesApi(testConfig.ApiClient.Configuration);

            RecipientViewRequest viewOptions = new RecipientViewRequest()
            {
                ReturnUrl            = testConfig.ReturnUrl,
                ClientUserId         = "1234", // must match clientUserId set in step #2!
                AuthenticationMethod = "email",
                UserName             = testConfig.RecipientName,
                Email = testConfig.RecipientEmail
            };

            // create the recipient view (aka signing URL)
            ViewUrl recipientView = envelopesApi.CreateRecipientView(testConfig.AccountId, testConfig.EnvelopeId, viewOptions);

            Assert.IsNotNull(recipientView);

            // Start the embedded signing session
            System.Diagnostics.Process.Start(recipientView.Url);

            Assert.IsNotNull(recipientView.Url);
        }
Exemple #9
0
        protected override void RunTestLog(log4net.ILog log)
        {
            log4net.GlobalContext.Properties["custom"] = new Custom();
            try
            {
                log.Info("First");
                log.Info("Second");

                var events = GetEventStrings(log.Logger);

                Assert.AreEqual(2, events.Length, "events Count");

                var le1 = events.First();
                var le2 = events.Last();

                Assert.IsNotNull(le1, "loggingevent 1");
                Assert.IsNotNull(le2, "loggingevent 2");

                Assert.AreEqual(@"{""message"":""First"",""custom"":{""Text"":""Number 0"",""Number"":1}}" + Environment.NewLine, le1, "le1 has structured message");
                Assert.AreEqual(@"{""message"":""Second"",""custom"":{""Text"":""Number 2"",""Number"":3}}" + Environment.NewLine, le2, "le2 has structured message");
            }
            finally
            {
                log4net.GlobalContext.Properties.Remove("custom");
            }
        }
        protected override void RunTestLog(log4net.ILog log)
        {
            using (log4net.ThreadContext.Stacks["NDC"].Push("TestLog"))
            {
                log4net.ThreadContext.Properties["data"] = new { A = 1, B = new { X = "Y" } };

                using (log4net.ThreadContext.Stacks["NDC"].Push("sub section"))
                {
                    log.Info("OK");
                }
            };

            var events = GetEventStrings(log.Logger);

            Assert.AreEqual(1, events.Length, "events Count");

            var le = events.Single();

            Assert.IsNotNull(le, "loggingevent");

            StringAssert.Contains(@"""data"":{", le, "le2 has structured message");
            StringAssert.Contains(@"""X"":""Y""", le, "le2 has structured message");
            StringAssert.Contains(@"""A"":1", le, "le2 has structured message");

            StringAssert.Contains(@"""TestLog sub section""", le, "le1 has structured message");

            StringAssert.DoesNotContain(@"""exception""", le, "le2 has no exception");
        }
Exemple #11
0
        protected override void RunTestLog(log4net.ILog log)
        {
            log4net.GlobalContext.Properties["OurCompany.ApplicationName"] = "fubar";

            log.Info(4);

            var events = GetEventStrings(log.Logger);

            Assert.AreEqual(1, events.Length, "events Count");

            var le = events.Single();

            Assert.IsNotNull(le, "loggingevent");

            var procid = Process.GetCurrentProcess().Id;

            StringAssert.StartsWith(@"{""OurCompany.ApplicationName"":""fubar""", le, "log line");
            StringAssert.Contains(@",""Host"":{", le, "log line");
            StringAssert.Contains(@"""ProcessId"":" + procid, le, "log line");
            StringAssert.Contains(@"""HostName"":""" + Environment.MachineName + @"""", le, "log line");
            StringAssert.Contains(@"""A"":""L-INFO-log4net.Ext.Json.Xunit.Layout.Arrangements.Members""", le, "log line");
            StringAssert.Contains(@"""B"":""" + DateTime.Now.Year + @"""", le, "log line");
            StringAssert.Contains(@"""App"":""", le, "log line");

            // fix #3, do not use member name as a default value
            StringAssert.DoesNotContain("empty1", le);
            StringAssert.DoesNotContain("empty2", le);
        }
 public void EmptyCollectionPropertyCollectionResolveStateIsPersistent() {
     var relativesAdapter = GetAdaptedRelatives(GetPerson(2));
     Assert.IsTrue(relativesAdapter.ResolveState.IsPersistent(), "should be persistent");
     //  Assert.IsFalse(relativesAdapter.ResolveState.IsResolved(), "should not be resolved");
     Assert.IsNotNull(relativesAdapter.Oid, "is  null");
     Assert.IsInstanceOf(typeof (IAggregateOid), relativesAdapter.Oid, "is not aggregate");
 }
        protected override void RunTestLog(log4net.ILog log)
        {
            var appenders = GetAppenders <TestAppender>(log.Logger);

            Assert.AreEqual(1, appenders.Length, "appenders Count");

            var tapp = appenders.Single();

            Assert.IsInstanceOf <SerializedLayout>(tapp.Layout, "layout type");
            var layout = ((SerializedLayout)tapp.Layout);

            Assert.IsInstanceOf <JsonPatternConverter>(layout.SerializingConverter, "converter type");
            var converter = ((JsonPatternConverter)layout.SerializingConverter);

            Assert.IsInstanceOf <JsonDotNetRenderer>(converter.Renderer, "renderer type");
            var renderer = ((JsonDotNetRenderer)converter.Renderer);

            log.Info(new { A = 1, B = new { X = "Y" } });

            var events = GetEventStrings(log.Logger);

            Assert.AreEqual(1, events.Length, "events Count");

            var le = events.Single();

            Assert.IsNotNull(le, "loggingevent");

            StringAssert.Contains(@"{""message"":{""A"":1,""B"":{""X"":""Y""}}}", le, "le has structured message");
        }
Exemple #14
0
        public void Resolve_RepeatedEventHookUp_SOC_411()
        {
            SvnSandBox sbox        = new SvnSandBox(this);
            Uri        projectRoot = new Uri("https://ctf.open.collab.net/svn/repos/sharpsvn/trunk/scripts");

            using (var svnClient = NewSvnClient(false, false))
            {
                for (int i = 0; i < 3; i++)
                {
                    string workingcopy = sbox.GetTempDir();
                    Directory.CreateDirectory(workingcopy);

                    svnClient.Authentication.UserNamePasswordHandlers += DoNowt;
                    try
                    {
                        SvnUpdateResult svnUpdateResult;
                        SvnCheckOutArgs ca = new SvnCheckOutArgs()
                        {
                            Depth = SvnDepth.Files
                        };
                        Assert.IsTrue(svnClient.CheckOut(projectRoot, workingcopy, ca, out svnUpdateResult));
                        Assert.IsNotNull(svnUpdateResult);
                        Assert.IsTrue(svnUpdateResult.HasRevision);
                    }
                    finally
                    {
                        svnClient.Authentication.UserNamePasswordHandlers -= DoNowt;
                    }
                }
            }
        }
        public void CanAccessCollectionProperty()
        {
            var relatives = GetPerson(1).Relatives;

            Assert.IsNotNull(relatives, "Failed to access collection");
            Assert.Greater(relatives.Count, 0, "no items in collection");
        }
        private void LegacyRequestSignatureOnDocumentTest(string status = "sent")
        {
            // the document (file) we want signed
            const string SignTest1File = @"../../docs/SignTest1.pdf";

            // Read a file from disk to use as a document.
            byte[] fileBytes = File.ReadAllBytes(SignTest1File);

            EnvelopeDefinition envDef = new EnvelopeDefinition();

            envDef.EmailSubject = "[DocuSign C# SDK] - Please sign this doc";

            // Add a document to the envelope
            Document doc = new Document();

            doc.DocumentBase64 = System.Convert.ToBase64String(fileBytes);
            doc.Name           = "TestFile.pdf";
            doc.DocumentId     = "1";

            envDef.Documents = new List <Document>();
            envDef.Documents.Add(doc);

            // Add a recipient to sign the documeent
            Signer signer = new Signer();

            signer.Email        = testConfig.RecipientEmail;
            signer.Name         = testConfig.RecipientName;
            signer.RecipientId  = "1";
            signer.ClientUserId = "1234";

            // Create a |SignHere| tab somewhere on the document for the recipient to sign
            signer.Tabs = new Tabs();
            signer.Tabs.SignHereTabs = new List <SignHere>();
            SignHere signHere = new SignHere();

            signHere.DocumentId  = "1";
            signHere.PageNumber  = "1";
            signHere.RecipientId = "1";
            signHere.XPosition   = "100";
            signHere.YPosition   = "100";
            signHere.ScaleValue  = ".5";
            signer.Tabs.SignHereTabs.Add(signHere);

            envDef.Recipients         = new Recipients();
            envDef.Recipients.Signers = new List <Signer>();
            envDef.Recipients.Signers.Add(signer);

            // set envelope status to "sent" to immediately send the signature request
            envDef.Status = status;

            // |EnvelopesApi| contains methods related to creating and sending Envelopes (aka signature requests)
            EnvelopesApi    envelopesApi    = new EnvelopesApi(testConfig.ApiClient.Configuration);
            EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(testConfig.AccountId, envDef);

            Assert.IsNotNull(envelopeSummary);
            Assert.IsNotNull(envelopeSummary.EnvelopeId);

            testConfig.EnvelopeId = envelopeSummary.EnvelopeId;
        }
        public void Test_GetTotalPrice()
        {
            //Arrange
            Calculate      calculate = new Calculate();
            List <Product> products  = new List <Product>();
            var            productA  = new Product
            {
                Id    = "A",
                Price = 50
            };

            var productE = new Product
            {
                Id    = "A",
                Price = 50
            };

            var productF = new Product
            {
                Id    = "A",
                Price = 50
            };

            var productB = new Product
            {
                Id    = "B",
                Price = 30
            };

            var productC = new Product
            {
                Id    = "C",
                Price = 20
            };

            var productD = new Product
            {
                Id    = "A",
                Price = 15
            };


            products.Add(productA);
            products.Add(productE);
            products.Add(productF);
            products.Add(productB);
            products.Add(productC);
            products.Add(productD);

            int calculatedPrice = 205;


            //Act
            int totalPrice = calculate.GetTotalPrice(products);

            //Assert
            Assert.IsNotNull(true);
            Assert.AreEqual(totalPrice, calculatedPrice);
        }
Exemple #18
0
        public void IsTypeOfGeneric()
        {
            Matcher matcher = Is.TypeOf <Matcher>();

            Assert.IsNotNull(matcher);
            Assert.IsTrue(typeof(TypeMatcher).IsInstanceOfType(matcher));
            Assert.IsTrue(matcher.Matches(matcher));
        }
Exemple #19
0
        public void tensor_int()
        {
            var tensor = torch.tensor(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 });

            Assert.IsNotNull(tensor.ToString());
            Console.WriteLine(tensor);
            Assert.AreEqual(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }, tensor.GetData());
        }
Exemple #20
0
 void IAction.Invoke(Invocation invocation)
 {
     if (Previous != null)
     {
         Assert.IsNotNull(Previous.Received, "called out of order");
     }
     Received = invocation;
 }
Exemple #21
0
        public virtual void TestLog()
        {
            var log = GetLog();

            Assert.IsNotNull(log);

            RunTestLog(log);
        }
        public static void NotNull(object value)
        {
#if XUNIT
            FrameworkAssert.NotNull(value);
#else
            FrameworkAssert.IsNotNull(value);
#endif
        }
Exemple #23
0
        public void GetUsedCardsMethodTest()
        {
            var cardDeck = MockBuilder.GetDeckOfCards();

            GameBoard.GetBoard().SetUsedCards(cardDeck);

            Assert.IsNotNull(GameBoard.GetBoard().GetUsedCards());
        }
        public void CanAccessReferenceProperty()
        {
            var person1 = GetPerson(1);
            var product = person1.FavouriteProduct;

            Assert.IsNotNull(product, "Failed to access instance");
            Assert.AreEqual("ProductOne", product.Name);
        }
Exemple #25
0
        public void tensor_jagged_float()
        {
            var tensor = torch.tensor(new float[, ] {
                { 0.1f, 1.2f }, { 2.2f, 3.1f }, { 4.9f, 5.2f }
            });

            Assert.IsNotNull(tensor.ToString());
            Console.WriteLine(tensor);
        }
Exemple #26
0
 public void empty()
 {
     // initialize an array with random integers
     var a = np.empty(new Shape(2, 3), np.int32);
     Console.WriteLine(a.repr);
     Assert.IsNotNull(a.ToString());
     // this should print out the exact integers of the array
     foreach (var x in a.GetData<int>())
         Console.WriteLine(x);
 }
Exemple #27
0
 public void efficient_array_copy()
 {
     var a = np.empty(new Shape(2, 3), np.int32);
     Console.WriteLine(a.repr);
     Assert.IsNotNull(a.ToString());
     long ptr = a.PyObject.ctypes.data;
     Console.WriteLine("ptr: " + ptr);
     var array = new int[] { 1, 2, 3, 4, 5, 6 };
     Marshal.Copy(array, 0, new IntPtr(ptr), array.Length);
     Console.WriteLine(a.ToString());
 }
Exemple #28
0
        public void JwtGetEnvelopeInformationTest()
        {
            JwtRequestSignatureOnDocumentTest();

            // |EnvelopesApi| contains methods related to creating and sending Envelopes including status calls
            EnvelopesApi envelopesApi = new EnvelopesApi(testConfig.ApiClient.Configuration);
            Envelope     envInfo      = envelopesApi.GetEnvelope(testConfig.AccountId, testConfig.EnvelopeId);

            Assert.IsNotNull(envInfo);
            Assert.IsNotNull(envInfo.EnvelopeId);
        }
Exemple #29
0
        public void JwtListRecipientsTest()
        {
            JwtRequestSignatureOnDocumentTest();

            // |EnvelopesApi| contains methods related to envelopes and envelope recipients
            EnvelopesApi envelopesApi = new EnvelopesApi(testConfig.ApiClient.Configuration);
            Recipients   recips       = envelopesApi.ListRecipients(testConfig.AccountId, testConfig.EnvelopeId);

            Assert.IsNotNull(recips);
            Assert.IsNotNull(recips.RecipientCount);
        }
Exemple #30
0
        public void bycicleListAsync()
        {
            // Arrange
            ByciclesController controller = new ByciclesController();

            // Act
            IQueryable <Bycicle> result = controller.GetBycicles();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreNotEqual(0, result.ToList().Count);
            Assert.IsInstanceOf <Bycicle>(result.ToList()[0]);
        }