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


C# PrivateObject.GetProperty方法代码示例

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


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

示例1: GetVirtualPath_NoTranslationExistsForThreadCulture_ReturnsNeutralLocalizationRoute

		public void GetVirtualPath_NoTranslationExistsForThreadCulture_ReturnsNeutralLocalizationRoute()
		{
			using (ShimsContext.Create())
			{
				// Arrange
				Thread.CurrentThread.CurrentUICulture = new CultureInfo("es");

				LocalizationCollectionRoute localizationCollectionRoute =
					new LocalizationCollectionRoute(new HttpRoute("Home",
						new HttpRouteValueDictionary() { { "controller", "Home" }, { "action", "Index" } }, new HttpRouteValueDictionary(),
						new HttpRouteValueDictionary(), null));

				PrivateObject privateObject = new PrivateObject(localizationCollectionRoute);

				IDictionary<string, LocalizationRoute> routes =
					(IDictionary<string, LocalizationRoute>)privateObject.GetProperty("LocalizedRoutesContainer");

				ShimLocalizationRoute localizationRouteNeutral =
					new ShimLocalizationRoute(new LocalizationRoute("Welcome",
						new HttpRouteValueDictionary() { { "controller", "Home" }, { "action", "Index" } }, new HttpRouteValueDictionary(),
						new HttpRouteValueDictionary(), null, string.Empty));

				(new ShimHttpRoute(localizationRouteNeutral)).GetVirtualPathHttpRequestMessageIDictionaryOfStringObject =
					(requestContext, values) => new HttpVirtualPathData(localizationRouteNeutral.Instance, "Welcome");

				routes[string.Empty] = localizationRouteNeutral;

				ShimLocalizationRoute localizationRouteEnglish =
					new ShimLocalizationRoute(new LocalizationRoute("Welcome",
						new HttpRouteValueDictionary() { { "controller", "Home" }, { "action", "Index" } }, new HttpRouteValueDictionary(),
						new HttpRouteValueDictionary(), null, "en"));

				(new ShimHttpRoute(localizationRouteEnglish)).GetVirtualPathHttpRequestMessageIDictionaryOfStringObject =
					(requestContext, values) => new HttpVirtualPathData(localizationRouteEnglish.Instance, "Welcome");

				routes["en"] = localizationRouteEnglish;

				ShimLocalizationRoute localizationRouteGerman =
					new ShimLocalizationRoute(new LocalizationRoute("Willkommen",
						new HttpRouteValueDictionary() { { "controller", "Home" }, { "action", "Index" } }, new HttpRouteValueDictionary(),
						new HttpRouteValueDictionary(), null, "de"));

				routes["de"] = localizationRouteGerman;

				(new ShimHttpRoute(localizationRouteGerman)).GetVirtualPathHttpRequestMessageIDictionaryOfStringObject =
					(requestContext, values) => new HttpVirtualPathData(localizationRouteGerman.Instance, "Willkommen");

				// Act
				IHttpVirtualPathData virtualPathData = localizationCollectionRoute.GetVirtualPath(null,
					new HttpRouteValueDictionary());

				// Assert
				Assert.AreEqual(virtualPathData.Route, localizationRouteNeutral.Instance);
			}
		}
开发者ID:NishiGulnaz,项目名称:RouteLocalization,代码行数:55,代码来源:LocalizationCollectionRouteTests.cs

