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


C# PrivateObject.GetField方法代码示例

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


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

示例1: TestCellBackgroundIsChangedWhenCellHasMine

        public void TestCellBackgroundIsChangedWhenCellHasMine()
        {
            MainWindow window = new MainWindow();
            MinesweeperGrid minesweeperGrid =
                (MinesweeperGrid)MinesweeperGridFactory.CreateNewTable(MinesweeperDifficultyType.Easy);
            PrivateObject view = new PrivateObject(new WpfView(window.WinesweeperGrid));
            Grid buttons = (Grid)view.GetField("win");

            view.Invoke("DisplayGrid", minesweeperGrid);

            int counter = 0;
            for (int r = 0; r < minesweeperGrid.Rows; r++)
            {
                for (int c = 0; c < minesweeperGrid.Cols; c++)
                {
                    if (minesweeperGrid.HasCellBomb(r, c))
                    {
                        minesweeperGrid.RevealCell(r, c);
                        view.Invoke("DisplayGrid", minesweeperGrid);
                        r = minesweeperGrid.Rows;
                        break;
                    }

                    counter++;
                }
            }

            List<ImageBrush> images = (List<ImageBrush>)view.GetField("images");
            Button button = (Button)buttons.Children[counter];

            Assert.AreEqual(images[0], button.Background);
        }
开发者ID:Minesweeper-6-Team-Project-Telerik,项目名称:Minesweeper-6,代码行数:32,代码来源:WpfViewTest.cs

示例2: Janitor_AdjustsFrequency_Correctly

        public void Janitor_AdjustsFrequency_Correctly()
        {
            var janitor = CacheJanitor.Instance;
            var secret = new PrivateObject(janitor);
            var cache1 = new CheckAndSetCache<string, object>(Expires.Always<object>());
            var cache2 = new CheckAndSetCache<string, object>(Expires.Always<object>());
            var cleanup1 = Cleanup.Expired<string, object>(cache1);
            var cleanup2 = Cleanup.Expired<string, object>(cache2);

            cleanup1.Options = new CleanupOptions
            {
                Frequency = TimeSpan.FromMilliseconds(200),
            };
            cleanup2.Options = new CleanupOptions
            {
                Frequency = TimeSpan.FromMilliseconds(100),
            };

            // starts with frequency of 200
            janitor.Register(cache1, cleanup1);
            Assert.AreEqual(cleanup1.Options.Frequency, (TimeSpan)secret.GetField("SleepTime"));

            // starts with frequency of 100
            janitor.Register(cache2, cleanup2);
            Assert.AreEqual(cleanup2.Options.Frequency, (TimeSpan)secret.GetField("SleepTime"));

            janitor.Unregister(cache1);
            janitor.Unregister(cache2);
        }
开发者ID:bashwork,项目名称:common,代码行数:29,代码来源:CacheJanitor.Tests.cs

示例3: DispatcherTimerOnTickTest

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

            Assert.AreEqual(new TimeSpan(0, 0, 0, 5), (TimeSpan)privateObject.GetField("_startTime"));
            privateObject.Invoke("DispatcherTimerOnTick", new object[] {null,null});

            Assert.AreEqual(new TimeSpan(0, 0, 0, 4), (TimeSpan)privateObject.GetField("_startTime"));
        }
开发者ID:devinh,项目名称:KinectRCCar,代码行数:10,代码来源:CountDownTimerTest.cs

示例4: RotateGunTest

        public void RotateGunTest()
        {
            Tank tank = new Tank(new Vector2(0, 400), null, new Random());
            PrivateObject tankObject = new PrivateObject(tank);
            tank.RotateGun(new Vector2(300, 0), 100, 100);

            Assert.IsTrue((float)tankObject.GetField("gunRotation") < 0);

            tank.RotateGun(new Vector2(-300, 0), 100, 100);

            Assert.IsTrue((float)tankObject.GetField("gunRotation") > 0);
        }
开发者ID:csce3513,项目名称:Team12,代码行数:12,代码来源:TankTest.cs

