Пример #1
0
        private IServiceProvider CreateServiceProvider()
        {
            var services = new Dictionary <Type, object>();

            services[typeof(DataStoreHelloWorld)] = new DataStoreHelloWorld();
            services[typeof(QueryHelloWorldClr)]  =
                new QueryHelloWorldClr(new DataStoreHelloWorld());

            var serviceResolver = new Func <Type, object>(
                t =>
            {
                if (services.TryGetValue(t, out object s))
                {
                    return(s);
                }
                return(null);
            });

            var serviceProvider = new Mock <IServiceProvider>(
                MockBehavior.Strict);

            serviceProvider.Setup(t => t.GetService(It.IsAny <Type>()))
            .Returns(serviceResolver);

            return(serviceProvider.Object);
        }
Пример #2
0
 public MutationHelloWorld(DataStoreHelloWorld dataStore)
 {
     DataStore = dataStore;
 }
Пример #3
0
 public QueryHelloWorld(DataStoreHelloWorld dataStore)
 {
     DataStore = dataStore;
 }