/// <summary> /// Loads the current RecordSet from \\Connections\DummyConnection\Tables\LAG\Articles /// This can be used to verify that modifications worked. /// </summary> /// <returns></returns> public RecordSet LoadArticlesRecordSetFromDummyPlugin() { // load the provider plugin connection string[] connectionPath = new string[] { "Connections", "DummyConnection" }; IProviderConnection connection = _ProviderPluginManager.Connections[connectionPath]; string[] endpointPath = new string[] { "Tables", "LAG" }; IReadEndpoint articlesEndpoint = (from e in connection.Endpoints where e is IReadEndpoint && ArrayEqualityComparer.Equals(e.Path, endpointPath) && e.Name == "Articles" select(IReadEndpoint) e).FirstOrDefault(); ReadResource resource = articlesEndpoint.GetReadResource(); // create a mocked read request Mock <IReadRequest> mock = new Mock <IReadRequest>(); mock.Setup(r => r.Resource).Returns(resource); mock.Setup(r => r.RequestedFields).Returns(resource.Schema.Fields); // request all articles with all fields ReadResponse response = articlesEndpoint.RunReadRequest(mock.Object); return(response.RecordSet); }
public void Basic_READ_Statement_Works() { string code = @" READ \\Connections\DummyConnection\Tables\LAG\Articles TO \imported\Articles END"; _SyneryClient.Run(code); // load the imported table ITable table = _Database.LoadTable(@"\imported\Articles"); // load the provider plugin connection string[] connectionPath = new string[] { "Connections", "DummyConnection" }; IProviderConnection connection = _ProviderPluginManager.Connections[connectionPath]; string[] endpointPath = new string[] { "Tables", "LAG" }; IReadEndpoint articlesEndpoint = (from e in connection.Endpoints where e is IReadEndpoint && ArrayEqualityComparer.Equals(e.Path, endpointPath) && e.Name == "Articles" select(IReadEndpoint) e).FirstOrDefault(); // check whether the table is available Assert.IsInstanceOf <ITable>(table); // check whether the number of fiels is equal in the endpoint's schema and in the imported table's schema Assert.AreEqual(articlesEndpoint.GetReadResource().Schema.Fields.Count, table.Schema.Fields.Count); }
public void Create_Connection_With_Valid_Parameters_Works() { string code = @" CONNECT ""Dummy"" AS \\Connections\DummyConnection SET ( Database.Connection.Server = ""Testserver"", Database.Connection.Database = ""TestDb"", Database.Connection.User = ""TestUser"", Database.Connection.Password = ""TestPassword"", Proffix.Tables.ShowAdditionalTables = TRUE, Proffix.Tables.ShowSystemTables = TRUE ) END "; _SyneryClient.Run(code); string[] connectionPath = new string[] { "Connections", "DummyConnection" }; IProviderConnection connection = _ProviderPluginManager.Connections[connectionPath]; var serverValue = (from a in connection.Settings.Answers where ArrayEqualityComparer.Equals <string>(a.Question.Path, new string[] { "Database", "Connection" }) && a.Question.Name == "Server" select a.Value).First(); var showAdditionalTablesValue = (from a in connection.Settings.Answers where ArrayEqualityComparer.Equals <string>(a.Question.Path, new string[] { "Proffix", "Tables" }) && a.Question.Name == "ShowAdditionalTables" select a.Value).First(); Assert.AreEqual("Testserver", serverValue); Assert.AreEqual(true, showAdditionalTablesValue); }
public void Create_Two_Connections_With_The_Same_ProviderPlugin() { string code = @" CONNECT ""Dummy"" AS \\Connections\FirstDummyConnection SET ( Database.Connection.Server = ""FirstTestserver"", Database.Connection.Database = ""FirstTestDb"", Database.Connection.User = ""FirstTestUser"", Database.Connection.Password = ""FirstTestPassword"", Proffix.Tables.ShowAdditionalTables = TRUE, Proffix.Tables.ShowSystemTables = TRUE ) END CONNECT ""Dummy"" AS \\Connections\SecondDummyConnection SET ( Database.Connection.Server = ""SecondTestserver"", Database.Connection.Database = ""SecondTestDb"", Database.Connection.User = ""SecondTestUser"", Database.Connection.Password = ""SecondTestPassword"", Proffix.Tables.ShowAdditionalTables = FALSE, Proffix.Tables.ShowSystemTables = FALSE ) END "; _SyneryClient.Run(code); string[] firstConnectionPath = new string[] { "Connections", "FirstDummyConnection" }; IProviderConnection firstConnection = _ProviderPluginManager.Connections[firstConnectionPath]; var firstServerValue = (from a in firstConnection.Settings.Answers where ArrayEqualityComparer.Equals <string>(a.Question.Path, new string[] { "Database", "Connection" }) && a.Question.Name == "Server" select a.Value).First(); string[] secondConnectionPath = new string[] { "Connections", "SecondDummyConnection" }; IProviderConnection secondConnection = _ProviderPluginManager.Connections[secondConnectionPath]; var secondServerValue = (from a in secondConnection.Settings.Answers where ArrayEqualityComparer.Equals <string>(a.Question.Path, new string[] { "Database", "Connection" }) && a.Question.Name == "Server" select a.Value).First(); Assert.AreEqual("FirstTestserver", firstServerValue); Assert.AreEqual("SecondTestserver", secondServerValue); }
public void Basic_READ_Statement_Works() { string code = @" INT nextNumber = 999; EXECUTE \\Connections\DummyConnection\Tables\LAG\Manufacturers GET (NextManufacturerNumber AS nextNumber) END"; _SyneryClient.Run(code); // resolve the synery variable "nextNumber" int testNextNumber = (int)_SyneryMemory.CurrentScope.ResolveVariable("nextNumber").Value; // load the provider plugin connection string[] connectionPath = new string[] { "Connections", "DummyConnection" }; IProviderConnection connection = _ProviderPluginManager.Connections[connectionPath]; string[] endpointPath = new string[] { "Tables", "LAG" }; IReadEndpoint articlesEndpoint = (from e in connection.Endpoints where e is IReadEndpoint && ArrayEqualityComparer.Equals(e.Path, endpointPath) && e.Name == "Articles" select(IReadEndpoint) e).FirstOrDefault(); ReadResource resource = articlesEndpoint.GetReadResource(); // create a mocked read request Mock <IReadRequest> mock = new Mock <IReadRequest>(); mock.Setup(r => r.Resource).Returns(resource); mock.Setup(r => r.RequestedFields).Returns(resource.Schema.Fields); // request all articles with all fields ReadResponse response = articlesEndpoint.RunReadRequest(mock.Object); // calculate the expected number from adding 1 to the highest manufacturer number int expectedNextNumber = response.RecordSet.Max(r => (int)r["ManufacturerNumber"]) + 1; Assert.AreEqual(expectedNextNumber, testNextNumber); }
public void RegisterConnection(IProviderConnection providerConnection) { providerConnection.CallFunc = ProcessCall; _providerConnectionList.Add(providerConnection); }