Inheritance: IEsbManagementEndpoint
 public void GetDatabaseColumnsForTable_UnitTest_ExecuteWithBlankDatabase_ExpectedHasErrors()
 {
     var esb = new GetDatabaseColumnsForTable();
     var actual = esb.Execute(new Dictionary<string, StringBuilder> { { "Database", new StringBuilder() } }, null);
     Assert.IsNotNull(actual);
     var result = JsonConvert.DeserializeObject<DbColumnList>(actual.ToString());
     Assert.IsTrue(result.HasErrors);
     Assert.AreEqual("No database set.", result.Errors);
 }
 public void GetDatabaseColumnsForTable_UnitTest_ExecuteWithNullValues_ExpectedInvalidDataContractException()
 {
     var esb = new GetDatabaseColumnsForTable();
     var actual = esb.Execute(null, null);
     Assert.AreEqual(string.Empty, actual);
 }
 public void GetDatabaseColumnsForTable_UnitTest_HandlesType_ExpectedReturnsGetDatabaseColumnsForTableService()
 {
     var esb = new GetDatabaseColumnsForTable();
     var result = esb.HandlesType();
     Assert.AreEqual("GetDatabaseColumnsForTableService", result);
 }
        public void GetDatabaseColumnsForTable_UnitTest_CreateServiceEntry_ExpectedReturnsDynamicService()
        {
            var esb = new GetDatabaseColumnsForTable();
            var result = esb.CreateServiceEntry();
            Assert.AreEqual(esb.HandlesType(), result.Name);
            Assert.AreEqual("<DataList><Database ColumnIODirection=\"Input\"/><TableName 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 GetDatabaseColumnsForTable_Execute_EmptySchema_ValidDatabaseSource_ReturnsFromAllSchemas()
        {
            //------------Setup for test--------------------------
            var dbSource = CreateDev2TestingDbSource();
            ResourceCatalog.Instance.SaveResource(Guid.Empty, dbSource);
            string someJsonData = JsonConvert.SerializeObject(dbSource, new JsonSerializerSettings
            {
                TypeNameHandling = TypeNameHandling.Objects,
                TypeNameAssemblyFormat = FormatterAssemblyStyle.Simple
            });
            var esb = new GetDatabaseColumnsForTable();
            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) }, { "TableName", new StringBuilder("City") }, { "Schema", new StringBuilder("") } }, mockWorkspace.Object);
            //------------Assert Results-------------------------
            var value = actual.ToString();
            Assert.IsFalse(string.IsNullOrEmpty(value));
            var result = JsonConvert.DeserializeObject<DbColumnList>(actual.ToString(), new JsonSerializerSettings
            {
                TypeNameHandling = TypeNameHandling.Objects,
                TypeNameAssemblyFormat = FormatterAssemblyStyle.Simple
            });
            Assert.AreEqual(3, result.Items.Count);

            // Check Columns Returned ;)
            Assert.IsFalse(result.Items[0].IsNullable);
            Assert.IsFalse(result.Items[0].IsAutoIncrement);
            StringAssert.Contains(result.Items[0].ColumnName, "CityID");
            StringAssert.Contains(result.Items[0].SqlDataType.ToString(), "Int");

            Assert.IsFalse(result.Items[1].IsNullable);
            Assert.IsFalse(result.Items[1].IsAutoIncrement);
            StringAssert.Contains(result.Items[1].ColumnName, "Description");
            StringAssert.Contains(result.Items[1].SqlDataType.ToString(), "VarChar");

            Assert.IsFalse(result.Items[2].IsNullable);
            Assert.IsFalse(result.Items[2].IsAutoIncrement);
            StringAssert.Contains(result.Items[2].ColumnName, "CountryID");
            StringAssert.Contains(result.Items[2].SqlDataType.ToString(), "Int");
        }