• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# PrivateType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中PrivateType的典型用法代码示例。如果您正苦于以下问题:C# PrivateType类的具体用法?C# PrivateType怎么用?C# PrivateType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PrivateType类属于命名空间,在下文中一共展示了PrivateType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: InstanceTest

        public void InstanceTest()
        {
            try
            {
                InvisibleForm actual;

                actual = InvisibleForm.Instance;
                Assert.IsNotNull(actual, "InvisibleForm.Instance returned null");

                // Reset and try again
                PrivateType invisibleForm = new PrivateType(typeof(InvisibleForm));
                invisibleForm.SetStaticFieldOrProperty("instanceForm", null);

                actual = InvisibleForm.Instance;
                Assert.IsNotNull(actual, "InvisibleForm.Instance returned null");

                Assert.AreSame(actual, invisibleForm.GetStaticFieldOrProperty("instanceForm"), "Second call to the property should return the same opbject instance.");

                Form f = actual as Form;
                Assert.IsFalse(f.Visible, "InvisibleForm should not be visible");
            }
            catch (Exception ex)
            {
                // Use try catch to test a workaround on CI build (AppVeyor)
                Console.WriteLine(ex.Message);
            }
        }
开发者ID:Visual-Stylecop,项目名称:Visual-StyleCop,代码行数:27,代码来源:InvisibleFormTest.cs


示例2: MyTestCleanup

        public void MyTestCleanup()
        {
            PrivateType privateWindowType = new PrivateType(typeof(VSWindows));
            privateWindowType.SetStaticFieldOrProperty("instance", null);

            this.serviceProvider = null;
        }
开发者ID:kopelli,项目名称:Visual-StyleCop,代码行数:7,代码来源:VSWindowsTest.cs


示例3: KeyGenerationTest

        public void KeyGenerationTest()
        {
            PrivateType pt = new PrivateType(typeof(AsymmetricBlobCryptoProvider));

            byte[] key = (byte[])pt.InvokeStatic("GenerateRandomKey");
            byte[] encryptedKey;
            byte[] decryptedKey;

            var rsa = new RSACryptoServiceProvider();
            rsa.ImportCspBlob(testCspBlob);

            using (ICspProxy cspProxy = new DisposingCspProxy(rsa, rsa.KeySize))
            {
                encryptedKey = cspProxy.Encrypt(key);
                decryptedKey = cspProxy.Decrypt(encryptedKey);
            }

            // The two keys shouldn't be the same...
            Assert.IsFalse(key.SequenceEqual(encryptedKey));

            // And we expect it to grow to the same size as the RSA Key
            Assert.IsTrue(encryptedKey.Length == 4096 / 8);

            // Sanity check, it should be 256 bit / 32 bytes and not contain any zeros.
            Assert.IsTrue(decryptedKey.Length == 256/8, "Key length is incorrect");
            Assert.IsTrue(decryptedKey[0] != 0, "Key starts with an empty byte");

            // And of course, the round tripped key should match original
            Assert.IsTrue(key.SequenceEqual(decryptedKey));
        }
开发者ID:DataWingSoftware,项目名称:azure-encryption-extensions,代码行数:30,代码来源:AsymmetricBlobCryptoProviderTests.cs


示例4: Init

        public void Init()
        {
            PrivateType p = new PrivateType(typeof(Dev2DataLanguageParser));
            var cache = p.GetStaticField("_expressionCache") as ConcurrentDictionary<string, IList<IIntellisenseResult>>;
            Assert.IsNotNull(cache);
            cache.Clear();
            var cache2 = p.GetStaticField("_payloadCache") as ConcurrentDictionary<Tuple<string, string>, IList<IIntellisenseResult>>;
            Assert.IsNotNull(cache2);
            cache2.Clear();
            Monitor.Enter(DataListSingletonTest.DataListSingletonTestGuard);

            var testEnvironmentModel = ResourceModelTest.CreateMockEnvironment();

            _resourceModel = new ResourceModel(testEnvironmentModel.Object)
            {
                ResourceName = "test",
                ResourceType = ResourceType.Service,
                DataList = @"
            <DataList>
                    <Scalar/>
                    <Country/>
                    <State />
                    <City>
                        <Name/>
                        <GeoLocation />
                    </City>
             </DataList>
            "
            };

            IDataListViewModel setupDatalist = new DataListViewModel();
            DataListSingleton.SetDataList(setupDatalist);
            DataListSingleton.ActiveDataList.InitializeDataListViewModel(_resourceModel);
        }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:34,代码来源:DefaultIntellisenseProviderTest.cs


示例5: Initialize

        public void Initialize()
        {
            PrivateType pt = new PrivateType(typeof(SQLiteRepositoryClient));
            pt.SetStaticField("dataSource", filename);

            wait = new AutoResetEvent(false);
        }
