Пример #1
0
        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);
        }