示例5: RemoveObjectTest

        public void RemoveObjectTest()
        {
            PrivateObject manager = new PrivateObject(new GameObjectsManager(new Spaceship(), new Random()));
            manager.Invoke("AddObject", new LiftObjectTestClass(Vector2.Zero, 0, null));
            manager.Invoke("Update", new GameTime());
            List<LiftObject> liftObjects = (List<LiftObject>)manager.GetField("liftObjects");

            manager.Invoke("RemoveObject", liftObjects.Last());
            manager.Invoke("Update", new GameTime());
            liftObjects = (List<LiftObject>)manager.GetField("liftObjects");
            Assert.AreEqual(0, liftObjects.Count);
        }
开发者ID:csce3513,项目名称:Team12,代码行数:12,代码来源:GameObjectsManagerTest.cs

示例6: DependencyTrackingTelemetryModuleIsNotInitializedTwiceToPreventProfilerAttachFailure

        public void DependencyTrackingTelemetryModuleIsNotInitializedTwiceToPreventProfilerAttachFailure()
        {
            var module = new DependencyTrackingTelemetryModule();
            PrivateObject privateObject = new PrivateObject(module);

            module.Initialize(TelemetryConfiguration.CreateDefault());
            object config1 = privateObject.GetField("telemetryConfiguration");

            module.Initialize(TelemetryConfiguration.CreateDefault());
            object config2 = privateObject.GetField("telemetryConfiguration");

            Assert.AreSame(config1, config2);
        }
开发者ID:gregjhogan,项目名称:ApplicationInsights-server-dotnet,代码行数:13,代码来源:DependencyTrackingTelemetryModuleTest.cs

示例7: MoveRandomlyTest

        public void MoveRandomlyTest()
        {
            // Test that it moves when on ground
            PrivateObject cow = new PrivateObject(new Cow(new Vector2(100, 300), 0, null, new Random()));
            cow.Invoke("MoveRandomly", new GameTime());
            TimeSpan duration = (TimeSpan) cow.GetField("actionDuration");
            Assert.IsTrue(duration.Ticks > 0);

            // Test that it doesn't move when off ground
            cow.SetProperty("Position", new Vector2(100, 299));
            cow.Invoke("MoveRandomly", new GameTime());
            duration = (TimeSpan)cow.GetField("actionDuration");
            Assert.AreEqual(0, duration.Ticks);
        }
开发者ID:csce3513,项目名称:Team12,代码行数:14,代码来源:CowTest.cs

示例8: HostAndPortMustMatchWhatIsInRequestWhenHostAndXffHeadersAreAbsent

        public void HostAndPortMustMatchWhatIsInRequestWhenHostAndXffHeadersAreAbsent()
        {
            var request = new HttpRequestMessage();
            request.RequestUri = new Uri("http://server/api/values");

            var normalizedRequest = new NormalizedRequest(request, null);

            PrivateObject po = new PrivateObject(normalizedRequest);

            var hostName = (string)po.GetField("hostName");
            var port = (string)po.GetField("port");

            Assert.AreEqual("server", hostName);
            Assert.AreEqual("80", port);
        }
开发者ID:ChrisRollason,项目名称:Thinktecture.IdentityModel.45,代码行数:15,代码来源:NormalizedRequestTests.cs

示例9: HostAndPortMustMatchWhatIsInHostHeaderWhenPresent

        public void HostAndPortMustMatchWhatIsInHostHeaderWhenPresent()
        {
            var request = new HttpRequestMessage();
            request.RequestUri = new Uri("http://server/api/values");
            request.Headers.Host = "myhost:899";

            var normalizedRequest = new NormalizedRequest(new WebApiRequestMessage(request), null);

            PrivateObject po = new PrivateObject(normalizedRequest);

            var hostName = (string)po.GetField("hostName");
            var port = (string)po.GetField("port");

            Assert.AreEqual("myhost", hostName);
            Assert.AreEqual("899", port);
        }
开发者ID:Rameshcyadav,项目名称:Thinktecture.IdentityModel.45,代码行数:16,代码来源:HawkNormalizedRequestTests.cs

