本文整理汇总了C#中PrivateObject类的典型用法代码示例。如果您正苦于以下问题:C# PrivateObject类的具体用法?C# PrivateObject怎么用?C# PrivateObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PrivateObject类属于命名空间,在下文中一共展示了PrivateObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
}
示例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();
}
示例4: Init
public void Init()
{
c = new Customer();
pc = new PrivateObject(c);
ac = new Account();
c.AddAccount(ac);
}
示例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);
}
示例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);
}
示例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);
}
示例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());
}
示例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, "多云转中雨");
}
示例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, "上海地区天气预报");
}
示例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);
}
示例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());
}
示例13: GetZeroReturnsZero
public void GetZeroReturnsZero()
{
var summator = new Summator();
var privateObject = new PrivateObject(summator);
var getZeroValue = privateObject.Invoke("GetZero");
Assert.AreEqual(0, getZeroValue);
}
示例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);
}
示例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);
}