Exemple #1
0
        public static void Main(string[] args)
        {
            Console.WriteLine(ServiceName + " is starting..");

            new HostBuilder().ConfigureHostConfiguration(configHost =>
            {
                configHost.AddCommandLine(args);
                configHost.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
            })
            .ConfigureAppConfiguration((hostContext, configApp) =>
            {
                hostContext.HostingEnvironment.EnvironmentName = System.Environment.GetEnvironmentVariable("NETCORE_ENVIRONMENT");
            })
            .ConfigureLogging((hostContext, configLogging) =>
            {
                if (hostContext.HostingEnvironment.IsDevelopment())
                {
                    configLogging.AddConsole();
                    configLogging.AddDebug();
                }
            }).ConfigureServices((hostContext, services) =>
            {
                services.AddLogging();
                services.ConfigureCloudCassandra(hostContext.Configuration);
                var sp = services.BuildServiceProvider();
                CassandraRepository repo = new CassandraRepository(sp.GetService <CassandraSessionCacheManager>(), sp.GetService <CassandraConfiguration>());
                services.AddSingleton(typeof(IViewDataRepository), repo);
                services.ConfigureConsumerService(hostContext.Configuration, new EventoMessageHadler(repo));
                services.AddHostedService <KafkaConsumer>();
            })
            .RunConsoleAsync();

            Console.WriteLine(ServiceName + " started");
            Console.ReadLine();
        }
        public CassandraUnitOfWorkTests(CassandraUnitOfWorkTestsFixtureData fixtureData)
        {
            this._unitOfWork = fixtureData.UnitOfWork;

            var repository = new CassandraRepository <Foo>(this._unitOfWork);

            this._repositoryWriter = repository;
            this._repositoryReader = repository;
        }
Exemple #3
0
        //private dynamic _context;

        public BaseRepositoryTests(BaseRepositoryTestsFixtureData fixtureData)
        {
            var unitOfWork = fixtureData.UnitOfWork;
            var repository = new CassandraRepository <Foo>(unitOfWork);

            this._unitOfWork = unitOfWork;
            this._foosTable  = unitOfWork.Session.GetTable <Foo>();

            this._repositoryWriter      = repository;
            this._repositoryReader      = repository;
            this._repositoryWriterAsync = repository;
            this._repositoryReaderAsync = repository;
        }
        public void DisposeWorksCorrectly()
        {
            //Arrange
            var cluster    = Cluster.Builder().AddContactPoint("127.0.0.1").Build();
            var unitOfWork = new CassandraUnitOfWork(cluster, new EntityMappings());
            var repository = new CassandraRepository <Foo>(this._unitOfWork);

            //Act
            repository.Insert(new Foo {
                Id = Guid.NewGuid()
            });
            unitOfWork.SaveChanges();
            unitOfWork.Dispose();

            //Assert
        }