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


C# PrivateType类代码示例

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


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


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