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_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_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_UnitTest_CreateServiceEntry_ExpectedReturnsDynamicService() { var esb = new GetDatabaseTables(); var result = esb.CreateServiceEntry(); Assert.AreEqual(esb.HandlesType(), result.Name); Assert.AreEqual("<DataList><Database ColumnIODirection=\"Input\"/><Dev2System.ManagmentServicePayload ColumnIODirection=\"Both\"></Dev2System.ManagmentServicePayload></DataList>", result.DataListSpecification.ToString()); Assert.AreEqual(1, result.Actions.Count); var serviceAction = result.Actions[0]; Assert.AreEqual(esb.HandlesType(), serviceAction.Name); Assert.AreEqual(enActionType.InvokeManagementDynamicService, serviceAction.ActionType); Assert.AreEqual(esb.HandlesType(), serviceAction.SourceMethod); }
public void GetDatabaseTables_UnitTest_HandlesType_ExpectedReturnsGetDatabaseTablesService() { var esb = new GetDatabaseTables(); var result = esb.HandlesType(); Assert.AreEqual("GetDatabaseTablesService", result); }
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); }