示例2: DoRun

    // Utility function that sets up and executes the run, then asserts the results
    private PrivateObject DoRun(BinaryProblem problem, int maximumEvaluations, int seed, double bestQuality, int foundOn) {
      var solver = new HeuristicLab.Algorithms.ParameterlessPopulationPyramid.ParameterlessPopulationPyramid();
      solver.Problem = problem;
      solver.MaximumEvaluations = maximumEvaluations;
      solver.Seed = seed;
      solver.SetSeedRandomly = false;
      PrivateObject hidden = new PrivateObject(solver);
      try {
        hidden.Invoke("Run", new CancellationToken());
      } catch (OperationCanceledException) {
        // Ignore
      }

      Assert.AreEqual(maximumEvaluations, hidden.GetProperty("ResultsEvaluations"), "Total Evaluations");
      double foundQuality = (double)hidden.GetProperty("ResultsBestQuality");
      Assert.IsTrue(foundQuality.IsAlmost(bestQuality), string.Format("Expected <{0}> Actual <{1}>", bestQuality, foundQuality));
      Assert.AreEqual(foundOn, hidden.GetProperty("ResultsBestFoundOnEvaluation"), "Found On");

      return hidden;
    }
开发者ID:t-h-e,项目名称:HeuristicLab,代码行数:21,代码来源:ParameterlessPopulationPyramidTest.cs

示例3: DispatcherTimerTest

        public void DispatcherTimerTest()
        {
            CountdownTimer timer = new CountdownTimer(new TimeSpan(0, 0, 0, 5), new TimeSpan(0, 0, 0, 1));
            PrivateObject privateObject = new PrivateObject(timer);

            Timer testTimer = new Timer(5001);

            testTimer.Elapsed += (sender, args) =>
                                {
                                    Assert.IsFalse((bool)privateObject.GetProperty("IsEnabled"));
                                    Assert.AreEqual(new TimeSpan(), (TimeSpan)privateObject.GetField("_startTime"));
                                };

            Assert.AreEqual(new TimeSpan(0, 0, 0, 5), (TimeSpan)privateObject.GetField("_startTime"));
            Assert.IsFalse((bool)privateObject.GetProperty("IsEnabled"));
            privateObject.Invoke("Start");
            Assert.IsTrue((bool)privateObject.GetProperty("IsEnabled"));
            testTimer.Start();
        }
开发者ID:devinh,项目名称:KinectRCCar,代码行数:19,代码来源:CountDownTimerTest.cs

示例4: GetVirtualPath_OverriddenCultureByRouteDictionaryThatDoesNotExist_ReturnsNeutralLocalizationRoute

		public void GetVirtualPath_OverriddenCultureByRouteDictionaryThatDoesNotExist_ReturnsNeutralLocalizationRoute()
		{
			using (ShimsContext.Create())
			{
				// Arrange
				Thread.CurrentThread.CurrentUICulture = new CultureInfo("en");

				LocalizationCollectionRoute localizationCollectionRoute =
					new LocalizationCollectionRoute(new Route("Home",
						new RouteValueDictionary() { { "controller", "Home" }, { "action", "Index" } }, new RouteValueDictionary(),
						new RouteValueDictionary(), null));

				PrivateObject privateObject = new PrivateObject(localizationCollectionRoute);

				IDictionary<string, LocalizationRoute> routes =
					(IDictionary<string, LocalizationRoute>)privateObject.GetProperty("LocalizedRoutesContainer");

				ShimLocalizationRoute localizationRouteNeutral =
					new ShimLocalizationRoute(new LocalizationRoute("Welcome",
						new RouteValueDictionary() { { "controller", "Home" }, { "action", "Index" } }, new RouteValueDictionary(),
						new RouteValueDictionary(), null, string.Empty));

				(new ShimRoute(localizationRouteNeutral)).GetVirtualPathRequestContextRouteValueDictionary =
					(requestContext, values) => new VirtualPathData(localizationRouteNeutral, "Welcome");

				routes[string.Empty] = localizationRouteNeutral;

				ShimLocalizationRoute localizationRouteEnglish =
					new ShimLocalizationRoute(new LocalizationRoute("Welcome",
						new RouteValueDictionary() { { "controller", "Home" }, { "action", "Index" } }, new RouteValueDictionary(),
						new RouteValueDictionary(), null, "en"));

				(new ShimRoute(localizationRouteEnglish)).GetVirtualPathRequestContextRouteValueDictionary =
					(requestContext, values) => new VirtualPathData(localizationRouteEnglish, "Welcome");

				routes["en"] = localizationRouteEnglish;

				ShimLocalizationRoute localizationRouteGerman =
					new ShimLocalizationRoute(new LocalizationRoute("Willkommen",
						new RouteValueDictionary() { { "controller", "Home" }, { "action", "Index" } }, new RouteValueDictionary(),
						new RouteValueDictionary(), null, "de"));

				routes["de"] = localizationRouteGerman;

				(new ShimRoute(localizationRouteGerman)).GetVirtualPathRequestContextRouteValueDictionary =
					(requestContext, values) => new VirtualPathData(localizationRouteGerman, "Willkommen");

				// Act
				VirtualPathData virtualPathData = localizationCollectionRoute.GetVirtualPath(null,
					new RouteValueDictionary() { { "Culture", "es" } });

				// Assert
				Assert.AreEqual(virtualPathData.Route, localizationRouteNeutral.Instance);
			}
		}