开发者ID:joy1192,项目名称:WPF,代码行数:7,代码来源:UnitTest1.cs


示例6: GetPublicStaticPropertyValue

        public void GetPublicStaticPropertyValue()
        {
            dynamic subjectPO = new PrivateType<Subject>();

            bool actual = subjectPO.publicStaticProperty;

            Assert.IsFalse(actual);
        }
开发者ID:vatirim,项目名称:BetterPrivateObject,代码行数:8,代码来源:PrivateTypeTests.cs


示例7: TestGetApiURL

        public void TestGetApiURL()
        {
            PrivateType grinder = new PrivateType(typeof(MeatGrinder));
            PrivateObject obj = new PrivateObject(grinder);
            var retval = obj.Invoke("GetApiURL");

            Assert.AreEqual(1, 1);
        }
开发者ID:jkimbrough,项目名称:BICSL,代码行数:8,代码来源:MeatGrinderTest.cs


示例8: GetPublicStaticFieldValue

        public void GetPublicStaticFieldValue()
        {
            dynamic subjectPO = new PrivateType<Subject>();

            int actual = subjectPO.publicStaticField;

            Assert.AreEqual(Subject.FieldInitialValue, actual);
        }
开发者ID:vatirim,项目名称:BetterPrivateObject,代码行数:8,代码来源:PrivateTypeTests.cs


示例9: TestCountBulls

 public void TestCountBulls()
 {
     bool[] isBull = new bool[4];
     PrivateType pr = new PrivateType(typeof(Game));
     pr.SetStaticFieldOrProperty("secretNumberAsString", "1234");
     int res = Game.CountBulls("1235", 0, isBull);
     Assert.AreEqual(3, res);
 }
开发者ID:hmaleev,项目名称:Quality-Code-Team-Zinc,代码行数:8,代码来源:GameTest.cs


示例10: ReplaceNulls

 public void ReplaceNulls()
 {
     PrivateType internalAssertEx = new PrivateType(typeof(AssertEx));
     object oNull = null;
     Assert.AreEqual("(null)", internalAssertEx.InvokeStatic("ReplaceNulls", oNull), "AssertEx.ReplaceNulls didn't return the correct value.");
     Assert.AreEqual("teststring", internalAssertEx.InvokeStatic("ReplaceNulls", "teststring"), "AssertEx.ReplaceNulls didn't return the correct value.");
     Assert.AreEqual("test\\0string", internalAssertEx.InvokeStatic("ReplaceNulls", "test\0string"), "AssertEx.ReplaceNulls didn't return the correct value.");
 }
开发者ID:benallred,项目名称:Icing,代码行数:8,代码来源:TestOf_AssertEx.cs


示例11: TestBaseClass

        protected TestBaseClass(object instanceToTest, Type typeToTest, int? presentationMethodID)
        {
            if (instanceToTest != null)
                InstanceToTest = new PrivateObject(instanceToTest);

            if (typeToTest != null)
                TypeToTest = new PrivateType(typeToTest);
        }
开发者ID:mnoreke,项目名称:MNorekePublic,代码行数:8,代码来源:TestBaseClass.cs


示例12: InvokePrivateMethodThatReturnsBooleanWithParameter

        public void InvokePrivateMethodThatReturnsBooleanWithParameter()
        {
            dynamic subjectPO = new PrivateType<Subject>();

            bool result = subjectPO.privateStaticMethodThatReturnsBooleanWithParameter(true);

            Assert.IsTrue(result);
        }
开发者ID:vatirim,项目名称:BetterPrivateObject,代码行数:8,代码来源:PrivateTypeTests.cs


示例13: SetTestDateTime

 /// <summary>
 /// Injects current UTC time as fixed constant as replacement of DateTime.UtcNow for testing purposes
 /// </summary>
 internal static void SetTestDateTime()
 {
     var moment = new PrivateType(typeof(Moment));
     var current = DateTime.UtcNow;
     // reduce precision to seconds, because Ticks may be extracted by SQL server
     DateTime precise = new DateTime(current.Year, current.Month, current.Day, current.Hour, current.Minute, current.Second);
     var customMoment = new InjectionDateTime { UtcNow = precise };
     moment.SetStaticField("service", customMoment);
 }
开发者ID:oo00spy00oo,项目名称:SharedTerminals,代码行数:12,代码来源:InjectionDateTime.cs


示例14: TestIfCorrectNumbersOfMinesAreCreated

 public void TestIfCorrectNumbersOfMinesAreCreated()
 {
     PrivateType privateType = new PrivateType(typeof(GameBoardGenerator));
     var fieldSize = 1;
     int startRandomRange = ((15 * fieldSize * fieldSize) / 100) + 1;
     int endRandomRange = ((30 * fieldSize * fieldSize) / 100) + 1;
     int randomCheck = (int)privateType.InvokeStatic("RandomGenerator", startRandomRange, endRandomRange);
     Assert.IsTrue(randomCheck >= 1);
 }
