public void DefineBitsJPEG2Test() { var file = new SwfFile(); file.FileInfo.Version = 10; var tag = new DefineBitsJPEG2Tag(); tag.CharacterID = 1; tag.ImageData = GetEmbeddedResourceData("DefineBitsJPEG2.jpg"); var visitor = new SwfTagSerializer(file); var res = visitor.GetTagData(tag); var mem = new MemoryStream(); var writer = new SwfStreamWriter(mem); writer.WriteTagData(res); var etalon = GetTagFullBinariesFromSwfResource("DefineBitsJPEG2.swf") .FirstOrDefault(item => item.Type == SwfTagType.DefineBitsJPEG2); if (etalon.Binary == null) { throw new InvalidOperationException("Couldn't find etalon tag"); } AssertExt.AreEqual(etalon.Binary, mem.ToArray(), "Checking DefineBitsJPEG2"); }
public void ParseTest() { var parser = new VrmlParser(new Vrml97Tokenizer(new StringReader(@" #VRML V2.0 utf8 Shape { appearance Appearance { material Material { diffuseColor 0.1 0.05 0.03 } texture NULL textureTransform TextureTransform { } } }"))); var scene = new VrmlScene(); parser.Parse(scene); AssertExt.AreEqual(new ShapeNode { Appearance = new AppearanceNode { Material = new MaterialNode { DiffuseColor = new SFColor(0.1f, 0.05f, 0.03f) }, TextureTransform = new TextureTransformNode() } }, scene.Root.Children[0]); }
public void ParseTest() { var parser = new VrmlParser(new Vrml97Tokenizer(new StringReader(@" #VRML V2.0 utf8 Shape { appearance Appearance { material Material { diffuseColor 0.05 0.03 0.01 ambientIntensity 0 specularColor 0.07 0.12 0.12 shininess 0.06615 transparency 0 } } }"))); var scene = new VrmlScene(); parser.Parse(scene); AssertExt.AreEqual(new ShapeNode { Appearance = new AppearanceNode { Material = new MaterialNode { DiffuseColor = new SFColor(0.05f, 0.03f, 0.01f), AmbientIntensity = 0, SpecularColor = new SFColor(0.07f, 0.12f, 0.12f), Shininess = 0.06615f, Transparency = 0, } } }, scene.Root.Children[0]); }
public void LeftJoinTest_WithoutForeignKeys() { using (var context = TestObjects.TestDbContext.CreateInstance()) { InitializeData(context); var expected = new[] { new { Number = 1, Line = (int?)1 }, new { Number = 1, Line = (int?)2 }, new { Number = 2, Line = (int?)1 }, new { Number = 3, Line = (int?)null }, }; var actual = context.Parents .LeftJoin(context.Orphans, x => x.Id, y => y.Id, (x, y) => new { x.Number, Line = (int?)y.Line, }) .OrderBy(x => x.Number) .ThenBy(x => x.Line) .ToArray(); AssertExt.AreEqual(expected, actual); } }
public void ReplaceParameterTest_New() { var expression = CreateExpression(x => new { Value = x, x.Length }); var expected = GetDemoQuery() .Select(x => new { Value = x, x.Length }); var rdo = GetDemoQuery() .Select(expression); AssertExt.AreEqual(expected, rdo); }
private static void TestTypeUpperBounds(string methodName, Type[] types, Type[] expectedArgs) { var method = typeof(UnitTestTypeBounds).GetMethod(methodName, BindingFlags.Static | BindingFlags.NonPublic); var typeBounds = new PrivateObject("Cyjb", "Cyjb.Reflection.TypeBounds", new object[] { method.GetGenericArguments() }); var paramTypes = method.GetParameterTypes(); var last = paramTypes.Length - 1; for (var i = 0; i < types.Length; i++) { if (!(bool)typeBounds.Invoke("TypeInferences", paramTypes[i > last ? last : i], types[i], true)) { Assert.AreEqual(expectedArgs, null); return; } } AssertExt.AreEqual(expectedArgs, (Type[])typeBounds.Invoke("FixTypeArguments")); }
public void ParseTest() { var parser = new VrmlParser(new Vrml97Tokenizer(new StringReader(@" #VRML V2.0 utf8 Shape { appearance Appearance { textureTransform TextureTransform { } } }"))); var scene = new VrmlScene(); parser.Parse(scene); AssertExt.AreEqual(new ShapeNode { Appearance = new AppearanceNode { TextureTransform = new TextureTransformNode { } } }, scene.Root.Children[0]); }
public void TestGenericArgumentsInferences() { var type = typeof(TestClass); var method = type.GetMethod("TestMethod"); AssertExt.AreEqual(new[] { typeof(int) }, method.GenericArgumentsInferences(typeof(int))); AssertExt.AreEqual(new[] { typeof(uint) }, method.GenericArgumentsInferences(typeof(uint))); method = type.GetMethod("TestMethod2"); AssertExt.AreEqual(new[] { typeof(int) }, method.GenericArgumentsInferences(typeof(int))); AssertExt.AreEqual(new[] { typeof(uint) }, method.GenericArgumentsInferences(typeof(uint))); method = type.GetMethod("TestMethod3"); AssertExt.AreEqual(new[] { typeof(int) }, method.GenericArgumentsInferences(typeof(int), typeof(int))); AssertExt.AreEqual(new[] { typeof(object) }, method.GenericArgumentsInferences(typeof(string), typeof(object))); AssertExt.AreEqual(new[] { typeof(IList <int>) }, method.GenericArgumentsInferences(typeof(int[]), typeof(IList <int>))); AssertExt.AreEqual(new[] { typeof(IList <int>) }, method.GenericArgumentsInferences(typeof(IList <int>), typeof(int[]))); AssertExt.AreEqual(null, method.GenericArgumentsInferences(typeof(uint), typeof(string))); method = type.GetMethod("TestMethod4"); AssertExt.AreEqual(new[] { typeof(int) }, method.GenericArgumentsInferences(typeof(int), typeof(int))); AssertExt.AreEqual(new[] { typeof(IList <int>) }, method.GenericArgumentsInferences(typeof(IList <int>), typeof(int[]))); AssertExt.AreEqual(null, method.GenericArgumentsInferences(typeof(int[]), typeof(IList <int>))); AssertExt.AreEqual(null, method.GenericArgumentsInferences(typeof(string), typeof(object))); AssertExt.AreEqual(null, method.GenericArgumentsInferences(typeof(uint), typeof(string))); method = type.GetMethod("TestMethod5"); AssertExt.AreEqual(new[] { typeof(int) }, method.GenericArgumentsInferences(typeof(int[]), typeof(int))); AssertExt.AreEqual(new[] { typeof(long) }, method.GenericArgumentsInferences(typeof(long[]), typeof(int))); method = type.GetMethod("TestMethod6"); AssertExt.AreEqual(new[] { typeof(int), typeof(string) }, method.GenericArgumentsInferences(typeof(List <IDictionary <int, string> >), typeof(IList <int[]>))); AssertExt.AreEqual(null, method.GenericArgumentsInferences(typeof(List <Dictionary <int, string> >), typeof(IList <long[]>))); method = type.GetMethod("TestMethod7"); AssertExt.AreEqual(new[] { typeof(int), typeof(string) }, method.GenericArgumentsInferences(typeof(List <IDictionary <int, string> >), typeof(IList <int[]>))); AssertExt.AreEqual(new[] { typeof(int), typeof(string) }, method.GenericArgumentsInferences(typeof(List <Dictionary <int, string> >), typeof(IList <int[]>))); AssertExt.AreEqual(null, method.GenericArgumentsInferences(typeof(List <Dictionary <int, string> >), typeof(IList <long[]>))); method = type.GetMethod("TestMethod8"); AssertExt.AreEqual(new[] { typeof(int) }, method.GenericArgumentsInferences(typeof(int), typeof(int), typeof(int), typeof(int))); AssertExt.AreEqual(new[] { typeof(object) }, method.GenericArgumentsInferences(typeof(string), typeof(string), typeof(object), typeof(object))); AssertExt.AreEqual(new[] { typeof(string) }, method.GenericArgumentsInferences(typeof(string), typeof(string[]))); AssertExt.AreEqual(new[] { typeof(string[]) }, method.GenericArgumentsInferences(typeof(string[]), typeof(string[]))); AssertExt.AreEqual(new[] { typeof(string[][]) }, method.GenericArgumentsInferences(typeof(string[][]), typeof(string[][]))); AssertExt.AreEqual(new[] { typeof(string[]) }, method.GenericArgumentsInferences(typeof(string[]), typeof(string[][]))); AssertExt.AreEqual(new[] { typeof(string) }, method.GenericArgumentsInferences(typeof(string), typeof(string))); AssertExt.AreEqual(new[] { typeof(string) }, method.GenericArgumentsInferences(typeof(string))); method = type.GetMethod("TestMethod9"); AssertExt.AreEqual(new[] { typeof(int), typeof(string) }, method.GenericArgumentsInferences(typeof(Func <int, string>), typeof(int), typeof(string))); AssertExt.AreEqual(new[] { typeof(TestClass2), typeof(string) }, method.GenericArgumentsInferences(typeof(Func <TestClass2, string>), typeof(TestClass3), typeof(string))); AssertExt.AreEqual(null, method.GenericArgumentsInferences(typeof(Func <short, string>), typeof(int), typeof(string))); AssertExt.AreEqual(new[] { typeof(object), typeof(string) }, method.GenericArgumentsInferences(typeof(Func <object, string>), typeof(string), typeof(string))); AssertExt.AreEqual(new[] { typeof(int), typeof(string) }, method.GenericArgumentsInferences(typeof(Func <int, string>), typeof(short), typeof(string))); AssertExt.AreEqual(new[] { typeof(int), typeof(object) }, method.GenericArgumentsInferences(typeof(Func <int, string>), typeof(short), typeof(object))); AssertExt.AreEqual(new[] { typeof(IList <int>), typeof(object) }, method.GenericArgumentsInferences(typeof(Func <IList <int>, string>), typeof(int[]), typeof(object))); AssertExt.AreEqual(new[] { typeof(IList <int>), typeof(object) }, method.GenericArgumentsInferences(typeof(Func <IList <int>, object>), typeof(int[]), typeof(string))); AssertExt.AreEqual(new[] { typeof(IList <int>), typeof(IList <int>) }, method.GenericArgumentsInferences(typeof(Func <IList <int>, int[]>), typeof(int[]), typeof(IList <int>))); }