当前位置: 首页>>代码示例>>C#>>正文


C# IProcess.Execute方法代码示例

本文整理汇总了C#中IProcess.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# IProcess.Execute方法的具体用法?C# IProcess.Execute怎么用?C# IProcess.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IProcess的用法示例。


在下文中一共展示了IProcess.Execute方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Can_Get_Decrypted_Credentials

        public void Can_Get_Decrypted_Credentials()
        {
            // Setup
            string decryptedString = "decrypted string";
            string username = "username";
            string encryptedString = "w6AnE3eWg1urf54jkTejCku+JT3gPT78e9MAkUa8fsI=";
            byte[] expectedKey = Convert.FromBase64String("LHRqdBadRUVh3cdMYoeuYVng/qQlgvBReEAg5JvO48E=");
            byte[] expectedIV = Convert.FromBase64String("CB7hOrmWxs2riRF26Imn7w==");
            byte[] expectedEncryptedPass = Convert.FromBase64String(encryptedString);

            var encryptionMock = new Mock<EncryptionUtils>();
            encryptionMock.Setup(x => x.DecryptStringFromBytes_AES(expectedEncryptedPass, expectedKey, expectedIV)).Returns(decryptedString);

            var user = new User();
            var jigsaw = new JigsawAccountDetails { AssociatedUser = user, Username = username, EncryptedPassword = encryptedString };
            _context.JigsawAccountDetails.Add(jigsaw);
            _context.SaveChanges();

            _process = new JigsawAuthProcesses(_context, encryptionMock.Object);

            // Act
            var result = _process.Execute(new GetUserJigsawCredentialsParams { RequestingUserId = user.Id });

            // Verify
            Assert.IsNotNull(result, "Process returned a null result");
            Assert.AreEqual(username, result.JigsawUsername, "An incorrect username was returned");
            Assert.AreEqual(decryptedString, result.JigsawPassword, "An incorrect password was returned");
        }
开发者ID:KallDrexx,项目名称:MyJobLeads,代码行数:28,代码来源:GetUserJigsawCredentialTests.cs

示例2: Jigsaw_Credentials_Gets_Updated_If_One_Exists_For_User

        public void Jigsaw_Credentials_Gets_Updated_If_One_Exists_For_User()
        {
            // Setup
            var encryptionMock = new Mock<EncryptionUtils>();
            encryptionMock.Setup(x => x.EncryptStringToBytes_AES(It.IsAny<string>(), It.IsAny<byte[]>(), It.IsAny<byte[]>())).Returns(new byte[] { Convert.ToByte(true) });

            var user = new User { JigsawAccountDetails = new JigsawAccountDetails { Username = "a", EncryptedPassword = "b" } };
            _context.Users.Add(user);
            _context.SaveChanges();

            _process = new JigsawAuthProcesses(_context, encryptionMock.Object);

            // Act
            var result = _process.Execute(new SaveJigsawUserCredentialsParams
            {
                RequestingUserId = user.Id,
                JigsawUsername = "a",
                JigsawPassword = "b"
            });

            // Verify
            Assert.AreEqual(1, _context.JigsawAccountDetails.Count(), "Incorrect number of jigsaw records exist");
            Assert.AreEqual("a", user.JigsawAccountDetails.Username, "Jigsaw username was incorrect");
            Assert.AreEqual(Convert.ToBase64String(new byte[] { Convert.ToByte(true) }), user.JigsawAccountDetails.EncryptedPassword, "Jigsaw password was incorrect");
        }
开发者ID:KallDrexx,项目名称:MyJobLeads,代码行数:25,代码来源:SaveJigsawCredentialsTests.cs

示例3: Can_Save_Jigsaw_Encrypted_Credentials_For_User

        public void Can_Save_Jigsaw_Encrypted_Credentials_For_User()
        {
            // Setup
            string username = "username";
            string unencryptedPass = "base password";
            byte[] expectedKey = Convert.FromBase64String("LHRqdBadRUVh3cdMYoeuYVng/qQlgvBReEAg5JvO48E=");
            byte[] expectedIV = Convert.FromBase64String("CB7hOrmWxs2riRF26Imn7w==");

            var encryptionMock = new Mock<EncryptionUtils>();
            encryptionMock.Setup(x => x.EncryptStringToBytes_AES(unencryptedPass, expectedKey, expectedIV)).Returns(new byte[] { Convert.ToByte(true) });

            var user = new User();
            _context.Users.Add(user);
            _context.SaveChanges();

            _process = new JigsawAuthProcesses(_context, encryptionMock.Object);

            // Act
            var result = _process.Execute(new SaveJigsawUserCredentialsParams
            {
                RequestingUserId = user.Id,
                JigsawUsername = username,
                JigsawPassword = unencryptedPass
            });

            // Verify
            Assert.IsNotNull(result, "Process returned a null result");
            Assert.IsTrue(result.WasSuccessful, "Process' result was not successful");

            var jigsaw = _context.JigsawAccountDetails.SingleOrDefault();
            Assert.IsNotNull(jigsaw, "No jigsaw credentials entity was created");
            Assert.AreEqual(username, jigsaw.Username, "Jigsaw username was incorrect");
            Assert.AreEqual(Convert.ToBase64String(new byte[] { Convert.ToByte(true) }), jigsaw.EncryptedPassword, "Jigsaw password was incorrect");
        }
开发者ID:KallDrexx,项目名称:MyJobLeads,代码行数:34,代码来源:SaveJigsawCredentialsTests.cs

示例4: Returns_Null_If_No_Credentials_Exist

        public void Returns_Null_If_No_Credentials_Exist()
        {
            // Setup
            var encryptionMock = new Mock<EncryptionUtils>();
            _process = new JigsawAuthProcesses(_context, encryptionMock.Object);

            // Act
            var result = _process.Execute(new GetUserJigsawCredentialsParams { RequestingUserId = 1 });

            // Verify
            Assert.IsNull(result);
        }
开发者ID:KallDrexx,项目名称:MyJobLeads,代码行数:12,代码来源:GetUserJigsawCredentialTests.cs

示例5: Throws_EntityNotFoundException_When_User_Not_Found

        public void Throws_EntityNotFoundException_When_User_Not_Found()
        {
            // Setup
            var encryptionMock = new Mock<EncryptionUtils>();
            encryptionMock.Setup(x => x.EncryptStringToBytes_AES(It.IsAny<string>(), It.IsAny<byte[]>(), It.IsAny<byte[]>())).Returns(new byte[] { Convert.ToByte(true) });

            var user = new User { JigsawAccountDetails = new JigsawAccountDetails { Username = "a", EncryptedPassword = "b" } };
            _context.Users.Add(user);
            _context.SaveChanges();

            int id = user.Id + 101;
            _process = new JigsawAuthProcesses(_context, encryptionMock.Object);

            // Act
            try
            {
                _process.Execute(new SaveJigsawUserCredentialsParams { RequestingUserId = id });
                Assert.Fail("No exception was thrown");
            }

            // Verify
            catch (MJLEntityNotFoundException ex)
            {
                Assert.AreEqual(typeof(User), ex.EntityType, "Exception's entity type value was incorrect");
                Assert.AreEqual(id.ToString(), ex.IdValue, "Exception's id value was incorrect");
            }
        }
开发者ID:KallDrexx,项目名称:MyJobLeads,代码行数:27,代码来源:SaveJigsawCredentialsTests.cs


注:本文中的IProcess.Execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。