开发者ID:NishiGulnaz,项目名称:RouteLocalization,代码行数:55,代码来源:LocalizationCollectionRouteTests.cs

示例5: GetReadOnlyAndCompulsory

 private void GetReadOnlyAndCompulsory(string contentTypeName, out bool readOnly, out bool compulsory)
 {
     ContentType contentType = ContentTypeManager.Current.GetContentTypeByName(contentTypeName);
     PrivateObject obj = new PrivateObject(contentType);
     object o = obj.GetProperty("FieldSettings");
     PrivateObject setting = new PrivateObject(((IList)o)[0]);
     readOnly = (bool)setting.GetProperty("ReadOnly", new object[0]);
     compulsory = (bool)setting.GetProperty("Compulsory", new object[0]);
 }
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:9,代码来源:FieldSettingTest.cs

示例6: ChoiceTestOnEnum

        private void ChoiceTestOnEnum(string ctd, EnumTestNode.TestEnum loadValue, EnumTestNode.TestEnum selectValue, out ListItemCollection loadedList, out EnumTestNode.TestEnum result, out bool isValid)
        {
            ContentTypeInstaller.InstallContentType(ctd);

            SNC.Content content = SNC.Content.CreateNew("EnumTestNode", _testRoot, "ChoiceTest");
            var contentHandler = (EnumTestNode)content.ContentHandler;
            contentHandler.TestProperty = loadValue;

            //-- simulate ContentView
            ChoiceField field = (ChoiceField)content.Fields["TestProperty"];
            SenseNet.Portal.UI.Controls.CheckBoxGroup chk = new SenseNet.Portal.UI.Controls.CheckBoxGroup();
            PrivateObject chkAcc = new PrivateObject(chk);
            chkAcc.Invoke("set_Field", content.Fields["TestProperty"]);

            chk.SetData(field.GetData());
            ListItemCollection items = (ListItemCollection)chkAcc.GetProperty("InnerListItemCollection");

            loadedList = new ListItemCollection();
            foreach (ListItem item in items)
            {
                ListItem newItem = new ListItem(item.Text, item.Value, item.Enabled);
                newItem.Selected = item.Selected;
                loadedList.Add(newItem);
            }

            var extraOptionValue = (string)chkAcc.Invoke("get_ExtraOptionValue");

            //-- select item
            var selectedText = selectValue.ToString();
            foreach (ListItem item in items)
                item.Selected = item.Text == selectedText;

            field.SetData(chk.GetData());
            new PrivateObject(field).Invoke("Save", false);

            result = (EnumTestNode.TestEnum)contentHandler.TestProperty;
            isValid = field.IsValid;
        }
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:38,代码来源:FieldSettingTest.cs

