public void TestSerializeEnum() { TestGraph.Worker arthur = new TestGraph.Worker {Name = "Arthur", Status = TestGraph.WorkerStatus.Normal}; CoreDataSerializer serializer = new CoreDataSerializer(arthur); CoreDataCommand command = serializer.Commands.First(); Assert.AreEqual("3", command.Parameters["Status"]); }
public void TestDateTimeOutput() { TestGraph.Worker arthur = new TestGraph.Worker { Name = "Arthur", HireDate = new DateTime(2001, 01, 01, 08, 0, 0) }; CoreDataSerializer serializer = new CoreDataSerializer(arthur); CoreDataCommand command = serializer.Commands.First(); Assert.AreEqual("28800", command.Parameters["HireDate"]); }
public void TestBooleanOutput() { TestGraph.Worker arthur = new TestGraph.Worker { Name = "Arthur", IsEnabled = true }; CoreDataSerializer serializer = new CoreDataSerializer(arthur); CoreDataCommand command = serializer.Commands.First(); Assert.AreEqual("1", command.Parameters["IsEnabled"]); }
public void TestSerializeNullValue() { TestGraph.Worker arthur = new TestGraph.Worker { Name = null }; CoreDataSerializer serializer = new CoreDataSerializer(arthur); IEnumerable<CoreDataCommand> commands = serializer.Commands.ToList(); CoreDataCommand command = commands.First(); Assert.AreEqual("", command.Parameters["Name"]); }
public void TestCustomConverter() { TestGraph.Worker arthur = new TestGraph.Worker { Name = "Arthur" }; CoreDataSerializer serializer = new CoreDataSerializer(arthur); serializer.ValueConverters[typeof(string)] = value => Convert.ToString(value) + " 1234"; CoreDataCommand command = serializer.Commands.First(); Assert.AreEqual("Arthur 1234", command.Parameters["Name"]); }
public void TestGetFactoryCommand() { TestGraph.Factory emptyFactory = new TestGraph.Factory {Name = "Magrathea"}; CoreDataSerializer serializer = new CoreDataSerializer(emptyFactory); IEnumerable<CoreDataCommand> commands = serializer.Commands; CoreDataCommand command = commands.First(); Assert.AreEqual("Factory", command.ObjectName); Assert.AreEqual("Magrathea", command.Parameters["Name"]); }
public void TestDefaultsAreNotModified() { TestGraph.Worker arthur = new TestGraph.Worker { Name = "Arthur" }; int defaultConverters = CoreDataSerializer.DefaultValueConverters.Count; CoreDataSerializer serializer = new CoreDataSerializer(arthur); serializer.ValueConverters[typeof(string)] = value => Convert.ToString(value) + " 1234"; Assert.AreEqual(defaultConverters, CoreDataSerializer.DefaultValueConverters.Count); }
public void TestBackwardRelation() { TestGraph.Worker arthur = new TestGraph.Worker {Name = "Arthur"}; TestGraph.Department sales = new TestGraph.Department {Name = "sales", Workers = new[] {arthur}}; arthur.CurrentDepartment = sales; CoreDataSerializer serializer = new CoreDataSerializer(sales); IEnumerable<CoreDataCommand> commands = serializer.Commands.ToList(); Assert.AreEqual(2, commands.Count()); CoreDataCommand workerCommand = commands.First(command => command.ObjectName == "Worker"); Assert.AreEqual("1", workerCommand.Parameters["CurrentDepartment"]); }
public void TestIgnoreRoot() { TestGraph.Factory graph = TestGraph.GetSimpleGraph(); CoreDataSerializer serializer = new CoreDataSerializer(graph) {IgnoreRoot = true}; serializer.Refresh(); Assert.AreEqual(3, serializer.GraphNodes.Count()); Assert.IsTrue(serializer.Types.Contains(typeof(TestGraph.Worker))); Assert.IsFalse(serializer.Types.Contains(typeof(TestGraph.Factory))); }
public void TestIgnoreDataMember() { TestGraph.Worker arthur = new TestGraph.Worker {Name = "Arthur", Password = "******"}; CoreDataSerializer serializer = new CoreDataSerializer(arthur); IEnumerable<CoreDataCommand> commands = serializer.Commands.ToList(); CoreDataCommand command = commands.First(); Assert.IsFalse(command.Parameters.ContainsKey("Password")); }
public void TestCollapseNodeGraphRecursion() { TestGraph.Factory graph = TestGraph.GetRecursiveGraph(); CoreDataSerializer serializer = new CoreDataSerializer(graph); Assert.AreEqual(3, serializer.GraphNodes.Count()); }
public void TestCollapseNodeGraphDuplicateReferences() { TestGraph.Factory graph = TestGraph.GetDuplicateReferenceGraph(); CoreDataSerializer serializer = new CoreDataSerializer(graph); Assert.AreEqual(6, serializer.GraphNodes.Count()); }
public void TestCollapseNodeGraphCount() { TestGraph.Factory graph = TestGraph.GetSimpleGraph(); CoreDataSerializer serializer = new CoreDataSerializer(graph); Assert.AreEqual(4, serializer.GraphNodes.Count()); }
public void TestTypeList() { TestGraph.Factory graph = TestGraph.GetSimpleGraph(); CoreDataSerializer serializer = new CoreDataSerializer(graph); Assert.AreEqual(2, serializer.Types.Count()); Assert.IsTrue(serializer.Types.Contains(typeof(TestGraph.Worker))); Assert.IsTrue(serializer.Types.Contains(typeof(TestGraph.Factory))); }
public void TestNodeGraphCollapseContents() { TestGraph.Factory graph = TestGraph.GetSimpleGraph(); CoreDataSerializer serializer = new CoreDataSerializer(graph); Assert.IsTrue(serializer.GraphNodes.Contains(graph)); Assert.IsTrue(serializer.GraphNodes.Contains(graph.Workers.First())); }
public void TestIgnoreTypes() { TestGraph.Factory graph = TestGraph.GetRecursiveGraph(); CoreDataSerializer serializer = new CoreDataSerializer(graph); serializer.IgnoredTypes.Add(typeof (TestGraph.Worker)); serializer.Refresh(); Assert.AreEqual(1, serializer.GraphNodes.Count()); }