public void WorkspaceDataConstructorTest() { object data = new TraceLab.Core.Test.Workspaces.TestObject(); WorkspaceUnitData target = new WorkspaceUnitData(data); Assert.AreEqual(data, target.Data); }
public void ReadVersion1() { string data = "this is a test"; var reader = System.Xml.XmlReader.Create("WorkspaceDataVersion1.xml"); var formatter = new System.Xml.Serialization.XmlSerializer(typeof(WorkspaceUnitData)); WorkspaceUnitData workspaceData = null; try { workspaceData = (WorkspaceUnitData)formatter.Deserialize(reader); } catch (Exception e) { if (e.InnerException != null) { throw e.InnerException; } else { throw; } } Assert.AreEqual(typeof(TraceLab.Core.Test.Workspaces.TestObject), workspaceData.Data.GetType()); var testData = (TraceLab.Core.Test.Workspaces.TestObject)workspaceData.Data; Assert.AreEqual(data, testData.Value); }
public void InvalidXmlReaderThrows() { var data = new TraceLab.Core.Test.Workspaces.TestObject(); data.Value = "this is a test"; System.Xml.Serialization.IXmlSerializable target = new WorkspaceUnitData(data); target.ReadXml(null); }
public void SchemaIsNull() { var data = new TraceLab.Core.Test.Workspaces.TestObject(); data.Value = "this is a test"; System.Xml.Serialization.IXmlSerializable target = new WorkspaceUnitData(data); Assert.IsNull(target.GetSchema()); }
public void DataTest() { WorkspaceUnitData target = new WorkspaceUnitData(new TraceLab.Core.Test.Workspaces.TestObject()); // TODO: Initialize to an appropriate value object expected = new TraceLab.Core.Test.Workspaces.TestObject(); object actual = null; target.Data = expected; actual = target.Data; Assert.AreEqual(expected, actual); }
public void IsTemporaryTest() { WorkspaceUnitData target = new WorkspaceUnitData(new TraceLab.Core.Test.Workspaces.TestObject()); bool expected = true; bool actual; target.IsTemporary = expected; actual = target.IsTemporary; Assert.AreEqual(expected, actual); expected = false; target.IsTemporary = expected; actual = target.IsTemporary; Assert.AreEqual(expected, actual); }
public void XmlSerializeTest() { var data = new TraceLab.Core.Test.Workspaces.TestObject(); data.Value = "this is a test"; WorkspaceUnitData target = new WorkspaceUnitData(data); var stream = new System.IO.MemoryStream(); var formatter = new System.Xml.Serialization.XmlSerializer(typeof(WorkspaceUnitData)); Assert.IsTrue(stream.Length == 0); formatter.Serialize(stream, target); Assert.IsTrue(stream.Length > 0); stream.Position = 0; var result = (WorkspaceUnitData)formatter.Deserialize(stream); var resultData = (TraceLab.Core.Test.Workspaces.TestObject)result.Data; Assert.AreEqual(data.Value, resultData.Value); }
public void RawBinarySerializeTest() { var data = new TraceLab.Core.Test.Workspaces.TestObject(); data.Value = "this is a test"; WorkspaceUnitData target = new WorkspaceUnitData(data); var stream = new System.IO.MemoryStream(); var writer = new System.IO.BinaryWriter(stream); Assert.IsTrue(stream.Length == 0); target.WriteData(writer); Assert.IsTrue(stream.Length > 0); stream.Position = 0; var result = (WorkspaceUnitData)Activator.CreateInstance(typeof(WorkspaceUnitData), true); result.ReadData(new System.IO.BinaryReader(stream)); var resultData = (TraceLab.Core.Test.Workspaces.TestObject)result.Data; Assert.AreEqual(data.Value, resultData.Value); }
public void WorkspaceDataConstructorNullTest() { object data = null; WorkspaceUnitData target = new WorkspaceUnitData(data); }