public void WriteOneByteActionsTest() { var vals = Enum.GetValues(typeof(ActionCode)); var factory = new ActionsFactory(); foreach (ActionCode type in vals) { if ((byte)type < 0x80) { var action = factory.Create(type); var xAction = XAction.ToXml(action); Assert.AreEqual(xAction.Name.LocalName, XActionNames.FromActionCode(type)); } } }
public void AllActionsBuildTest() { var factory = new ActionsFactory(); var vals = Enum.GetValues(typeof(ActionCode)); foreach (ActionCode type in vals) { var action = factory.Create(type); Assert.IsNotNull(action); if (action.GetType().Name != "Action" + type.ToString()) { Console.WriteLine("Warning: Incosistent naming, Action code: {0}, Class: {1}", type, action.GetType().Name); } var actualType = action.ActionCode; Assert.AreEqual(type, actualType); } }
public void WriteOneByteActionsTest() { var vals = Enum.GetValues(typeof(ActionCode)); var factory = new ActionsFactory(); foreach (ActionCode type in vals) { if ((byte)type < 0x80) { var action = factory.Create(type); var mem = new MemoryStream(); var writer = new SwfStreamWriter(mem); var actionWriter = new ActionWriter(writer); actionWriter.WriteAction(action); var buffer = mem.ToArray(); Assert.AreEqual(1, buffer.Length); Assert.AreEqual((byte)type, buffer[0]); } } }
public void CreateTest() { var ser = new XActionWriter(); var actionFactory = new ActionsFactory(); var vals = Enum.GetValues(typeof(ActionCode)); foreach (ActionCode type in vals) { if ((byte)type <= 0x80) { var action = actionFactory.Create(type); try { var res = ser.Serialize(action); var actualName = res.Name.LocalName; var expectedName = type.ToString(); if (type == ActionCode.End) expectedName = "EndAction"; if (actualName != expectedName) { Console.WriteLine("Warning: Incosistent naming, Action type: {0}, Class: {1}", type, actualName); } } catch (Exception) { Assert.Fail("Couldnt serialize: {0}", type); } } } }
public ActionReader(ISwfStreamReader reader) { _reader = reader; _factory = new ActionsFactory(); }