示例10: InitSessionWithNoDataBaseDirectoryIsNullStillInitialises

        public void InitSessionWithNoDataBaseDirectoryIsNullStillInitialises()
        {
            DebugTO to = new DebugTO();
            string rootFolder = Path.GetTempPath() + Guid.NewGuid();
            IDev2StudioSessionBroker broker = Dev2StudioSessionFactory.CreateBroker();
            to.RememberInputs = true;
            to.BaseSaveDirectory = null;
            to.DataList = "<DataList><scalar1/><rs><f1/><f2/></rs></DataList>";
            to.XmlData = "<DataList><scalar1>s1</scalar1><rs><f1/>f1Value<f2/>f2Value</rs></DataList>";
            to.ServiceName = "DummyService";
            to.WorkflowID = "DummyService";
            broker.InitDebugSession(to);
            to = broker.PersistDebugSession(to);
            to.BaseSaveDirectory = null;
            PrivateObject p = new PrivateObject(broker);
            var field = p.GetField("_debugPersistSettings") as IDictionary<string, DebugTO>;
            Assert.IsNotNull(field);
            field.Add("bob", new DebugTO());
            to = broker.PersistDebugSession(to);

            Assert.AreEqual(string.Empty, to.Error);
            Assert.IsNotNull(to.BinaryDataList); // assert not null hence we created it ;)

            DeleteDir(rootFolder);
        }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:25,代码来源:BrokerTest.cs

示例11: AycockHorspoolAlgorithmShouldAcceptVulnerableGrammar

        public void AycockHorspoolAlgorithmShouldAcceptVulnerableGrammar()
        {
            var a = new TerminalLexerRule(
                new CharacterTerminal('a'),
                new TokenType("a"));

            ProductionExpression
                SPrime = "S'",
                S = "S",
                A = "A",
                E = "E";

            SPrime.Rule = S;
            S.Rule = (Expr)S | A + A + A + A;
            A.Rule = (Expr)"a" | E;

            var expression = new GrammarExpression(
                SPrime,
                new[] { SPrime, S, A, E });

            var grammar = expression.ToGrammar();

            var parseEngine = new ParseEngine(grammar);
            parseEngine.Pulse(new Token("a", 0, a.TokenType));

            var privateObject = new PrivateObject(parseEngine);
            var chart = privateObject.GetField("_chart") as Chart;

            Assert.IsNotNull(chart);
            Assert.AreEqual(2, chart.Count);
            Assert.IsTrue(parseEngine.IsAccepted());
        }
开发者ID:bilsaboob,项目名称:Pliant,代码行数:32,代码来源:AycockHorspoolAlgorithmTests.cs

示例12: Test_AycockHorspoolAlgorithm_That_Vulnerable_Grammar_Accepts_Input

        public void Test_AycockHorspoolAlgorithm_That_Vulnerable_Grammar_Accepts_Input()
        {
            var a = new TerminalLexerRule(
                new Terminal('a'),
                new TokenType("a"));

            var grammar = new GrammarBuilder("S'")
            .Production("S'", r => r
                .Rule("S"))
            .Production("S", r => r
                .Rule("A", "A", "A", "A"))
            .Production("A", r => r
                .Rule(a)
                .Rule("E"))
            .Production("E", r => r
                .Lambda())
            .ToGrammar();

            var parseEngine = new ParseEngine(grammar);
            parseEngine.Pulse(new Token("a", 0, a.TokenType));

            var privateObject = new PrivateObject(parseEngine);
            var chart = privateObject.GetField("_chart") as Chart;

            Assert.IsNotNull(chart);
            Assert.AreEqual(2, chart.Count);
            Assert.IsTrue(parseEngine.IsAccepted());
        }
开发者ID:whitten,项目名称:Pliant,代码行数:28,代码来源:AycockHorspoolAlgorithmTests.cs

示例13: PortMustDefaultTo80WhenHostHeaderDoesNotContainPort

        public void PortMustDefaultTo80WhenHostHeaderDoesNotContainPort()
        {
            var request = new HttpRequestMessage();
            request.RequestUri = new Uri("http://server/api/values");
            request.Headers.Host = "myhost";

            var normalizedRequest = new NormalizedRequest(request, null);

            PrivateObject po = new PrivateObject(normalizedRequest);

            var hostName = (string)po.GetField("hostName");
            var port = (string)po.GetField("port");

            Assert.AreEqual("myhost", hostName);
            Assert.AreEqual("80", port);
        }
