Example #1
0
        public void ResolveRuntime_ShouldPass()
        {
            XpoDataStoreResolver DataStoreResolver =
                new XpoDataStoreResolver(ConfiguratioName);


            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile(ConfiguratioName);

            builder.Build();


            var NewConfig = File.ReadAllText("NewConnectionString.json");

            File.WriteAllText(ConfiguratioName, NewConfig);



            XpoInitializerResolver xpoInitializerResolver = new XpoInitializerResolver(DataStoreResolver, typeof(Invoice), typeof(Customer));

            var db99 = xpoInitializerResolver.GetById("db99");


            Assert.IsNotNull(db99);
        }
Example #2
0
        public void GetById_db1NotNull_ShouldPassA()
        {
            XpoDataStoreResolver DataStoreResolver =
                new XpoDataStoreResolver(ConfiguratioName);


            XpoInitializerResolver xpoInitializerResolver = new XpoInitializerResolver(DataStoreResolver, typeof(Invoice), typeof(Customer));

            IXpoInitializer FirstInitializer = xpoInitializerResolver.GetById("db1");

            var FirstUoW = FirstInitializer.CreateUnitOfWork();



            Customer FirstPerson = new Customer(FirstUoW);

            FirstPerson.Name = "Jose Manuel Ojeda Melgar";
            if (FirstUoW.InTransaction)
            {
                FirstUoW.CommitChanges();
            }


            IXpoInitializer SecondInitializer = xpoInitializerResolver.GetById("db1");
            var             SecondUoW         = SecondInitializer.CreateUnitOfWork();

            var SecondPerson = SecondUoW.FindObject <Customer>(new BinaryOperator(nameof(Customer.Name), FirstPerson.Name));



            Assert.AreEqual(FirstPerson.Name, SecondPerson.Name);
        }
        public static IServiceCollection AddXpoWebApiWithDal(this IServiceCollection serviceCollection, string appsettingsjson, IStringSerializationService stringSerializationHelper, IObjectSerializationService simpleObjectSerializationHelper, params Type[] entityTypes)
        {
            XpoDataStoreResolver dataStoreResolver = new XpoDataStoreResolver(appsettingsjson);

            return(AddXpoWebApiWithDal(serviceCollection, dataStoreResolver, stringSerializationHelper, simpleObjectSerializationHelper, new XpoInitializerResolver(dataStoreResolver, entityTypes)));
            //return serviceCollection.AddXpoWebApi(dataStoreResolver, stringSerializationHelper, simpleObjectSerializationHelper);
        }
Example #4
0
        public void XpoDataStoreResolver_GetById_ArgumentException_ShouldFail()
        {
            XpoDataStoreResolver configurationResolverBase =
                new XpoDataStoreResolver("appsettings.json");

            Assert.Throws <ArgumentException>(() =>
                                              configurationResolverBase.GetById("db99")
                                              );
        }
Example #5
0
        public void XpoDataStoreResolver_GetById_db1NotNull_ShouldPass()
        {
            XpoDataStoreResolver configurationResolverBase =
                new XpoDataStoreResolver("appsettings.json");

            var db1 = configurationResolverBase.GetById("db1") as InMemoryDataStore;

            Assert.IsNotNull(db1CnxConst);
        }
Example #6
0
        public void GetById_db1NotNull_ShouldPass()
        {
            XpoDataStoreResolver DataStoreResolver =
                new XpoDataStoreResolver(ConfiguratioName);


            XpoInitializerResolver xpoInitializerResolver = new XpoInitializerResolver(DataStoreResolver, typeof(Invoice), typeof(Customer));

            IXpoInitializer xpoinitializer = xpoInitializerResolver.GetById("db1");


            Assert.IsNotNull(xpoinitializer);
        }
Example #7
0
        public void GetById_ArgumentException_ShouldFail()
        {
            XpoDataStoreResolver DataStoreResolver =
                new XpoDataStoreResolver(ConfiguratioName);


            XpoInitializerResolver xpoInitializerResolver = new XpoInitializerResolver(DataStoreResolver, typeof(Invoice), typeof(Customer));

            IXpoInitializer xpoinitializer = xpoInitializerResolver.GetById("db1");


            Assert.Throws <ArgumentException>(() =>
                                              xpoInitializerResolver.GetById("db99")
                                              );
        }
        // 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;
            //});
        }
Example #9
0
        public void XpoDataStoreResolver_ResolveRuntime_ShouldPass()
        {
            XpoDataStoreResolver configurationResolverBase =
                new XpoDataStoreResolver("appsettings.json");


            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json");

            builder.Build();


            var NewConfig = File.ReadAllText("NewConnectionString.json");

            File.WriteAllText("appsettings.json", NewConfig);


            var db99 = configurationResolverBase.GetById("db99");

            Assert.IsNotNull(db99);
        }