本文整理汇总了C#中PrivateObject类的典型用法代码示例。如果您正苦于以下问题:C# PrivateObject类的具体用法?C# PrivateObject怎么用?C# PrivateObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PrivateObject类属于命名空间,在下文中一共展示了PrivateObject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: LabyrinthMoveUpTest
public void LabyrinthMoveUpTest()
{
PlayerPosition startPosition = new PlayerPosition(3, 3);
string[] rawData = new string[Labyrinth.LabyrinthSize]
{
"XXXXXXX",
"X-X---X",
"X---X-X",
"X--*--X",
"X-X----",
"X-----X",
"XXXXXXX"
};
Cell[,] board = LabyrinthDataFromStringArray(rawData);
Labyrinth labyrinth = new Labyrinth(startPosition, board);
var privateObject = new PrivateObject(labyrinth);
privateObject.Invoke("ProcessMoveUp", 3, 3);
string result =
@"X X X X X X X
X - X - - - X
X - - * X - X
X - - - - - X
X - X - - - -
X - - - - - X
X X X X X X X
";
string expected = labyrinth.ToString();
Assert.AreEqual(expected, result);
}
开发者ID:Jarolim,项目名称:AllMyHomeworkForTelerikAcademy,代码行数:30,代码来源:Labyrinth.Tests.cs
示例2: 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
示例3: UpdateDoesNotErrorTest
public void UpdateDoesNotErrorTest()
{
var pnet = new PNetC.Net(new PNet.Testing.Common.TestEngineHook());
var param0 = new PrivateObject(pnet);
var target = new Net_Accessor(param0);
target.Update();
}
开发者ID:traleven,项目名称:PNet,代码行数:7,代码来源:NetTest.cs
示例4: Init
public void Init()
{
c = new Customer();
pc = new PrivateObject(c);
ac = new Account();
c.AddAccount(ac);
}
开发者ID:KasperFlye,项目名称:CsharpAndDotNet,代码行数:7,代码来源:UnitTest1.cs
示例5: SinglePointCrossoverCrossTest
public void SinglePointCrossoverCrossTest() {
var target = new PrivateObject(typeof(SinglePointCrossover));
ItemArray<IntegerVector> parents;
TestRandom random = new TestRandom();
bool exceptionFired;
// The following test checks if there is an exception when there are more than 2 parents
random.Reset();
parents = new ItemArray<IntegerVector>(new IntegerVector[] { new IntegerVector(5), new IntegerVector(6), new IntegerVector(4) });
exceptionFired = false;
try {
IntegerVector actual;
actual = (IntegerVector)target.Invoke("Cross", random, parents);
}
catch (System.ArgumentException) {
exceptionFired = true;
}
Assert.IsTrue(exceptionFired);
// The following test checks if there is an exception when there are less than 2 parents
random.Reset();
parents = new ItemArray<IntegerVector>(new IntegerVector[] { new IntegerVector(4) });
exceptionFired = false;
try {
IntegerVector actual;
actual = (IntegerVector)target.Invoke("Cross", random, parents);
}
catch (System.ArgumentException) {
exceptionFired = true;
}
Assert.IsTrue(exceptionFired);
}
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:30,代码来源:SinglePointCrossoverTest.cs
示例6: ItShouldBePossibleToRegisterAMessageFromAChildThreadAutomatically
public void ItShouldBePossibleToRegisterAMessageFromAChildThreadAutomatically()
{
var subThread = new MessageThread(true, NullLogger.Create(), "SUBTHREAD");
subThread.SetMaxMessagePerCycle(1);
var subThread2 = new MessageThread(false,NullLogger.Create(), "SUBTHREAD2");
var threadManager = new ThreadManager(NullLogger.Create());
var privateObject = new PrivateObject(threadManager);
threadManager.RunThread();
threadManager.AddThread(subThread);
threadManager.AddThread(subThread2);
Thread.Sleep(100);
Assert.IsTrue(threadManager.Status == RunningStatus.Running);
var result = privateObject.Invoke("IsTypeRegistered", subThread.ThreadName, typeof(TestMessage)) as Boolean?;
Assert.IsNotNull(result);
Assert.AreEqual(true, result);
result = privateObject.Invoke("IsTypeRegistered", subThread2.ThreadName, typeof(TestMessage)) as Boolean?;
Assert.IsNotNull(result);
Assert.AreEqual(false, result);
threadManager.SendMessageToThread(new TestMessage());
Thread.Sleep(1000);
Assert.IsTrue(subThread.MessagesCount==1);
Assert.IsFalse(subThread2.MessagesCount == 1);
Thread.Sleep(100);
threadManager.Terminate();
Thread.Sleep(500);
Assert.IsTrue(threadManager.Status == RunningStatus.Halted);
}
开发者ID:kendarorg,项目名称:ZakFramework,代码行数:30,代码来源:ThreadManagerWithMessagingTest.cs
示例7: 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
示例8: TestIfBombWithSizeFiveExplodesAsExpectedWhenTheBombIsNearTheBottompLeftFieldCorner
public void TestIfBombWithSizeFiveExplodesAsExpectedWhenTheBombIsNearTheBottompLeftFieldCorner()
{
string testFieldSize = "6";
Engine.FieldSizeUnitTestSetter = new StringReader(testFieldSize);
Engine.StartMenu.IsStartGameChosen = true;
Engine gameEngine = new Engine();
Playfield testField = Playfield.Instance;
testField.SetFieldSize(6);
testField.InitializeEmptyField();
testField[1, 5] = new BombCell(5);
PrivateObject enginePrivateInstance = new PrivateObject(gameEngine);
enginePrivateInstance.Invoke("HandleExplosion", testField[1, 5]);
Playfield engineField = (Playfield)enginePrivateInstance.GetFieldOrProperty("playField");
BombCell bomb = new BombCell(5);
bomb.X = 4;
bomb.Y = 4;
engineField[1, 5] = bomb;
enginePrivateInstance.Invoke("ChangeCurrentCell", 1, 5);
enginePrivateInstance.Invoke("HandleExplosion", engineField[1, 5]);
Assert.AreEqual(engineField[2, 5].CellType == CellType.BlownCell, true, "Expected that the cell on coordinates 2,5 is CellType.BlownCell. Received {0} ", engineField.ToString());
}
开发者ID:huuuskyyy,项目名称:Teamworks,代码行数:25,代码来源:EngineTests.cs
示例9: DealFuncGBKFlag_GB2312NormalCharacter
public void DealFuncGBKFlag_GB2312NormalCharacter()//多云转中雨
{
var po = new PrivateObject(new BaseResp(null));
byte[] arg = new byte[] { 27,14,54,96,84,70,87,42,86,80,83,106};
var r = (string)po.Invoke("DealFuncGBKFlag", new object[] { arg });
Assert.AreEqual(r, "多云转中雨");
}
开发者ID:upan,项目名称:ETermSimulator,代码行数:7,代码来源:BaseRespTest.cs
示例10: DealFuncGBKFlag_GB2312SpecialCharacter
public void DealFuncGBKFlag_GB2312SpecialCharacter()////上海地区天气预报 “报” is a special character!
{
var po = new PrivateObject(new BaseResp(null));
byte[] arg = new byte[] { 27,14,73,79,58,35,53,88,71,120,76,108,70,120,84,36,35,40};
var r = (string)po.Invoke("DealFuncGBKFlag", new object[] { arg });
Assert.AreEqual(r, "上海地区天气预报");
}
开发者ID:upan,项目名称:ETermSimulator,代码行数:7,代码来源:BaseRespTest.cs
示例11: TestConstructorAsItShuoldCreateTableWithInitialCapacityOf16
public void TestConstructorAsItShuoldCreateTableWithInitialCapacityOf16()
{
var table = new CustomHashTable<int, int>();
PrivateObject accessor = new PrivateObject(table);
LinkedList<KeyValuePair<int, int>>[] dataPrivateField = (LinkedList<KeyValuePair<int, int>>[])accessor.GetField("data");
Assert.AreEqual(16, dataPrivateField.Length);
}
开发者ID:veselints,项目名称:DSA,代码行数:7,代码来源:CustomHashTableTests.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: GetZeroReturnsZero
public void GetZeroReturnsZero()
{
var summator = new Summator();
var privateObject = new PrivateObject(summator);
var getZeroValue = privateObject.Invoke("GetZero");
Assert.AreEqual(0, getZeroValue);
}
开发者ID:NikolayIT,项目名称:CSharp-Tips-and-Tricks,代码行数:7,代码来源:SummatorUnitTests.cs
示例14: ServerProxy_FallbackOnConnect
public void ServerProxy_FallbackOnConnect()
{
//------------Setup for test--------------------------
var serverProxy = new ServerProxy(new Uri("http://bob"));
var serverGuid = Guid.NewGuid();
PrivateObject p = new PrivateObject(serverProxy);
var wrapped = new Mock<IEnvironmentConnection>();
wrapped.Setup(a => a.DisplayName).Returns("moo");
wrapped.Setup(a => a.Connect(It.IsAny<Guid>())).Throws(new FallbackException());
wrapped.Setup(a => a.WebServerUri).Returns( new Uri("http://bob"));
p.SetField("_wrappedConnection", wrapped.Object);
try
{
serverProxy.Connect(serverGuid);
}
// ReSharper disable EmptyGeneralCatchClause
catch(Exception err)
{
Assert.IsNotNull(err);
}
var con = p.GetField("_wrappedConnection") as IEnvironmentConnection;
Assert.IsNotNull(con);
Assert.AreNotEqual(con,wrapped.Object);
Assert.AreEqual("moo",con.DisplayName);
}
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:30,代码来源:ServerProxyWithFallbackTests.Specs.cs
示例15: TestLabyrinthNoExit1
public void TestLabyrinthNoExit1()
{
int labyrinthRows = 3;
int labyrinthCols = 3;
int positionX = labyrinthRows / 2;
int positionY = labyrinthCols / 2;
char[,] testMatrix = new char[labyrinthRows, labyrinthCols];
testMatrix[0, 0] = '-';
testMatrix[0, 1] = 'x';
testMatrix[0, 2] = '-';
testMatrix[1, 0] = 'x';
testMatrix[1, 1] = '-';
testMatrix[1, 2] = 'x';
testMatrix[2, 0] = '-';
testMatrix[2, 1] = 'x';
testMatrix[2, 2] = '-';
LabyrinthFactory factory = new LabyrinthRectangularFactory();
PrivateObject factoryPrivate = new PrivateObject(factory);
var returnedvalue = factoryPrivate.Invoke("CheckIfAnyExit", testMatrix, positionX, positionY);
Assert.AreEqual(false, returnedvalue);
}
开发者ID:Enlightment,项目名称:Labyrinth7,代码行数:25,代码来源:TestLabyrinthfactory.cs
示例16: CountNeighborStates1x1Grid
public void CountNeighborStates1x1Grid()
{
PrivateObject ATestGrid = new PrivateObject(new GameOfLife(1, 1));
Cell[,] ATestCellGrid = (Cell[,])ATestGrid.GetField("cells");
int[] TestNeighborStates = (int[])ATestGrid.Invoke("CountNeighborStates", new object[] { ATestCellGrid[0, 0] });
CollectionAssert.AreEqual(new int[] { 0, 0 }, TestNeighborStates);
}
开发者ID:sqfish,项目名称:ConwaysGameOfLife,代码行数:7,代码来源:GridTests.cs
示例17: 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
示例18: DealFuncGBKFlag_GBKInfrequentlyUsedCharacter
public void DealFuncGBKFlag_GBKInfrequentlyUsedCharacter()//朱镕基 “镕” is not a frequently used character
{
var po = new PrivateObject(new BaseResp(null));
byte[] arg = new byte[] { 27,14,86, 108, 120, 77, 100, 69, 59, 121 };
var r = (string)po.Invoke("DealFuncGBKFlag", new object[] { arg });
Assert.AreEqual(r, "朱镕基");
}
开发者ID:upan,项目名称:ETermSimulator,代码行数:7,代码来源:BaseRespTest.cs
示例19: TestTryParseRemoteAddressBase
private void TestTryParseRemoteAddressBase(string source)
{
var settingsObject = new PrivateObject(new Settings());
var args = new object[] { source, null, null };
Assert.IsFalse((bool)settingsObject.Invoke("TryParseRemoteAddress", args));
}
开发者ID:nagyist,项目名称:WinDesktop-FlashAir-SnowyImageCopy,代码行数:7,代码来源:SettingsTest.cs
示例20: DealFuncASCIIFlag_Test
public void DealFuncASCIIFlag_Test()
{
var po = new PrivateObject(new BaseResp(null));
byte[] arg = new byte[] {27,15,32,51,50,67,40,57,48,70,41,44,32};
var r = (string)po.Invoke("DealFuncASCIIFlag", new object[] { arg });
Assert.AreEqual(r, " 32C(90F), ");
}
开发者ID:upan,项目名称:ETermSimulator,代码行数:7,代码来源:BaseRespTest.cs
注:本文中的PrivateObject类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论