public void Test1() { headers.Add(nameof(Token), Token); headers.Add(nameof(Id), Id); //https://christianfindlay.com/2020/05/15/c-delegates-with-ioc-containers-and-dependency-injection/ client = new Client(new NewtonsoftSerializationAdapter(), createHttpClient: (name) => _testServerHttpClientFactory.CreateClient()); //TODO check why the serialization does not work when the class DataResult inherits from dictionary CompressXmlObjectSerializationService simpleObjectSerializationHelper = new CompressXmlObjectSerializationService(); ApiFunction restFunctionClient = new ApiFunction(client, "http://localhost/HttpDataTransferTest", headers); IDataResult Result = restFunctionClient.ExecuteFunction(new DataParameters() { MemberName = "NoErrors" }); var ResultValue = simpleObjectSerializationHelper.GetObjectsFromByteArray <string>(Result.ResultValue); Assert.AreEqual("Hello Data Transfer", ResultValue); }
public void ICommandChannelTest() { XpoWebApiProvider.Register(); client = new Client(new NewtonsoftSerializationAdapter(), createHttpClient: (name) => _testServerHttpClientFactory.CreateClient()); if (File.Exists("db011.db")) { File.Delete("db011.db"); } CompressXmlObjectSerializationService simpleObjectSerializationHelper = new CompressXmlObjectSerializationService(); Dictionary <string, string> Headers = new Dictionary <string, string>(); Headers.Add(XpoWebApiProvider.TokenPart, ""); Headers.Add(XpoWebApiProvider.DataStoreIdPart, "011"); ApiFunction restFunctionClient = new ApiFunction(client, Url, Headers); XpoWebApiProvider restClientNetProvider = new XpoWebApiProvider(restFunctionClient, new CompressXmlObjectSerializationService(), DevExpress.Xpo.DB.AutoCreateOption.DatabaseAndSchema); XpoInitializer xpoInitializer = new XpoInitializer(restClientNetProvider, typeof(Customer), typeof(Invoice)); xpoInitializer.InitSchema(); var UoW = xpoInitializer.CreateUnitOfWork(); Customer customer = new Customer(UoW); customer.Name = "Jose Manuel Ojeda Melgar"; if (UoW.InTransaction) { UoW.CommitChanges(); } var CustomerFromDataStore = UoW.FindObject <Customer>(new BinaryOperator(nameof(customer.Code), customer.Code)); var ExecuteQueryData = UoW.ExecuteQuery("Select * from customer"); var ExecuteScalarData = UoW.ExecuteScalar("Select * from customer"); // var ExecuteNonQueryData = UoW.ExecuteNonQuery($"UPDATE customer SET Name = 'Joche Ojeda' WHERE Name = '{customer.Name}';"); Assert.NotNull(CustomerFromDataStore); Assert.NotNull(ExecuteQueryData); Assert.NotNull(ExecuteScalarData); Assert.AreEqual(1, ExecuteNonQueryData); }
public async Task CreateAndReadRecordTest() { XpoWebApiProvider.Register(); client = new Client(new NewtonsoftSerializationAdapter(), createHttpClient: (name) => _testServerHttpClientFactory.CreateClient()); CompressXmlObjectSerializationService simpleObjectSerializationHelper = new CompressXmlObjectSerializationService(); Dictionary <string, string> Headers = new Dictionary <string, string>(); Headers.Add(XpoWebApiProvider.TokenPart, ""); Headers.Add(XpoWebApiProvider.DataStoreIdPart, "001"); ApiFunction restFunctionClient = new ApiFunction(client, Url, Headers); XpoWebApiProvider restClientNetProvider = new XpoWebApiProvider(restFunctionClient, new CompressXmlObjectSerializationService(), DevExpress.Xpo.DB.AutoCreateOption.DatabaseAndSchema); XpoInitializer xpoInitializer = new XpoInitializer(restClientNetProvider, typeof(Customer), typeof(Invoice)); xpoInitializer.InitSchema(); var UoW = xpoInitializer.CreateUnitOfWork(); Customer customer = new Customer(UoW); customer.Name = "Jose Manuel Ojeda Melgar"; if (UoW.InTransaction) { UoW.CommitChanges(); } var CustomerFromDataStore = UoW.FindObject <Customer>(new BinaryOperator(nameof(customer.Code), customer.Code)); Response <int> count = await client.GetAsync <int>(new Uri(UrlGet + "/?DataStoreId=001", UriKind.Absolute)); Assert.AreEqual(count.Body, 1); Assert.AreEqual(customer.Name, CustomerFromDataStore.Name); }
public void SerializeAString_TestShouldPass() { BinaryObjectSerializationService DeflatSerialization = new BinaryObjectSerializationService(StreamType.Deflated); BinaryObjectSerializationService GzipSerialization = new BinaryObjectSerializationService(StreamType.GZip); BinaryObjectSerializationService UnCompressedSerialization = new BinaryObjectSerializationService(StreamType.UnCompressed); CompressXmlObjectSerializationService compressXmlObjectSerializationService = new CompressXmlObjectSerializationService(); var DeflatData = DeflatSerialization.ToByteArray <string>(Text); var GzipData = GzipSerialization.ToByteArray <string>(Text); var UnCompressedData = UnCompressedSerialization.ToByteArray <string>(Text); var CompressedXml = compressXmlObjectSerializationService.ToByteArray(Text); Assert.NotNull(DeflatData); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); IResolver <IDataStore> DataStoreResolver = new XpoDataStoreResolver("appsettings.json"); IStringSerializationService stringSerializationHelper = new StringSerializationHelper(); IObjectSerializationService objectSerializationHelper = new CompressXmlObjectSerializationService(); IFunction function = new DataStoreFunctionServer(DataStoreResolver, objectSerializationHelper); services.AddSingleton <IResolver <IDataStore> >(DataStoreResolver); services.AddSingleton <IStringSerializationService>(stringSerializationHelper); services.AddSingleton <IObjectSerializationService>(objectSerializationHelper); services.AddSingleton <IFunction>(function); //services.AddXpoWebApi(); //TODO review this code, at the momentis needed to use the await for the operations in the fucntion rest client //services.Configure<KestrelServerOptions>(options => //{ // options.AllowSynchronousIO = true; //}); }
public void CreateAndReadRecordTest() { XpoWebApiProvider.Register(); client = new Client(new NewtonsoftSerializationAdapter(), createHttpClient: (name) => _testServerHttpClientFactory.CreateClient()); CompressXmlObjectSerializationService simpleObjectSerializationHelper = new CompressXmlObjectSerializationService(); Dictionary <string, string> Headers = new Dictionary <string, string>(); Headers.Add(XpoWebApiProvider.TokenPart, ""); Headers.Add(XpoWebApiProvider.DataStoreIdPart, "001"); ApiFunction restFunctionClient = new ApiFunction(client, Url, Headers); //var Cnx = XpoWebApiProvider.GetConnectionString("http://localhost", Controller, "", "001"); XpoWebApiProvider restClientNetProvider = new XpoWebApiProvider(restFunctionClient, new CompressXmlObjectSerializationService(), DevExpress.Xpo.DB.AutoCreateOption.DatabaseAndSchema); XpoInitializer xpoInitializer = new XpoInitializer(restClientNetProvider, typeof(Customer), typeof(Invoice)); xpoInitializer.InitSchema(); var UoW = xpoInitializer.CreateUnitOfWork(); Customer customer = new Customer(UoW); customer.Name = "Jose Manuel Ojeda Melgar"; if (UoW.InTransaction) { UoW.CommitChanges(); } var CustomerFromDataStore = UoW.FindObject <Customer>(new BinaryOperator(nameof(customer.Code), customer.Code)); Assert.AreEqual(customer.Name, CustomerFromDataStore.Name); }
public void CreateCollectionTest() { //HACK ToImplmement 001 XpoWebApiProvider.Register(); client = new Client(new NewtonsoftSerializationAdapter(), createHttpClient: (name) => _testServerHttpClientFactory.CreateClient()); CompressXmlObjectSerializationService simpleObjectSerializationHelper = new CompressXmlObjectSerializationService(); Dictionary <string, string> Headers = new Dictionary <string, string>(); Headers.Add(XpoWebApiProvider.TokenPart, ""); Headers.Add(XpoWebApiProvider.DataStoreIdPart, "002"); ApiFunction restFunctionClient = new ApiFunction(client, Url, Headers); XpoWebApiProvider restClientNetProvider = new XpoWebApiProvider(restFunctionClient, new CompressXmlObjectSerializationService(), DevExpress.Xpo.DB.AutoCreateOption.DatabaseAndSchema); XpoInitializer xpoInitializer = new XpoInitializer(restClientNetProvider, typeof(Customer), typeof(Invoice)); xpoInitializer.InitSchema(); var UoW = xpoInitializer.CreateUnitOfWork(); Customer JoseManuel = new Customer(UoW); JoseManuel.Name = "Jose Manuel Ojeda Melgar"; Customer OscarOjeda = new Customer(UoW); OscarOjeda.Name = "Oscar Ojeda Melgar"; if (UoW.InTransaction) { UoW.CommitChanges(); } var people = new XPCollection <Customer>(UoW).ToList(); Assert.IsNotNull(people); }