开发者ID:ChrisRollason,项目名称:Thinktecture.IdentityModel.45,代码行数:16,代码来源:NormalizedRequestTests.cs

示例14: OpenTest

		//-------------------------------------------------------------
		// 概要:MovieStartイベントが発生するか確認
		//-------------------------------------------------------------
		private static void OpenTest(string streamUrl)
		{
			// 再生中の判定
			bool isPlaying = false;

			// イベント登録
			PecaPlayerForm form = new PecaPlayerForm();
			form.Show();

			PecaPlayerControl pecaPlayer = form.pecaPlayer;
			PrivateObject accessor = new PrivateObject(pecaPlayer);
			IMoviePlayer moviePlayer = (IMoviePlayer)accessor.GetField("moviePlayer");
			moviePlayer.MovieStart += (sender, e) =>
			{
				isPlaying = true;
			};

			// テスト対象を実行
			pecaPlayer.Open(streamUrl);

			// 再生されるまで待つ
			while (isPlaying == false)
			{
				Application.DoEvents();
				Thread.Sleep(100);
			}
		}
开发者ID:shinji3,项目名称:PeerstPlayer,代码行数:30,代码来源:PecaPlayerTest.cs

示例15: CountNeighborStates3x3GridMixOfLiveAndDead

 public void CountNeighborStates3x3GridMixOfLiveAndDead()
 {
     PrivateObject ATestGrid = new PrivateObject(new GameOfLife(3, 3));
     Cell[,] ATestCellGrid = (Cell[,])ATestGrid.GetField("cells");
     ATestCellGrid[0, 0].State = true;
     ATestCellGrid[1, 1].State = true;
     ATestCellGrid[2, 2].State = true;
     int[] TestNeighborStates0x0 = (int[])ATestGrid.Invoke("CountNeighborStates", new object[] { ATestCellGrid[0, 0] });
     int[] TestNeighborStates0x2 = (int[])ATestGrid.Invoke("CountNeighborStates", new object[] { ATestCellGrid[0, 2] });
     int[] TestNeighborStates2x0 = (int[])ATestGrid.Invoke("CountNeighborStates", new object[] { ATestCellGrid[2, 0] });
     int[] TestNeighborStates2x2 = (int[])ATestGrid.Invoke("CountNeighborStates", new object[] { ATestCellGrid[2, 2] });
     int[] TestNeighborStates1x0 = (int[])ATestGrid.Invoke("CountNeighborStates", new object[] { ATestCellGrid[1, 0] });
     int[] TestNeighborStates1x2 = (int[])ATestGrid.Invoke("CountNeighborStates", new object[] { ATestCellGrid[1, 2] });
     int[] TestNeighborStates0x1 = (int[])ATestGrid.Invoke("CountNeighborStates", new object[] { ATestCellGrid[0, 1] });
     int[] TestNeighborStates2x1 = (int[])ATestGrid.Invoke("CountNeighborStates", new object[] { ATestCellGrid[2, 1] });
     int[] TestNeighborStates1x1 = (int[])ATestGrid.Invoke("CountNeighborStates", new object[] { ATestCellGrid[1, 1] });
     CollectionAssert.AreEqual(new int[] { 1, 2 }, TestNeighborStates0x0);
     CollectionAssert.AreEqual(new int[] { 1, 2 }, TestNeighborStates0x2);
     CollectionAssert.AreEqual(new int[] { 1, 2 }, TestNeighborStates2x0);
     CollectionAssert.AreEqual(new int[] { 1, 2 }, TestNeighborStates2x2);
     CollectionAssert.AreEqual(new int[] { 2, 3 }, TestNeighborStates1x0);
     CollectionAssert.AreEqual(new int[] { 2, 3 }, TestNeighborStates1x2);
     CollectionAssert.AreEqual(new int[] { 2, 3 }, TestNeighborStates0x1);
     CollectionAssert.AreEqual(new int[] { 2, 3 }, TestNeighborStates2x1);
     CollectionAssert.AreEqual(new int[] { 2, 6 }, TestNeighborStates1x1);
 }
开发者ID:sqfish,项目名称:ConwaysGameOfLife,代码行数:26,代码来源:GridTests.cs


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