10using System.Reflection;
13using System.Collections.Generic;
16using Microsoft.VisualStudio.TestTools.UnitTesting;
19using TestClass = NUnit.Framework.TestFixtureAttribute;
20using TestInitialize = NUnit.Framework.SetUpAttribute;
21using TestCleanup = NUnit.Framework.TearDownAttribute;
22using TestMethod = NUnit.Framework.TestAttribute;
60 Assert.IsInstanceOfType(ex.InnerException, typeof(MemberAccessException),
"Inner should be a MemberAccessException");
61 Assert.IsInstanceOfType(ex.InnerException.InnerException, typeof(NotSupportedException),
"Inner inner should be a NotSupportedException");
64 Assert.IsInstanceOfType(typeof(MemberAccessException), ex.InnerException,
"Inner should be a MemberAccessException");
65 Assert.IsInstanceOfType(typeof(NotSupportedException), ex.InnerException.InnerException,
"Inner inner should be a NotSupportedException");
73 Dictionary<string, List<int>> table =
new Dictionary<string, List<int>>();
75 table.Add(
"Column1",
new List<int>());
76 table[
"Column1"].Add(1);
77 table[
"Column1"].Add(2);
79 Assert.AreEqual(1, returnValue,
"table.Rows");
81 Assert.AreEqual(2, returnValue,
"rows");
83 Assert.AreEqual(3, returnValue,
"string[]");
85 Assert.AreEqual(4, returnValue,
"1, rows");
87 Assert.AreEqual(5, returnValue,
"1, string[]");
94 Assert.AreEqual(returnValue, 1);
96 Assert.AreEqual(returnValue, 1);
98 Assert.AreEqual(returnValue, 1);
106 Assert.AreEqual(returnValue1, 1);
108 Assert.AreEqual(returnValue2, 2);
110 Assert.AreEqual(returnValue3, 2);
113 Assert.AreEqual(returnValue1, 1);
115 Assert.AreEqual(returnValue2, 2);
117 Assert.AreEqual(returnValue3, 2);
124 public void CallDynamicIsFasterThanReflectionSuccess()
128 TimeSpan dynamicTime, reflectionTime;
129 var start = DateTime.Now;
130 for (
int x = 0; x < times; x++)
134 var end = DateTime.Now;
135 dynamicTime = end - start;
137 start = DateTime.Now;
138 for (
int x = 0; x < times; x++)
140 var doSuccess = this.GetType().GetMethod(
"DoSuccess", BindingFlags.Instance | BindingFlags.Public);
141 doSuccess.Invoke(
this,
null);
144 reflectionTime = end - start;
146 Assert.IsTrue(dynamicTime < reflectionTime,
string.Format(
"Dynamic {0} should be faster than reflection {1}", dynamicTime, reflectionTime));
155 MemoryStream ms =
new MemoryStream();
156 var t = this.GetType();
157 var
foo = t.GetMethod(
"foo");
164 MemoryStream ms =
new MemoryStream();
165 var t = this.GetType();
166 var
foo = t.GetMethod(
"foo");
170 public void foo(MemoryStream ms)
175 Assert.IsInstanceOfType(ms, typeof(MemoryStream));
177 Assert.IsInstanceOfType(typeof(MemoryStream), ms);
187 throw new NotSupportedException(
"DoException");
198 throw new MemberAccessException(
"DoInnerException", ex);
217 public int GetData(
int x, Dictionary<
string, List<int>> rows)
222 public int GetData(
int x, params
string[] rows)
This exception is returned from the CallMethod method in the server-side DataPortal and contains the ...
int GetData(params int[] rows)
void foo(MemoryStream ms)
void CallInnerException()
void CallSuccessArrayParameters()
void CallSuccessInheritedMethods()
int MethodWithParams(params object[] e)
void CallWithValidParameterTypeSucceeds()
void CallWithInvalidParameterTypeFails()
int GetData(params string[] rows)
int GetData(int x, params string[] rows)
int GetData(int x, Dictionary< string, List< int > > rows)