示例7: ChoiceTestOnString

        private void ChoiceTestOnString(string ctd, string loadValue, string setExtraValue, out ListItemCollection loadedList, out string result, out bool isValid)
        {
            ContentTypeInstaller.InstallContentType(ctd);

            SNC.Content content = SNC.Content.CreateNew("ValidatedContent", _testRoot, "ChoiceTest");
            content.ContentHandler["ChoiceTest"] = loadValue;

            //-- simulate ContentView
            ChoiceField field = (ChoiceField)content.Fields["ChoiceTest"];
            SenseNet.Portal.UI.Controls.CheckBoxGroup chk = new SenseNet.Portal.UI.Controls.CheckBoxGroup();
            PrivateObject chkAcc = new PrivateObject(chk);
            chkAcc.Invoke("set_Field", content.Fields["ChoiceTest"]);
            chk.SetData(field.GetData());
            ListItemCollection items = (ListItemCollection)chkAcc.GetProperty("InnerListItemCollection");

            loadedList = new ListItemCollection();
            foreach (ListItem item in items)
            {
                ListItem newItem = new ListItem(item.Text, item.Value, item.Enabled);
                newItem.Selected = item.Selected;
                loadedList.Add(newItem);
            }

            var extraOptionValue = (string)chkAcc.Invoke("get_ExtraOptionValue");
            ListItem extraItem = null;

            //-- return inverted selection
            foreach (ListItem item in items)
            {
                item.Selected = !item.Selected;
                if (item.Value == extraOptionValue)
                    extraItem = item;
            }
            if (setExtraValue != null)
            {
                chkAcc.Invoke("SetExtraValue", setExtraValue);
                if (extraItem != null)
                    extraItem.Selected = true;
            }
            field.SetData(chk.GetData());
            new PrivateObject(field).Invoke("Save", false);

            result = (string)content.ContentHandler["ChoiceTest"];
            isValid = field.IsValid;
        }
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:45,代码来源:FieldSettingTest.cs

示例8: clearMacroEntryListTest

        public void clearMacroEntryListTest()
        {
            Macro_Accessor target = new Macro_Accessor();

            target.addMacroEntry(this, new MementoEventArgs("TestMacroEntry", "notExistingPluginName"));

            target.addMacroEntry(this, new MementoEventArgs("memName", "Macro"));
            PrivateObject macroAccessor = new PrivateObject(target);
            MacroEntry rootEntry = macroAccessor.GetProperty("rootEntry", null) as MacroEntry;
            Assert.IsNotNull(rootEntry, "Macro didnt process the add operation correctly.");
            Assert.IsTrue(1 == rootEntry.macroEntries.Count, "Add macro operation didnt change the entries property.");

            target.clearMacroEntryList();

            Assert.IsTrue(0 == rootEntry.macroEntries.Count, "Clear operation didnt remove all items.");
        }
开发者ID:PSE-2012,项目名称:MMWTV,代码行数:16,代码来源:MacroTest.cs

示例9: SetupTest

        public void SetupTest()
        {
            //arrange
            var pvt = new PrivateObject(_imapMailBox);

            //act
            _imapMailBox.Setup().Wait();

            //assert
            var result = (bool)pvt.GetProperty("SetupInProgress");
            Assert.IsFalse(result);
            _worker.Verify(x => x.GetMailFolders());
        }
开发者ID:ptfuller,项目名称:InboxWatcher,代码行数:13,代码来源:ImapMailBoxTests.cs

示例10: Test_GIL_Lock

        public void Test_GIL_Lock()
        {
            var py = new PrivateObject(Python.Instance());
            var api = (PythonAPI)py.GetProperty("Api");
            var gil = api.PyGILState_Ensure();

            var sw = new Stopwatch();
            sw.Start();
            var t = new Thread(() => {
                Thread.Sleep(2000);
                api.PyGILState_Release(gil);
            });
            t.Start();
            var anotherGil = api.PyGILState_Ensure();
            Assert.GreaterOrEqual(sw.ElapsedMilliseconds, 2000);
            api.PyGILState_Release(anotherGil);
        }
开发者ID:omershelef,项目名称:NPython,代码行数:17,代码来源:PythonTests.cs


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