示例#1
0
        public async Task Setup()
        {
            redisInstance = new RedisInside.Redis(i => i.Port(6666).LogTo(item => Global.Logger.LogDebug(item)));
            var config = XDocument.Load(Path.Combine(TestContext.CurrentContext.TestDirectory, @"Config\redis.config")).XmlDeserialize <RedisConfiguration>();

            config.ServiceName = "IT";
            redis = await new ModuleHelper(config).Provider.GetService <IAsyncServiceFactory <IRedisLink> >().GetService(true);
            redis.Multiplexer.Flush();
            key = new ObjectKey("Test", "Key");
        }
示例#2
0
        public RedisServerFixture()
        {
            redis = new RedisInside.Redis();
            Thread.Sleep(100);
            mux = ConnectionMultiplexer.Connect(new ConfigurationOptions {
                AllowAdmin = true, AbortOnConnectFail = false, EndPoints = { redis.Endpoint }
            });
            RedisEndpoint = redis.Endpoint.ToString();
            mux.GetServer(redis.Endpoint.ToString()).ConfigSet("notify-keyspace-events", "KEA");

            mux.GetDatabase().StringSetAsync("key", "value");
            var actualValue = mux.GetDatabase().StringGetAsync("key");;
        }
        public void Setup()
        {
            local = new LocalDocumentsCache(ApplicationLogging.LoggerFactory.CreateLogger <LocalDocumentsCache>(), new MemoryCache(new MemoryCacheOptions()));
            redis = new RedisInside.Redis(i => i.Port(6666).LogTo(item => log.LogDebug(item)));
            IServiceCollection service = new ServiceCollection();

            service.RegisterModule(new RedisServerModule(new RedisConfiguration("localhost", 6666)
            {
                ServiceName = "Test"
            }));
            link     = service.BuildServiceProvider().GetService <IRedisLink>();
            instance = new RedisDocumentCache(new NullLogger <RedisDocumentCache>(), POSTaggerType.Simple, link, local);
        }
        public void Setup()
        {
            redis = new RedisInside.Redis(i => i.Port(6666).LogTo(message => log.Debug(message)));
            var config      = new RedisConfiguration("localhost", 6666);
            var jsonConvert = TweetinviContainer.Resolve <IJsonObjectConverter>();
            var jsons       = new FileLoader(new NullLogger <FileLoader>()).Load(Path.Combine(TestContext.CurrentContext.TestDirectory, @"data\data_20160311_1115.dat"));
            var tweetDto    = jsonConvert.DeserializeObject <TweetDTO>(jsons[0]);

            tweet = Tweet.GenerateTweetFromDTO(tweetDto);
            link  = new RedisLink("Trump", new RedisMultiplexer(config));
            link.Open();
            cache       = new MemoryCache(new MemoryCacheOptions());
            persistency = new RedisPersistency(new NullLogger <RedisPersistency>(), link, cache);
            persistency.ResolveRetweets = true;
        }
        public void Setup()
        {
            service = new RedisInside.Redis(config => config.Port(6666));

            var collection = new ServiceCollection();

            collection.AddLogging(builder => builder.AddConsole());
            collection.RegisterModule(new RedisModule(new NullLogger <RedisModule>(), new RedisConfiguration("localhost", 6666)));
            collection.RegisterModule <CommonModule>();
            var provider = collection.BuildServiceProvider();

            link = provider.GetService <IRedisLink>();
            link.Open();
            instance = new AmazonRepository(new NullLogger <AmazonRepository>(), link);
            review   = AmazonReview.Construct(
                new ProductData {
                Id = "Product1"
            },
                new UserData {
                Id = "User1"
            },
                new AmazonReviewData {
                Id = "One", UserId = "User1", ProductId = "Product1"
            },
                new AmazonTextData {
                Text = "Test"
            });
            review.User.Name        = "Andrius";
            review.Product.Name     = "Nokia";
            review.Product.Category = ProductCategory.Electronics;
            review.Data.Date        = new DateTime(2012, 01, 01);
            review.Product.Price    = 10;
            var task1 = instance.Save(review);

            review.Data.Id = "Two";
            review         = AmazonReview.Construct(review.Product, review.User, review.Data, review.TextData);
            var task2 = instance.Save(review);

            Task.WaitAll(task1, task2);
        }
        public virtual async Task Setup()
        {
            redisInstance = new RedisInside.Redis(i => i.Port(6666).LogTo(item => Global.Logger.LogDebug(item)));
            var config   = XDocument.Load(Path.Combine(TestContext.CurrentContext.TestDirectory, @"Config\redis.config")).XmlDeserialize <RedisConfiguration>();
            var provider = new ModuleHelper(config).Provider;

            Redis = await provider.GetService <IAsyncServiceFactory <IRedisLink> >().GetService(true);

            Redis.Multiplexer.Flush();

            Resilience            = provider.GetService <IResilience>();
            Key                   = new ObjectKey("Key1");
            Routing               = new Identity();
            Routing.ApplicationId = "Test";
            Routing.Environment   = "DEV";
            Repository            = new Mock <ILimitedSizeRepository>();
            Repository.Setup(item => item.Name).Returns("Test");
            Repository.Setup(item => item.Size).Returns(2);
            RepositoryKey = new RepositoryKey(Repository.Object, Key);
            ListAll       = new IndexKey(Repository.Object, "All", true);
            ListAll2      = new IndexKey(Repository.Object, "All2", true);
        }
        public async Task Setup()
        {
            redisOne = new RedisInside.Redis(i => i.LogTo(item => Global.Logger.LogDebug(item)).WithPersistence());
            redisTwo = new RedisInside.Redis(i => i.LogTo(item => Global.Logger.LogDebug(item)).WithPersistence());

            await Task.Delay(500).ConfigureAwait(false);

            var config = XDocument.Load(Path.Combine(TestContext.CurrentContext.TestDirectory, @"Config\redis.config")).XmlDeserialize <RedisConfiguration>();

            config.Endpoints[0].Port = ((IPEndPoint)redisOne.Endpoint).Port;
            linkOne = await new ModuleHelper(config).Provider.GetService <IAsyncServiceFactory <IRedisLink> >().GetService(true);

            config = XDocument.Load(Path.Combine(TestContext.CurrentContext.TestDirectory, @"Config\redis.config")).XmlDeserialize <RedisConfiguration>();
            config.Endpoints[0].Port = ((IPEndPoint)redisTwo.Endpoint).Port;
            var provider = new ModuleHelper(config).Provider;

            linkTwo = await provider.GetService <IAsyncServiceFactory <IRedisLink> >().GetService(true);

            factory = provider.GetService <IReplicationFactory>();

            linkOne.Multiplexer.Flush();
            linkTwo.Multiplexer.Flush();

            var data = linkOne.Database.ListRange(key);

            Assert.AreEqual(0, data.Length);

            // adding new record
            linkOne.Database.ListLeftPush(key, "Test");
            data = linkOne.Database.ListRange(key);
            Assert.AreEqual(1, data.Length);

            // checking nothing in another database
            data = linkTwo.Database.ListRange(key);
            Assert.AreEqual(0, data.Length);
        }
 public void Restart()
 {
     redisInside?.Dispose();
     redisInside = new RedisInside.Redis(configuration => configuration.Port(0));
 }
 public RedisFixture()
 {
     RedisInside            = new RedisInside.Redis();
     _lock                  = new object();
     _connectionMultiplexer = null;
 }