public void Test1() { //"use", "lastused", "modified", "count", "created", "name", "server", "database", "schema", "dropped" var fresh = new FakeOperation( new List<Row> { new Row {{"id", 1}, {"use", "old1"}, {"lastused", ""}, {"modified", "old2"}, {"count", ""}, {"created",""}, {"name",""}, {"server",""}, {"database",""}, {"schema",""},{"dropped",false}}, new Row {{"id", 2}, {"use", "old1"}, {"lastused", ""}, {"modified", "same"}, {"count", "3"}, {"created",""}, {"name",""}, {"server",""}, {"database",""}, {"schema",""},{"dropped",false}}, new Row {{"id", 3}, {"use", "new1"}, {"lastused", ""}, {"modified", "new2"}, {"count", ""}, {"created",""}, {"name",""}, {"server",""}, {"database",""}, {"schema",""},{"dropped",false}} } ); var existing = new FakeOperation( new List<Row> { new Row {{"id", 1}, {"use", "old1"}, {"lastused", ""}, {"modified", "old2"}, {"count", ""}, {"created",""}, {"name",""}, {"server",""}, {"database",""}, {"schema",""},{"dropped",false}}, new Row {{"id", 2}, {"use", "old1"}, {"lastused", ""}, {"modified", "same"}, {"count", "2"}, {"created",""}, {"name",""}, {"server",""}, {"database",""}, {"schema",""},{"dropped",false}}, new Row {{"id", 4}, {"use", "old1"}, {"lastused", ""}, {"modified", "old2"}, {"count", ""}, {"created",""}, {"name",""}, {"server",""}, {"database",""}, {"schema",""},{"dropped",false}} } ); var results = TestOperation( new SqloogleCompare().Left(fresh).Right(existing) ,new LogOperation() ); Assert.AreEqual(4, results.Count, "It's a full outer join, we should have all 4 rows!"); Assert.AreEqual("None", results[0]["Action"], "These rows are the same; should be None!"); Assert.AreEqual("Update", results[1]["Action"], "There is an updated property; should be Update!"); Assert.AreEqual("Create", results[2]["Action"], "This has never been seen before; should be Create!"); Assert.AreEqual("Update", results[3]["Action"], "This is gone! should be an Update!"); Assert.AreEqual(true, results[3]["Dropped"], "We don't delete drops, we mark them as dropped!"); }
public void TestUnion() { var rows = new List <Row> { new Row { { "k1", "v1" }, { "k2", 1 } }, new Row { { "k1", "v1" }, { "k2", 1 } }, new Row { { "k1", "v1" }, { "k2", 2 } } }; var fakeOperation1 = new FakeOperation(rows); var groupByColumns = new string[] { "k1", "k2" }; var results = TestOperation( fakeOperation1, new UnionOperation(groupByColumns), new LogOperation() ); Assert.AreEqual(2, results.Count); Assert.AreEqual(2, results[0]["Count"]); }
public void TestFakeOperation() { var rows = new List<Row> { new Row {{"k1", "v1"}, {"k2", "v2"}}, new Row {{"k1", "v3"}, {"k2", "v4"}} }; var fakeOperation = new FakeOperation(rows); var results = TestOperation( fakeOperation, new LogOperation() ); Assert.AreEqual(2, results.Count); }
public void Test1() { //"use", "lastused", "modified", "count", "created", "name", "server", "database", "schema", "dropped" var fresh = new FakeOperation( new List <Row> { new Row { { "id", 1 }, { "use", "old1" }, { "lastused", "" }, { "modified", "old2" }, { "count", "" }, { "created", "" }, { "name", "" }, { "server", "" }, { "database", "" }, { "schema", "" }, { "dropped", false } }, new Row { { "id", 2 }, { "use", "old1" }, { "lastused", "" }, { "modified", "same" }, { "count", "3" }, { "created", "" }, { "name", "" }, { "server", "" }, { "database", "" }, { "schema", "" }, { "dropped", false } }, new Row { { "id", 3 }, { "use", "new1" }, { "lastused", "" }, { "modified", "new2" }, { "count", "" }, { "created", "" }, { "name", "" }, { "server", "" }, { "database", "" }, { "schema", "" }, { "dropped", false } } } ); var existing = new FakeOperation( new List <Row> { new Row { { "id", 1 }, { "use", "old1" }, { "lastused", "" }, { "modified", "old2" }, { "count", "" }, { "created", "" }, { "name", "" }, { "server", "" }, { "database", "" }, { "schema", "" }, { "dropped", false } }, new Row { { "id", 2 }, { "use", "old1" }, { "lastused", "" }, { "modified", "same" }, { "count", "2" }, { "created", "" }, { "name", "" }, { "server", "" }, { "database", "" }, { "schema", "" }, { "dropped", false } }, new Row { { "id", 4 }, { "use", "old1" }, { "lastused", "" }, { "modified", "old2" }, { "count", "" }, { "created", "" }, { "name", "" }, { "server", "" }, { "database", "" }, { "schema", "" }, { "dropped", false } } } ); var results = TestOperation( new SqloogleCompare().Left(fresh).Right(existing) , new LogOperation() ); Assert.AreEqual(4, results.Count, "It's a full outer join, we should have all 4 rows!"); Assert.AreEqual("None", results[0]["Action"], "These rows are the same; should be None!"); Assert.AreEqual("Update", results[1]["Action"], "There is an updated property; should be Update!"); Assert.AreEqual("Create", results[2]["Action"], "This has never been seen before; should be Create!"); Assert.AreEqual("Update", results[3]["Action"], "This is gone! should be an Update!"); Assert.AreEqual(true, results[3]["Dropped"], "We don't delete drops, we mark them as dropped!"); }
public void TestFakeOperation() { var rows = new List <Row> { new Row { { "k1", "v1" }, { "k2", "v2" } }, new Row { { "k1", "v3" }, { "k2", "v4" } } }; var fakeOperation = new FakeOperation(rows); var results = TestOperation( fakeOperation, new LogOperation() ); Assert.AreEqual(2, results.Count); }
public void TestSqloogleAggregate() { var maxDate = DateTime.MaxValue; var nowDate = DateTime.Now; var testData = new FakeOperation( new Row { { "sqlscript", "ss1" }, { "use", (long)1 }, { "created", DateTime.Now }, { "server", "s1" }, { "dropped", false }, { "database", "db1" }, { "schema", "s1" }, { "name", "n1" } }, new Row { { "sqlscript", "ss1" }, { "use", (long)2 }, { "created", maxDate }, { "server", "s2" }, { "dropped", false }, { "database", "db1" }, { "schema", "s1" }, { "name", "n1" } }, new Row { { "sqlscript", "ss1" }, { "use", (long)3 }, { "created", DateTime.Now }, { "server", "s3" }, { "dropped", false }, { "database", "db1" }, { "schema", "s1" }, { "name", "n1" } }, new Row { { "sqlscript", "ss2" }, { "use", (long)4 }, { "created", nowDate }, { "server", "s4" }, { "dropped", false }, { "database", "db1" }, { "schema", "s1" }, { "name", "n1" } } ); var results = TestOperation(testData, new SqloogleAggregate()); var row1 = results[0]; var row1Servers = ((HashSet <string>)row1["server"]); var row2 = results[1]; var row2Servers = ((HashSet <string>)row2["server"]); Assert.AreEqual(2, results.Count); Assert.AreEqual(6, row1["use"]); Assert.AreEqual(4, row2["use"]); Assert.AreEqual("ss1", row1["sqlscript"]); Assert.AreEqual("ss2", row2["sqlscript"]); Assert.AreEqual(maxDate, row1["created"]); Assert.AreEqual(nowDate, row2["created"]); Assert.AreEqual(3, row1Servers.Count); Assert.AreEqual(1, row2Servers.Count); Assert.IsTrue(row1Servers.Contains("s1")); Assert.IsTrue(row2Servers.Contains("s4")); }
public void TestSqloogleAggregate() { var maxDate = DateTime.MaxValue; var nowDate = DateTime.Now; var testData = new FakeOperation( new Row { { "sqlscript", "ss1" }, { "use", (long)1 }, { "created", DateTime.Now }, { "server", "s1" }, { "dropped", false }, {"database","db1"},{"schema","s1"}, {"name","n1"} }, new Row { { "sqlscript", "ss1" }, { "use", (long)2 }, { "created", maxDate }, { "server", "s2" }, { "dropped", false }, { "database", "db1" }, { "schema", "s1" }, { "name", "n1" } }, new Row { { "sqlscript", "ss1" }, { "use", (long)3 }, { "created", DateTime.Now }, { "server", "s3" }, { "dropped", false }, { "database", "db1" }, { "schema", "s1" }, { "name", "n1" } }, new Row { { "sqlscript", "ss2" }, { "use", (long)4 }, { "created", nowDate }, { "server", "s4" }, { "dropped", false }, { "database", "db1" }, { "schema", "s1" }, { "name", "n1" } } ); var results = TestOperation(testData, new SqloogleAggregate()); var row1 = results[0]; var row1Servers = ((HashSet<string>)row1["server"]); var row2 = results[1]; var row2Servers = ((HashSet<string>)row2["server"]); Assert.AreEqual(2, results.Count); Assert.AreEqual(6, row1["use"]); Assert.AreEqual(4, row2["use"]); Assert.AreEqual("ss1", row1["sqlscript"]); Assert.AreEqual("ss2", row2["sqlscript"]); Assert.AreEqual(maxDate, row1["created"]); Assert.AreEqual(nowDate, row2["created"]); Assert.AreEqual(3, row1Servers.Count); Assert.AreEqual(1, row2Servers.Count); Assert.IsTrue(row1Servers.Contains("s1")); Assert.IsTrue(row2Servers.Contains("s4")); }
public void TestUnion() { var rows = new List<Row> { new Row {{"k1", "v1"}, {"k2", 1}}, new Row {{"k1", "v1"}, {"k2", 1}}, new Row {{"k1", "v1"}, {"k2", 2}} }; var fakeOperation1 = new FakeOperation(rows); var groupByColumns = new string[] { "k1", "k2" }; var results = TestOperation( fakeOperation1, new UnionOperation(groupByColumns), new LogOperation() ); Assert.AreEqual(2, results.Count); Assert.AreEqual(2, results[0]["Count"]); }