本文整理汇总了C#中PrivateType.InvokeStatic方法的典型用法代码示例。如果您正苦于以下问题:C# PrivateType.InvokeStatic方法的具体用法?C# PrivateType.InvokeStatic怎么用?C# PrivateType.InvokeStatic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PrivateType
的用法示例。
在下文中一共展示了PrivateType.InvokeStatic方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReplaceNulls
public void ReplaceNulls()
{
PrivateType internalAssertEx = new PrivateType(typeof(AssertEx));
object oNull = null;
Assert.AreEqual("(null)", internalAssertEx.InvokeStatic("ReplaceNulls", oNull), "AssertEx.ReplaceNulls didn't return the correct value.");
Assert.AreEqual("teststring", internalAssertEx.InvokeStatic("ReplaceNulls", "teststring"), "AssertEx.ReplaceNulls didn't return the correct value.");
Assert.AreEqual("test\\0string", internalAssertEx.InvokeStatic("ReplaceNulls", "test\0string"), "AssertEx.ReplaceNulls didn't return the correct value.");
}
示例2: KeyGenerationTest
public void KeyGenerationTest()
{
PrivateType pt = new PrivateType(typeof(AsymmetricBlobCryptoProvider));
byte[] key = (byte[])pt.InvokeStatic("GenerateRandomKey");
byte[] encryptedKey;
byte[] decryptedKey;
var rsa = new RSACryptoServiceProvider();
rsa.ImportCspBlob(testCspBlob);
using (ICspProxy cspProxy = new DisposingCspProxy(rsa, rsa.KeySize))
{
encryptedKey = cspProxy.Encrypt(key);
decryptedKey = cspProxy.Decrypt(encryptedKey);
}
// The two keys shouldn't be the same...
Assert.IsFalse(key.SequenceEqual(encryptedKey));
// And we expect it to grow to the same size as the RSA Key
Assert.IsTrue(encryptedKey.Length == 4096 / 8);
// Sanity check, it should be 256 bit / 32 bytes and not contain any zeros.
Assert.IsTrue(decryptedKey.Length == 256/8, "Key length is incorrect");
Assert.IsTrue(decryptedKey[0] != 0, "Key starts with an empty byte");
// And of course, the round tripped key should match original
Assert.IsTrue(key.SequenceEqual(decryptedKey));
}
开发者ID:DataWingSoftware,项目名称:azure-encryption-extensions,代码行数:30,代码来源:AsymmetricBlobCryptoProviderTests.cs
示例3: TestIfCorrectNumbersOfMinesAreCreated
public void TestIfCorrectNumbersOfMinesAreCreated()
{
PrivateType privateType = new PrivateType(typeof(GameBoardGenerator));
var fieldSize = 1;
int startRandomRange = ((15 * fieldSize * fieldSize) / 100) + 1;
int endRandomRange = ((30 * fieldSize * fieldSize) / 100) + 1;
int randomCheck = (int)privateType.InvokeStatic("RandomGenerator", startRandomRange, endRandomRange);
Assert.IsTrue(randomCheck >= 1);
}
示例4: TestGetDestFilePath_NoExtensions
public void TestGetDestFilePath_NoExtensions()
{
const string expected = @"C:\Garmin\Activities\1990-01-01-00-00-00_duplicated";
const string srcPath = @"C:\Garmin\Activities\1990-01-01-00-00-00";
var pt = new PrivateType(typeof(Program));
var actual = (string)pt.InvokeStatic("GetDestFilePath", new object[] { srcPath });
Assert.AreEqual(expected, actual);
}
示例5: TestKernel
public void TestKernel()
{
var kernel = (IKernel)inboxWatcherPrivateObject.Invoke("ConfigureNinject");
var pvtType = new PrivateType(typeof(InboxWatcher.InboxWatcher));
var configs = (List <ImapMailBoxConfiguration> ) pvtType.InvokeStatic("GetConfigs");
var client = kernel.Get<IImapFactory>(new ConstructorArgument("configuration", configs[0]));
var imapMailBox = kernel.Get<IImapMailBox>(new ConstructorArgument("config", configs[0]));
Debugger.Break();
}
示例6: V2MasterPasswordIsUniqueTest
public void V2MasterPasswordIsUniqueTest()
{
string key1 = CalculateNewMasterPasswordKey(MASTERPASSWORD);
string key2 = CalculateNewMasterPasswordKey(MASTERPASSWORD);
Assert.AreNotEqual(key1, key2, "generated master password key always equals.");
var accessor = new PrivateType(typeof(PasswordFunctions2));
byte[] keySalt = (byte[])accessor.InvokeStatic("CreateRandomKeySalt", new Object[] {});
key1 = CalculateV2Key(accessor, keySalt);
key2 = CalculateV2Key(accessor, keySalt);
Assert.AreEqual(key1, key2, "generated master password doesn't equal.");
}
示例7: GetName_StaticMethodTest
public void GetName_StaticMethodTest()
{
//arrange
string name = "Abhishek";
int age = 30;
Salary osalary = new Salary(name, age);
//act
PrivateType pType = new PrivateType(typeof(Salary));
string returnValue = pType.InvokeStatic("GetName", osalary) as string;
//assert
Assert.AreEqual(name, returnValue);
}
示例8: TestNullate01
public void TestNullate01() {
PrivateType nullateClass = new PrivateType(typeof(CFGtoCNF));
var production = CFGParser.Production("<S> -> <A> 'b' <B> [1]");
var nullableDictionary = new Dictionary<Nonterminal, double> {
{ Nonterminal.Of("A"), 0.5 },
{ Nonterminal.Of("B"), 0.2 }
};
var actualList = (List<Production>)nullateClass.InvokeStatic("Nullate", new object[] { production, nullableDictionary });
var actual = new HashSet<string>(actualList.Select((p) => p.ToString()));
var expected = new HashSet<string> {
CFGParser.Production("<S> -> <A> 'b' <B> [0.4]").ToString(),
CFGParser.Production("<S> -> <A> 'b' [0.1]").ToString(),
CFGParser.Production("<S> -> 'b' <B> [0.4]").ToString(),
CFGParser.Production("<S> -> 'b' [0.1]").ToString(),
};
Assert.IsTrue(actual.SetEquals(expected));
}
示例9: Quantization_Test
public void Quantization_Test()
{
PrivateType pt = new PrivateType(typeof(JpegImage));
JpegImage ji = new JpegImage(new Bitmap(200, 100), 100, 4);
float[,] inputValues = new float[8, 8];
int i = 0;
for (int x = 0; x < 8; x++) //Fill input value with values from 0 to 63
{
for (int y = 0; y < 8; y++)
{
inputValues[x, y] = i++;
}
}
short[,] quantizedValues =
(short[,]) pt.InvokeStatic("_quantization", new object[] {inputValues, ji.YQuantizationTable});
short[,] expectedQuantizedValues = new short[8, 8]
{
{0, 1, 2, 3, 2, 1, 1, 0},
{8, 9, 10, 5, 6, 3, 1, 1},
{16, 17, 9, 9, 5, 3, 2, 2},
{12, 12, 8, 9, 4, 3, 3, 2},
{10, 11, 6, 5, 4, 3, 3, 2},
{8, 5, 6, 4, 3, 3, 3, 3},
{8, 7, 6, 5, 4, 3, 3, 4},
{8, 9, 8, 8, 6, 5, 5, 5},
};
Assert.AreEqual(expectedQuantizedValues, quantizedValues);
}
示例10: TestTwoPairDetection
public void TestTwoPairDetection()
{
var handEvaluator = new PrivateType(typeof(HandEvaluator));
Assert.IsTrue((bool)handEvaluator.InvokeStatic("ContainsTwoPairs", TwoPair.Cards), "Two pair error", "Failed to detect two pairs in a hand.");
Assert.IsFalse((bool)handEvaluator.InvokeStatic("ContainsTwoPairs", OnePair.Cards), "Two pair error", "Detected two pair when given one pair");
Assert.IsFalse((bool)handEvaluator.InvokeStatic("ContainsTwoPairs", HighCard.Cards), "Two pair error", "Detected a high card hand as two pairs.");
}
示例11: TestSetDetection
public void TestSetDetection()
{
var handEvaluator = new PrivateType(typeof(HandEvaluator));
Assert.IsTrue((bool)handEvaluator.InvokeStatic("ContainsSetOfSizeX", 4, FourOfAKindHighCard.Cards), "Set Identification error.", "Failed to properly identify a four of a kind.");
Assert.IsFalse((bool)handEvaluator.InvokeStatic("ContainsSetOfSizeX", 2, StraightNoAce.Cards), "Set Identification error.", "Detected a two of a kind when given a straight.");
}
示例12: TestFlushDetection
public void TestFlushDetection()
{
var handEvaluator = new PrivateType(typeof(HandEvaluator));
Assert.IsTrue((bool)handEvaluator.InvokeStatic("IsFlush", Flush.Cards), "Flush Error", "Failed to identify a flush.");
Assert.IsFalse((bool)handEvaluator.InvokeStatic("IsFlush", StraightNoAce.Cards), "Flush Error", "Falsely identified a non flush hand as flush.");
}
示例13: NumberEncoder_Test
public void NumberEncoder_Test()
{
PrivateType pt = new PrivateType(typeof(JpegImage));
short input = -1;
ushort expected = 65534; // 11111111 11111110
ushort output = (ushort)pt.InvokeStatic("_numberEncoder", input);
Assert.AreEqual(expected, output);
}
示例14: Bitcost_Test
public void Bitcost_Test()
{
PrivateType pt = new PrivateType(typeof(JpegImage));
short input = 2;
byte expected = 2;
byte output = (byte)pt.InvokeStatic("_bitCost", input);
Assert.AreEqual(expected, output);
}
示例15: SwapVertexData
public void SwapVertexData()
{
PrivateType pt = new PrivateType(typeof(JpegImage));
Vertex
inputV1 = new Vertex(0, 1, 0, 4),
inputV2 = new Vertex(2, 3, 0, 4),
expectedV1 = new Vertex(2, 1, 0, 4),
expectedV2 = new Vertex(0, 3, 0, 4);
Edge
inputE1 = new Edge(inputV1, inputV2, 0, true, true),
expectedE1 = new Edge(expectedV1, expectedV2, 0, true, true);
pt.InvokeStatic("_swapVertexData", inputE1);
Assert.AreEqual(expectedE1.ToString(), inputE1.ToString());
}