Beispiel #1
0
 public void When_Get_Called_Without_Calling_Initialize_InitializationException_Is_Thrown()
 {
     ClusterHelper.Close();
     var cluster = ClusterHelper.Get();
 }
Beispiel #2
0
        static void Main(string[] args)
        {
            var _dbContext = new UserBehaviorDbContext();

            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

            IConfigurationRoot configuration = builder.Build();


            ClusterHelper.Initialize(new ClientConfiguration {
                Servers = new List <Uri> {
                    new Uri(configuration.GetSlnConfig("CouchbaseEndpoint"))
                }
            }, new PasswordAuthenticator(configuration.GetSlnConfig("CouchbaseUserName"), configuration.GetSlnConfig("CouchbasePassword")));

            var factory = new ConnectionFactory()
            {
                HostName = configuration.GetSlnConfig("RabbitMQEndpoint")
            };

            IBucket _bucket = ClusterHelper.GetBucket("TesteViajaNetUserBehavior");


            try
            {
                using (var connection = factory.CreateConnection())
                    using (var channel = connection.CreateModel())
                    {
                        channel.QueueDeclare(queue: "UserBehavior",
                                             durable: false,
                                             exclusive: false,
                                             autoDelete: false,
                                             arguments: null);

                        var consumer = new EventingBasicConsumer(channel);
                        consumer.Received += (model, ea) =>
                        {
                            var body    = ea.Body;
                            var message = Encoding.UTF8.GetString(body);

                            PageAccess pageAccess = JsonConvert.DeserializeObject <PageAccess>(message);

                            pageAccess.Id          = Guid.NewGuid();
                            pageAccess.DateCreated = DateTime.Now;


                            _dbContext.PageAccesses.Add(pageAccess);
                            _dbContext.SaveChanges();

                            _bucket.Insert <PageAccess>(pageAccess.Id.ToString(), pageAccess);
                        };
                        channel.BasicConsume(queue: "UserBehavior",
                                             autoAck: true,
                                             consumer: consumer);

                        Console.WriteLine(" Press [enter] to exit.");
                        Console.ReadLine();
                    }
            }
            catch (Exception e)
            {
                Console.Write(e.Message);
            }
            finally
            {
                ClusterHelper.Close();
            }
        }
 public static void CleanUp()
 {
     ClusterHelper.Close();
 }
 protected void Application_End()
 {
     ClusterHelper.Close();
 }
 public void When_Get_Called_Without_Calling_Initialize_InitializationException_Is_Thrown()
 {
     ClusterHelper.Close();
     var ex = Assert.Throws <InitializationException>(() => ClusterHelper.Get());
 }
 public static void CloseCouchbaseConnection()
 {
     ClusterHelper.Close();
 }
Beispiel #7
0
 public void TearDown()
 {
     // clear after each test
     ClusterHelper.Close();
 }