/// <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 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); }