Execute() public method

Executes the service
public Execute ( StringBuilder>.Dictionary values, IWorkspace theWorkspace ) : StringBuilder
values StringBuilder>.Dictionary The values.
theWorkspace IWorkspace The workspace.
return StringBuilder
 public void GetDatabaseTables_UnitTest_ExecuteWithDatabaseNotValidJson_ExpectedHasErrors()
 {
     var esb = new GetDatabaseTables();
     var actual = esb.Execute(new Dictionary<string, StringBuilder> { { "Database", new StringBuilder("Test") } }, null);
     Assert.IsNotNull(actual);
     var result = JsonConvert.DeserializeObject<DbTableList>(actual.ToString());
     Assert.IsTrue(result.HasErrors);
     Assert.AreEqual("Invalid JSON data for Database parameter. Exception: Unexpected character encountered while parsing value: T. Path '', line 0, position 0.", result.Errors);
 }
 public void GetDatabaseTables_UnitTest_ExecuteWithBlankDatabase_ExpectHasErrors()
 {
     var esb = new GetDatabaseTables();
     var actual = esb.Execute(new Dictionary<string, StringBuilder> { { "Database", new StringBuilder() } }, null);
     Assert.IsNotNull(actual);
     var result = JsonConvert.DeserializeObject<DbTableList>(actual.ToString());
     Assert.IsTrue(result.HasErrors);
     Assert.AreEqual("No database set.", result.Errors);
 }
 public void GetDatabaseTables_UnitTest_ExecuteWithNotDbSourceJson_ExpectedHasErrors()
 {
     const string someJsonData = "{Val:1}";
     var esb = new GetDatabaseTables();
     var actual = esb.Execute(new Dictionary<string, StringBuilder> { { "Database", new StringBuilder(someJsonData) } }, null);
     Assert.IsNotNull(actual);
     var result = JsonConvert.DeserializeObject<DbTableList>(actual.ToString());
     Assert.IsTrue(result.HasErrors);
     Assert.AreEqual("Invalid Database source", result.Errors);
 }
 public void GetDatabaseTables_UnitTest_ExecuteWithNullValues_ExpectedInvalidDataContractException()
 {
     var esb = new GetDatabaseTables();
     var actual = esb.Execute(null, null);
     Assert.AreEqual(string.Empty, actual);
 }
 public void GetDatabaseTables_Execute_InValidDatabaseName()
 {
     //------------Setup for test--------------------------
     var dbSource = CreateDev2TestingDbSource(true);
     ResourceCatalog.Instance.SaveResource(Guid.Empty, dbSource);
     string someJsonData = JsonConvert.SerializeObject(dbSource);
     var esb = new GetDatabaseTables();
     var mockWorkspace = new Mock<IWorkspace>();
     mockWorkspace.Setup(workspace => workspace.ID).Returns(Guid.Empty);
     //------------Execute Test---------------------------
     var actual = esb.Execute(new Dictionary<string, StringBuilder> { { "Database", new StringBuilder(someJsonData) } }, mockWorkspace.Object);
     //------------Assert Results-------------------------
     var value = actual.ToString();
     Assert.IsFalse(string.IsNullOrEmpty(value));
     var result = JsonConvert.DeserializeObject<DbTableList>(value);
     Assert.IsTrue(result.HasErrors);
     Assert.IsTrue(value.Contains("Invalid database sent"));
 }
 public void GetDatabaseTables_Execute_ValidDatabaseSource()
 {
     //------------Setup for test--------------------------
     var dbSource = CreateDev2TestingDbSource();
     ResourceCatalog.Instance.SaveResource(Guid.Empty, dbSource);
     string someJsonData = JsonConvert.SerializeObject(dbSource);
     var esb = new GetDatabaseTables();
     var mockWorkspace = new Mock<IWorkspace>();
     mockWorkspace.Setup(workspace => workspace.ID).Returns(Guid.Empty);
     //------------Execute Test---------------------------
     var actual = esb.Execute(new Dictionary<string, StringBuilder> { { "Database", new StringBuilder(someJsonData) } }, mockWorkspace.Object);
     //------------Assert Results-------------------------
     var value = actual.ToString();
     Assert.IsFalse(string.IsNullOrEmpty(value));
     var result = JsonConvert.DeserializeObject<DbTableList>(value);
     Assert.IsTrue(result.Items.Count > 2);
     var duplicateTables = result.Items.FindAll(table => table.TableName.Contains("[City]"));
     Assert.AreEqual(2, duplicateTables.Count);
     var dboCityTable = duplicateTables.Find(table => table.Schema == "dbo");
     var warewolfCityTable = duplicateTables.Find(table => table.Schema == "Warewolf");
     Assert.IsNotNull(dboCityTable);
     Assert.AreEqual("dbo", dboCityTable.Schema);
     Assert.IsNotNull(warewolfCityTable);
     Assert.AreEqual("Warewolf", warewolfCityTable.Schema);
 }