开发者ID:nkolarov,项目名称:telerik-academy,代码行数:9,代码来源:GameFieldGeneratorTests.cs


示例15: TestGetDestFilePath_NoExtensions

        public void TestGetDestFilePath_NoExtensions()
        {
            const string expected = @"C:\Garmin\Activities\1990-01-01-00-00-00_duplicated";
            const string srcPath = @"C:\Garmin\Activities\1990-01-01-00-00-00";

            var pt = new PrivateType(typeof(Program));
            var actual = (string)pt.InvokeStatic("GetDestFilePath", new object[] { srcPath });

            Assert.AreEqual(expected, actual);
        }
开发者ID:harry0000,项目名称:FitDataDuplicator,代码行数:10,代码来源:ProgramTest.cs


示例16: GetConfigurationIndependentPropertyPagesTest

        public void GetConfigurationIndependentPropertyPagesTest()
        {
            Guid[] expected = new Guid[] { typeof(GeneralPropertyPage).GUID };
            Guid[] actual;

            PrivateType type = new PrivateType(typeof(MyCustomProjectNode));
            PrivateObject obj = new PrivateObject(projectNode, type);
            actual = (Guid[])obj.Invoke("GetConfigurationIndependentPropertyPages", new object[] { });

            CollectionAssert.AreEqual(expected, actual, "IndependentPropertyPages not correctly set");
        }
开发者ID:ldematte,项目名称:BlenXVSP,代码行数:11,代码来源:MyCustomProjectNodeTest.cs


示例17: TestCountHits

 public void TestCountHits()
 {
     bool[] isBull = new bool[4];
     bool[] isCow = new bool[10];
     PrivateType pr = new PrivateType(typeof(Game));
     pr.SetStaticFieldOrProperty("secretNumberAsString", "1234");
     int bulls = Game.CountBulls("1234", 0, isBull);
     int cows = Game.CountCows("1234", 0, isBull, isCow);
     Assert.AreEqual(4, bulls);
     Assert.AreEqual(0, cows);
 }
开发者ID:hmaleev,项目名称:Quality-Code-Team-Zinc,代码行数:11,代码来源:GameTest.cs


示例18: TestKernel

        public void TestKernel()
        {
            var kernel = (IKernel)inboxWatcherPrivateObject.Invoke("ConfigureNinject");

            var pvtType = new PrivateType(typeof(InboxWatcher.InboxWatcher));
            var configs = (List <ImapMailBoxConfiguration> ) pvtType.InvokeStatic("GetConfigs");

            var client = kernel.Get<IImapFactory>(new ConstructorArgument("configuration", configs[0]));
            var imapMailBox = kernel.Get<IImapMailBox>(new ConstructorArgument("config", configs[0]));
            Debugger.Break();
        }
开发者ID:ptfuller,项目名称:InboxWatcher,代码行数:11,代码来源:InboxWatcherTests.cs


示例19: V2MasterPasswordIsUniqueTest

        public void V2MasterPasswordIsUniqueTest()
        {
            string key1 = CalculateNewMasterPasswordKey(MASTERPASSWORD);
            string key2 = CalculateNewMasterPasswordKey(MASTERPASSWORD);
            Assert.AreNotEqual(key1, key2, "generated master password key always equals.");

            var accessor = new PrivateType(typeof(PasswordFunctions2));
            byte[] keySalt = (byte[])accessor.InvokeStatic("CreateRandomKeySalt", new Object[] {});
            key1 = CalculateV2Key(accessor, keySalt);
            key2 = CalculateV2Key(accessor, keySalt);
            Assert.AreEqual(key1, key2, "generated master password doesn't equal.");
        }
开发者ID:oo00spy00oo,项目名称:SharedTerminals,代码行数:12,代码来源:PasswordTests.cs


示例20: GameTestCurrentHits

 public void GameTestCurrentHits()
 {
     PrivateType pr = new PrivateType(typeof(Game));
     pr.SetStaticFieldOrProperty("secretNumberAsString", "1234");
     StringWriter sw = new StringWriter();
     Console.SetOut(sw);
     Game.RevealCurrentHits("1234");
     var result = sw.ToString();
     var expected = String.Format("Wrong number! Bulls: 4, Cows: 0!{0}{0}",
         Environment.NewLine);
     Assert.AreEqual(expected, result);
 }
开发者ID:hmaleev,项目名称:Quality-Code-Team-Zinc,代码行数:12,代码来源:GameTest.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Privilege类代码示例发布时间:2022-05-24
下一篇:
C# PrivateObject类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap