public MainWindow() { Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); InitializeComponent(); Uri uri = new Uri("DataTemplates.xaml", System.UriKind.Relative); ResourceDictionary resourceDico = (ResourceDictionary)System.Windows.Application.LoadComponent(uri); Resources.MergedDictionaries.Add(resourceDico); EditorLink.Instance.Init(this.renderControl.Handle, Resources); this.renderControl.Paint += new PaintEventHandler(simpleOpenGlControl_Paint); CompositionTargetEx.FrameUpdating += new EventHandler<RenderingEventArgs>(CompositionTargetEx_FrameUpdating); List<ObjectLink> entityList = new List<ObjectLink>(); entityList.Add(EditorLink.Instance.SpawnEntity(-10.0f, 0, 0)); entityList.Add(EditorLink.Instance.SpawnEntity(10.0f, 0, 0)); SimpleTest[] obj = new SimpleTest[2]; obj[0] = new SimpleTestA(); obj[1] = new SimpleTestB(); myPropertyGrid.SelectedObjects = entityList.ToArray(); propertygrid2.SelectedObjects = entityList.ToArray(); // o.PropertyChanged += new PropertyChangedEventHandler(o_PropertyChanged); }
public static int Main() { SimpleTest.Prefix("foo", "1"); string s = "foo".Prefix("1"); Type ex_attr = typeof(System.Runtime.CompilerServices.ExtensionAttribute); if (!typeof(SimpleTest).IsDefined(ex_attr, false)) { return(1); } if (!typeof(SimpleTest).Assembly.IsDefined(ex_attr, false)) { return(2); } if (!typeof(SimpleTest).GetMethod("Prefix").IsDefined(ex_attr, false)) { return(3); } if (s != "1foo") { return(9); } Console.WriteLine(s); return(0); }
public void DRT_TestValidator(SimpleTest test, Type expectedExceptionType) { try { test(); } catch (Exception ex) { if (expectedExceptionType != null && expectedExceptionType == ex.GetType()) { return; } else { // otherwise we got an unexpected exception DRT.Assert(false, "XAML Test '{0}' failed.{1}", test.Method.Name, ex.ToString()); return; } } if (expectedExceptionType != null) { DRT.Assert(false, "XAAML Test '{0}' did not throw expected exception of type '{1}'.", test.Method.Name, expectedExceptionType); } }
//create a simple test public static WebResult AddSimpleTest(SimpleTest newtest) { using (Entities e = new Entities()) { WebResult wb = new WebResult(); try { //add new test var t = e.tests.Add(TestCasting.TestToDAL(newtest.test)); //add classes o the new test t.classes = ClassCasting.ClassesToDAL(newtest.classes); //add questions to the new test t.questions = QuestionCasting.QuestionsToDAL(newtest.questions); wb.status = true; wb.message = "succeed"; wb.value = TestCasting.TestToDTO(t); e.SaveChanges(); return(wb); } catch (Exception ex) { wb.status = false; wb.message = ex.Message; return(wb); } } }
private void RunMethodTest() { SimpleTest test = TestDelegate; if (ExpectedExceptionType == null) { test(); } // otherwise some sort of exception is expected else { try { test(); } catch (Exception e) { if (ExpectedExceptionType == e.GetType()) { // TODO: Bug 736396 //if((ExpectedInnerExceptionType == null && e.InnerException == null) || (ExpectedInnerExceptionType == e.InnerException.GetType())) return; } throw new InvalidOperationException("Wrong Exception was thrown", e); } throw new InvalidOperationException(String.Format("Expected exception {0} was not thrown", ExpectedExceptionType.ToString())); } }
public static DrtTest DRT_MakeTest(XamlTestSuite suiteInstance, XamlTestInfoBlock testBlk) { DrtTest drtTest = null; string name = testBlk.Name; if (testBlk.TestDelegate != null) { SimpleTest test = testBlk.TestDelegate; drtTest = new DrtTest(() => suiteInstance.DRT_TestValidator( test, testBlk.ExpectedExceptionType)); } else { string xamlString = testBlk.XamlString; XamlStringParser loader = testBlk.StringParserDelegate; PostTreeValidator validator = testBlk.TreeValidatorDelegate; Type expectedExceptionType = testBlk.ExpectedExceptionType; drtTest = new DrtTest(() => suiteInstance.DRT_XamlLoader( name, xamlString, loader, expectedExceptionType, validator)); } return(drtTest); }
private PgpSecretKeyRing loadSecretKey( string keyName) { Stream fIn = SimpleTest.GetTestDataAsStream("openpgp.dsa.keys." + keyName); return(new PgpSecretKeyRing(fIn)); }
public XamlTestInfoBlock(string name, SimpleTest test, Type expectedExceptionType, Type expectedInnerExceptionType) { _name = name; _test = test; _expectedExceptionType = expectedExceptionType; _expectedInnerExceptionType = expectedInnerExceptionType; }
private PgpObjectFactory loadSig( string sigName) { Stream fIn = SimpleTest.GetTestDataAsStream("openpgp.dsa.sigs." + sigName); return(new PgpObjectFactory(fIn)); }
public static void Main(string[] args) { foreach (ITest test in tests) { SimpleTest.RunTest(test); } }
static void Main(string[] args) { var test = new SimpleTest(); test.Setup(); test.Execute(); }
private X509Crl LoadCrl( string crlName) //throws Exception { X509Crl crl = (X509Crl)certs[crlName]; if (crl != null) { return(crl); } Stream fs = null; try { fs = SimpleTest.GetTestDataAsStream("PKITS.crls." + crlName + ".crl"); crl = new X509CrlParser().ReadCrl(fs); crls[crlName] = crl; return(crl); } catch (Exception) { throw new InvalidOperationException("exception loading CRL: " + crlName); } finally { fs.Close(); } }
private X509Certificate LoadCert( string certName) { X509Certificate cert = (X509Certificate)certs[certName]; if (cert != null) { return(cert); } Stream fs = null; try { fs = SimpleTest.GetTestDataAsStream("PKITS.certs." + certName + ".crt"); cert = new X509CertificateParser().ReadCertificate(fs); certs[certName] = cert; return(cert); } catch (Exception e) { throw new InvalidOperationException("exception loading certificate " + certName + ": " + e); } finally { fs.Close(); } }
public static void AppendToReport(SimpleTest simpleTest) { VerifyFile(); //Debug.Log("<color=red>Verified</color>"); File.WriteAllLines(reportFileName, simpleTest.dataCollected.Select(x => x.Key + ";" + x.Value).ToArray()); //Debug.Log("<color=red>Saved</color>"); }
public void MeasureSimpleCall_None_Equal() { SimpleTest.SimpleCall(); var actual = tracer.GetTraceResult().Threads[0].Methods[0]; var expected = new MethodTraceResult("SimpleTest", "SimpleCall"); CheckEqual(expected, actual); }
static void Main(string[] args) { SimpleTest simpleTest = new SimpleTest(); simpleTest.StatusChanged += SimpleTest_StatusChanged; simpleTest.Execute(); Console.ReadLine(); }
private void RunTests(IStreamCipher hc, string fileName) { Stream resource = SimpleTest.GetTestDataAsStream( "hc256." + fileName.Replace('/', '.')); PeekableLineReader r = new PeekableLineReader(resource); RunAllVectors(hc, fileName, r); }
protected void Page_Load(object sender, EventArgs e) { SimpleTest testComponent = new SimpleTest(); SimpleTest2 testComponent2 = new SimpleTest2(); lblResult.Text = testComponent.GetInfo("Hello") + "<br><br>"; lblResult.Text += testComponent2.GetInfo("Bye"); }
public void MeasureSimpleCall_None_Equal() { SimpleTest.SimpleCall(); var actual = _tracer.GetTraceResult()[0].MethodList[0]; var expected = new TraceResult("SimpleCall", "SimpleTest"); Equals(actual, expected); }
static public void NestedCall() { tracer.StartTrace(); SimpleTest.SimpleCall(); tracer.StopTrace(); }
internal static PemObject LoadPemResource(string resource) { Stream s = SimpleTest.GetTestDataAsStream("tls." + resource); PemReader p = new PemReader(new StreamReader(s)); PemObject o = p.ReadPemObject(); p.Reader.Close(); return(o); }
private X509Certificate loadCert( string certName) { Stream s = SimpleTest.GetTestDataAsStream("rsa3." + certName); TextReader tr = new StreamReader(s); PemReader rd = new PemReader(tr); return((X509Certificate)rd.ReadObject()); }
public void Simple_ClassSerializationTest() { SimpleTest test = new SimpleTest(); test.Setup(); MyTestSerializeRun(test); SimpleTest result = MyTestDeserializeRun<SimpleTest>(); Assert.AreEqual(test, result); }
public IEnumerable CollectTestVectors() { ArrayList testVectors = new ArrayList(); string curve = null; BigInteger k = null; BigInteger x = null; BigInteger y = null; using (StreamReader r = new StreamReader(SimpleTest.GetTestDataAsStream("crypto.nist_ecc.txt"))) { string line; while (null != (line = r.ReadLine())) { Regex capture = new Regex(@"^ ?(\w+):? =? ?(\w+)", RegexOptions.Compiled); Match data = capture.Match(line); if (!data.Success) { continue; } string nistKey = data.Groups[1].Value; string nistValue = data.Groups[2].Value; switch (nistKey) { case "Curve": // Change curve name from LNNN to L-NNN ie: P256 to P-256 curve = nistValue.Insert(1, "-"); break; case "k": k = new BigInteger(nistValue, 10); break; case "x": x = new BigInteger(nistValue, 16); break; case "y": y = new BigInteger(nistValue, 16); break; } if (null != curve && null != k && null != x && null != y) { testVectors.Add(new object[] { curve, k, x, y }); k = null; x = null; y = null; } } } return(testVectors); }
static int Main() { SanityTest.Run(); SimpleTest.Run(); TestInapplicableCatch.Run(); TestEmptyFinally.Run(); TestStaticField.Run(); TestIntConstant.Run(); return(100); }
public void TestMethod1() { //Arrange ( Create objects and prepare everything needed to test functionality ) SimpleTest maths = new SimpleTest(); //Act ( Execute and get the output ) int result = maths.Add(6, 5); //Assert ( Compare final output with expected Output ) Assert.AreEqual <int>(11, result); }
public void PreserveValue_DoesNotScrubTheMarkedValue() { const string expectedValue = "Keep me the same!"; var simpleTest = new SimpleTest { KeepMeTheSame = expectedValue }; ShamWow.Processor.IShamWow processor = ShamWow.Processor.ShamWowEngine.GetFactory().Create(simpleTest, Constants.ScrubMode.Marked); processor.Scrub(); var cleanedData = (SimpleTest)processor.CleanData(); Assert.Equal(expectedValue, cleanedData.KeepMeTheSame); }
public void CheckCmsTimeVsX509Time() { DateTime now = DateTime.UtcNow; // Time classes only have a resolution of seconds now = SimpleTest.MakeUtcDateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second); Org.BouncyCastle.Asn1.Cms.Time cmsTime = new Org.BouncyCastle.Asn1.Cms.Time(now); Org.BouncyCastle.Asn1.X509.Time x509Time = new Org.BouncyCastle.Asn1.X509.Time(now); // Assert.AreEqual(cmsTime.Date, x509Time.ToDateTime()); Assert.AreEqual(now, cmsTime.Date); Assert.AreEqual(now, x509Time.ToDateTime()); }
public void TestVectors() { using (StreamReader r = new StreamReader(SimpleTest.GetTestDataAsStream("crypto.SHA3TestVectors.txt"))) { String line; while (null != (line = ReadLine(r))) { if (line.Length != 0) { TestVector v = ReadTestVector(r, line); RunTestVector(v); } } } }
public static IEnumerable <XamlTestInfoBlock> TestMethods(object suiteInstance, bool excludeKnownFailures) { Type testClass = suiteInstance.GetType(); SimpleTest setup = null; foreach (MethodInfo method in testClass.GetMethods(methodBF)) { if (IsSetupMethod(method)) { setup = (SimpleTest)Delegate.CreateDelegate(typeof(SimpleTest), suiteInstance, method, true); break; //take the first setup method it finds } } foreach (MethodInfo method in testClass.GetMethods(methodBF)) { if (IsTestMethod(method)) { var testKnownFailureAttr = GetTestKnownFailureAttribute(method); if (excludeKnownFailures && testKnownFailureAttr != null) { Console.WriteLine($"Excluding known failure: Method: {method.Name} Owner: {testKnownFailureAttr.Reason}"); continue; // Exclude Known Failures } SimpleTest test = (SimpleTest)Delegate.CreateDelegate(typeof(SimpleTest), suiteInstance, method, true); if (setup != null) { test = (SimpleTest)Delegate.Combine(setup, test); } string name = String.Format("{0}.{1}", testClass.Name, method.Name); Type expectedExceptionType = GetExpectedException(method); var testBlock = new XamlTestInfoBlock(name, test, expectedExceptionType); if (testKnownFailureAttr != null) { testBlock.IsTestKnownFailure = true; testBlock.OwnerName = testKnownFailureAttr.Reason; } yield return(testBlock); } } }
public IHttpActionResult AddSimpleTest([FromBody] SimpleTest newtest) { try { if (ModelState.IsValid) { return(Ok(TestLogic.AddSimpleTest(newtest))); } var errors = ModelState.Select(x => x.Value.Errors) .Where(y => y.Count > 0) .ToList(); return(BadRequest(errors.ToString())); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public void TestVectors() { using (StreamReader sr = new StreamReader(SimpleTest.GetTestDataAsStream("scrypt.TestVectors.txt"))) { int count = 0; string line = sr.ReadLine(); while (line != null) { ++count; string header = line; StringBuilder data = new StringBuilder(); while (!IsEndData(line = sr.ReadLine())) { data.Append(line.Replace(" ", "")); } int start = header.IndexOf('(') + 1; int limit = header.LastIndexOf(')'); string argStr = header.Substring(start, limit - start); string[] args = argStr.Split(','); byte[] P = ExtractQuotedString(args[0]); byte[] S = ExtractQuotedString(args[1]); int N = ExtractInteger(args[2]); int r = ExtractInteger(args[3]); int p = ExtractInteger(args[4]); int dkLen = ExtractInteger(args[5]); byte[] expected = Hex.Decode(data.ToString()); // This skips very expensive test case(s), remove check to re-enable if (N <= 16384) { byte[] result = SCrypt.Generate(P, S, N, r, p, dkLen); if (!AreEqual(expected, result)) { Fail("Result does not match expected value in test case " + count); } } } } }
public void TestPost(SimpleTest test) { var text = "Hello World"; var request = PostPuppy.CreateRequest (test.Flags, test.TransferMode, text); var response = (HttpWebResponse)request.GetResponse (); try { Assert.AreEqual (HttpStatusCode.OK, response.StatusCode, "#1"); var puppy = PostPuppy.Read (response); if (test.TransferMode != TransferMode.Chunked) { Assert.AreEqual (text.Length, puppy.ContentLength, "#2a"); Assert.AreEqual (text, puppy.SimpleBody, "#3a"); Assert.IsNull (puppy.FullBody, "#4b"); } else { Assert.AreEqual (-1, puppy.ContentLength, "#2b"); Assert.IsNull (puppy.SimpleBody, "#3b"); Assert.AreEqual (text, puppy.FullBody, "#4"); } } finally { response.Close (); } }
public void TestGet(SimpleTest test) { GetPuppy.Get (test.Flags, test.TransferMode); Assert.Pass (); }