public void DynamicNotSupportedCase() { var d = new GenericPrivateMock().AsDynamic(); (d.ReturnType(Enumerable.Range(1, 10), 0) as Type).Is(typeof(int)); (d.ReturnType <int>(Enumerable.Range(1, 10), 0) as Type).Is(typeof(int)); var dict = new Dictionary <int, IDictionary <string, double> >(); (d.DictGen(dict, 1.9) as string).Is("dict"); (d.DictGen <int, string, double>(dict, 1.9) as string).Is("dict"); }
public void GenericPrivateExceptionTest() { var d = new GenericPrivateMock().AsDynamic(); var e1 = Assert.Throws <ArgumentException>(() => d.HogeHoge()); e1.Message.Is(s => s.Contains("not found") && s.Contains("HogeHoge")); var e2 = Assert.Throws <ArgumentException>(() => d.PrivateGeneric(1)); e2.Message.Is(s => s.Contains("not match arguments") && s.Contains("PrivateGeneric")); var e3 = Assert.Throws <ArgumentException>(() => d.PrivateGeneric <int, int, int, int>(0, 0, 0)); e3.Message.Is(s => s.Contains("not match arguments") && s.Contains("PrivateGeneric")); }
public void GenericPrivateTest() { var d = new GenericPrivateMock().AsDynamic(); (d.PrivateGeneric("", 0, "") as string).Is("a"); (d.PrivateGeneric <string, int>("", 0, "") as string).Is("a"); (d.PrivateGeneric <int, string, long>(0, "", 0) as string).Is("b"); (d.PrivateGeneric(0.0, "", 0) as string).Is("c"); (d.PrivateGeneric <double, string>(0.0, "", 0) as string).Is("c"); (d.PrivateGeneric(0.0, "", 0, "") as string).Is("d"); (d.PrivateGeneric <double, string>(0.0, "", 0, "") as string).Is("d"); (d.PrivateGeneric("", "", "") as string).Is("e"); (d.PrivateGeneric(0.0, "", 0, 0.0) as string).Is("f"); (d.PrivateGeneric <int, string, double>(0.0, "", 0, 0.0) as string).Is("f"); (d.PrivateGeneric <int>() as string).Is("g"); (d.PrivateGeneric() as string).Is("h"); (d.ReturnType(0, 0) as Type).Is(typeof(int)); (d.PrivateGeneric(0, "", 0) as string).Is("c"); (d.PrivateGeneric <int, string>(0, "", 0) as string).Is("c"); (d.PrivateGeneric(0, 0, 0) as string).Is("c"); (d.ReturnType <IEnumerable <int> >(Enumerable.Range(1, 10), new List <int>()) as Type).Is(typeof(IEnumerable <int>)); }