本文整理汇总了C#中PrivateObject.SetProperty方法的典型用法代码示例。如果您正苦于以下问题:C# PrivateObject.SetProperty方法的具体用法?C# PrivateObject.SetProperty怎么用?C# PrivateObject.SetProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PrivateObject
的用法示例。
在下文中一共展示了PrivateObject.SetProperty方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Expires_NextDay_Test
public void Expires_NextDay_Test()
{
var strategy = Expires.NextDay<string>();
var value = new CachedValue<string>("example", strategy);
var secret = new PrivateObject(value);
Assert.IsFalse(value.IsExpired);
secret.SetProperty("Created", Stopwatch.GetTimestamp() - TimeSpan.TicksPerDay);
Assert.IsTrue(value.IsExpired);
}
示例2: 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);
}
示例3: UpdateCollectionTest
public void UpdateCollectionTest()
{
using (var vm = new MainWindowViewModel())
{
vm.PropertyChanged += FViewModel_PropertyChanged;
var c = new ObservableCollection<CorrOrder>();
c.Add(new CorrOrder(1, ItemType.Fruits, "バナナ", "えええええおおおおお", 1234));
var s = (CollectionView)CollectionViewSource.GetDefaultView(c);
// privateなメンバへアクセスするためアクセスオブジェクトを作成
var obj = new PrivateObject(vm);
obj.SetProperty("GridDataCollectionView", s);
vm.PropertyChanged -= FViewModel_PropertyChanged;
Assert.IsTrue(this.FEventHappened);
}
}
示例4: CreateTestProteins
public static void CreateTestProteins(ISession session, IList<string> testProteinSequences)
{
var bulkInserter = new BulkInserter(session.Connection);
for (int i = 0; i < testProteinSequences.Count; ++i)
{
int id = i + 1;
var protein = new TestProtein()
{
Id = id,
Accession = "PRO" + id.ToString(),
Description = "Protein " + id.ToString(),
Sequence = testProteinSequences[i]
};
var proteinAccessor = new PrivateObject(protein);
proteinAccessor.SetProperty("Length", testProteinSequences[i].Length);
bulkInserter.Add(protein);
}
bulkInserter.Execute();
bulkInserter.Reset("");
}
示例5: RecognizerStatusTest
public void RecognizerStatusTest()
{
// Since we're treating this as the generic Recognizer this is ok
Recognizer recognizer = new AudioRecognizer();
bool eventFired = false;
// Register for the Recognizer StatusChanged Event
recognizer.StatusChanged += (param1, param2) => eventFired = true;
try {
// Simulate the StatusChanged Event with the Error status
PrivateObject privateObject = new PrivateObject(recognizer);
privateObject.SetProperty("Status", RecognizerStatus.Error);
Thread.Sleep(50);
// Make sure the Recognizer Status was updated
Assert.AreEqual(RecognizerStatus.Error, recognizer.Status);
// Make sure the Recognizer StatusChanged Event was fired
Assert.IsTrue(eventFired);
// Reset the event
eventFired = false;
// Simulate the StatusChanged Event with the NotReady status
privateObject.SetProperty("Status", RecognizerStatus.NotReady);
Thread.Sleep(50);
// Make sure the Recognizer Status was updated
Assert.AreEqual(RecognizerStatus.NotReady, recognizer.Status);
// Make sure the Recognizer StatusChanged Event was fired
Assert.IsTrue(eventFired);
// Reset the event
eventFired = false;
// Simulate the StatusChanged Event with the Ready status
privateObject.SetProperty("Status", RecognizerStatus.Ready);
Thread.Sleep(50);
// Make sure the Recognizer Status was updated
Assert.AreEqual(RecognizerStatus.Ready, recognizer.Status);
// Make sure the Recognizer StatusChanged Event was fired
Assert.IsTrue(eventFired);
// Reset the event
eventFired = false;
// Simulate the StatusChanged Event with the Running status
privateObject.SetProperty("Status", RecognizerStatus.Running);
Thread.Sleep(50);
// Make sure the Recognizer Status was updated
Assert.AreEqual(RecognizerStatus.Running, recognizer.Status);
// Make sure the Recognizer StatusChanged Event was fired
Assert.IsTrue(eventFired);
}
catch (Exception ex) {
Assert.Fail(ex.Message);
}
}
示例6: createTestPeptideInstances
private static void createTestPeptideInstances (NHibernate.ISession session, BulkInserter bulkInserter, Peptide pep)
{
// store instances even though the association is inverse:
// the PeptideModification.Offset property needs access to the protein sequence
pep.Instances = new List<PeptideInstance>();
foreach (Protein pro in session.Query<Protein>())
{
int start = pro.Sequence.IndexOf(pep.Sequence, 0);
while (start >= 0)
{
int end = start + pep.Sequence.Length;
bool nTerminusIsSpecific = start == 0 || pro.Sequence[start - 1] == 'K' || pro.Sequence[start - 1] == 'R';
bool cTerminusIsSpecific = end == pro.Sequence.Length || pro.Sequence[end - 1] == 'K' || pro.Sequence[end - 1] == 'R';
var instance = new TestPI()
{
Peptide = pep,
Protein = pro,
Offset = start,
Length = pep.Sequence.Length,
MissedCleavages = pep.Sequence.ToCharArray(0, pep.Sequence.Length - 1).Count(o => o == 'K' || o == 'R'),
NTerminusIsSpecific = nTerminusIsSpecific,
CTerminusIsSpecific = cTerminusIsSpecific,
};
var instanceAccessor = new PrivateObject(instance);
instanceAccessor.SetProperty("SpecificTermini", (nTerminusIsSpecific ? 1 : 0) + (cTerminusIsSpecific ? 1 : 0));
bulkInserter.Add(instance);
pep.Instances.Add(instance);
start = pro.Sequence.IndexOf(pep.Sequence, start + 1);
}
}
if (pep.Instances.Count == 0)
throw new ArgumentException("peptide " + pep.Sequence + " does not occur in any proteins");
}
示例7: UpdateConnectionStringSslEnabledSlaveOkEnabledTest
public void UpdateConnectionStringSslEnabledSlaveOkEnabledTest()
{
PrivateObject p = new PrivateObject(typeof(MongoConnectionManager));
p.SetField("_serverName", "db1");
p.SetField("_password", "pass1");
p.SetField("_userName", "user1");
p.SetField("_ssl", true);
p.SetProperty("SlaveOk", true);
p.Invoke("UpdateConnectionString", null);
Assert.AreEqual((string)p.GetField("_connectionString"), "mongodb://user1:[email protected]/?connect=direct;slaveok=true;ssl=true;sslverifycertificate=false");
}
示例8: OnGestureRecognizedTest
public void OnGestureRecognizedTest()
{
try {
GestureRecognizer recognizer = new GestureRecognizer(_directoryPath);
bool syncEventFired = false;
bool waveCallbackInvoked = false;
bool shakeCallbackInvoked = false;
// Set the Sync Gesture
PrivateObject privateObject = new PrivateObject(recognizer);
privateObject.SetProperty("SyncGesture", new IavaGesture("Sync", new List<IavaSnapshot>()));
// Register for some Gestures
recognizer.Synced += (parm1, param2) => { syncEventFired = true; };
recognizer.Subscribe("Wave", (eventArgs) => { waveCallbackInvoked = true; });
recognizer.Subscribe("Shake", (eventArgs) => { shakeCallbackInvoked = true; });
recognizer.Start();
try {
// Recognize the Wave gesture
privateObject.Invoke("OnGestureRecognized", null, new GestureEventArgs("Wave"));
Thread.Sleep(50);
// Make sure the Wave callback fired
Assert.IsTrue(waveCallbackInvoked);
}
catch (Exception ex) {
Assert.Fail(ex.Message);
}
try {
// Recognize the Shake gesture
privateObject.Invoke("OnGestureRecognized", null, new GestureEventArgs("Shake"));
Thread.Sleep(50);
// Make sure the Shake callback fired
Assert.IsTrue(shakeCallbackInvoked);
}
catch (Exception ex) {
Assert.Fail(ex.Message);
}
try {
// Recognize the Sync gesture
privateObject.Invoke("OnGestureRecognized", null, new GestureEventArgs("Sync"));
Thread.Sleep(50);
// Make sure the Sync event fired,
Assert.IsTrue(syncEventFired);
}
catch (Exception ex) {
Assert.Fail(ex.Message);
}
try {
// Reset the Sync, Wave, and Shake callbacks
syncEventFired = false;
waveCallbackInvoked = false;
shakeCallbackInvoked = false;
// Recognize the Wave gesture again
privateObject.Invoke("OnGestureRecognized", null, new GestureEventArgs("Wave"));
Thread.Sleep(50);
// Make sure the Wave callback fired
Assert.IsTrue(waveCallbackInvoked);
// Recognize the Shake gesture again
privateObject.Invoke("OnGestureRecognized", null, new GestureEventArgs("Shake"));
Thread.Sleep(50);
// Make sure the Shake callback fired
Assert.IsTrue(shakeCallbackInvoked);
}
catch (Exception ex) {
Assert.Fail(ex.Message);
}
recognizer.Stop();
}
catch (Exception ex) {
Assert.Fail(ex.Message);
}
}
示例9: GestureSyncUnsyncTest
public void GestureSyncUnsyncTest()
{
try {
GestureRecognizer recognizer = new GestureRecognizer(_directoryPath);
bool syncEventFired = false;
bool unsyncEventFired = false;
// Register for the Synced and Unsynced events
recognizer.Synced += (param1, param2) => syncEventFired = true;
recognizer.Unsynced += (param1, param2) => unsyncEventFired = true;
recognizer.Start();
// Set the Sync Timeout to 5 seconds
recognizer.SyncTimeoutValue = 5000;
// Set the Sync Gesture
PrivateObject privateObject = new PrivateObject(recognizer);
privateObject.SetProperty("SyncGesture", new IavaGesture("Sync", new List<IavaSnapshot>()));
// Recognize the 'Sync' Gesture
privateObject.Invoke("OnGestureRecognized", null, new GestureEventArgs("Sync"));
Thread.Sleep(50);
// Make sure the Sync Event fired
Assert.IsTrue(syncEventFired);
// Make sure the Unsync Event did not fire
Assert.IsFalse(unsyncEventFired);
// Reset the sync event
syncEventFired = false;
// Wait for the timeout to occur
Thread.Sleep(recognizer.SyncTimeoutValue);
// Make sure the Unsync Event fired
Assert.IsTrue(unsyncEventFired);
// Make sure the Sync Event did not fire
Assert.IsFalse(syncEventFired);
recognizer.Stop();
}
catch (Exception ex) {
Assert.Fail(ex.Message);
}
}