コード例 #1
0
        public static IQueryable <T> Queryable <T>(string bucketName)
        {
            var serializer = new DefaultSerializer();

            var services = new ServiceCollection();

            services.AddSingleton <ITypeSerializer>(serializer);
            services.AddLogging();
            services.AddSingleton(Mock.Of <IClusterVersionProvider>());
            services.AddSingleton <ISerializationConverterProvider>(
                new DefaultSerializationConverterProvider(serializer,
                                                          TypeBasedSerializationConverterRegistry.CreateDefaultRegistry()));

            var mockCluster = new Mock <ICluster>();

            mockCluster
            .Setup(p => p.ClusterServices)
            .Returns(services.BuildServiceProvider());

            var mockBucket = new Mock <IBucket>();

            mockBucket.SetupGet(e => e.Name).Returns(bucketName);
            mockBucket.SetupGet(e => e.Cluster).Returns(mockCluster.Object);

            var mockCollection = new Mock <ICouchbaseCollection>();

            mockCollection
            .SetupGet(p => p.Scope.Bucket)
            .Returns(mockBucket.Object);

            return(new CollectionQueryable <T>(mockCollection.Object, default));
        }
コード例 #2
0
        public static CouchbaseLinqConfiguration WithJsonNetConverterProvider(
            this CouchbaseLinqConfiguration configuration,
            Action <TypeBasedSerializationConverterRegistry>?registryConfigurationAction)
        {
            return(configuration.WithSerializationConverterProvider(serviceProvider =>
            {
                var registry = TypeBasedSerializationConverterRegistry.CreateDefaultRegistry();

                registryConfigurationAction?.Invoke(registry);

                return new DefaultSerializationConverterProvider(
                    serviceProvider.GetRequiredService <ITypeSerializer>(),
                    registry);
            }));
        }
コード例 #3
0
        protected N1QLTestBase()
        {
            var serializer = new DefaultSerializer();

            var services = new ServiceCollection();

            services.AddSingleton(new DocumentFilterManager());
            services.AddSingleton <ITypeSerializer>(serializer);
            services.AddLogging();
            services.AddSingleton(Mock.Of <IClusterVersionProvider>());
            services.AddSingleton <ISerializationConverterProvider>(
                new DefaultSerializationConverterProvider(serializer,
                                                          TypeBasedSerializationConverterRegistry.CreateDefaultRegistry()));

            ServiceProvider = services.BuildServiceProvider();
        }
コード例 #4
0
 public void OneTimeTearDown()
 {
     DefaultSerializationConverterProvider.Registry =
         TypeBasedSerializationConverterRegistry.CreateDefaultRegistry();
 }