public static async Task <Grain> New(Type concreteType, AbstractKey key, IGrainRuntime grainRuntime, IServiceProvider services, StorageCell storage, FakeSerializer serializer) { var creator = new GrainCreator(grainRuntime, services); var stateType = GetStateType(concreteType); var grain = stateType != null ? creator.CreateGrainInstance(concreteType, key, stateType, new DummyStorageProvider()) //IStorage will be hackily assigned below // new StorageProviderAdaptor(key, store)) : creator.CreateGrainInstance(concreteType, key); if (stateType != null) { var fnStateExtractor = _dStateExtractors.GetOrAdd(concreteType, t => BuildStateExtractor(t)); var fnStorageAssign = _dStorageAssigners.GetOrAdd(concreteType, t => BuildStorageAssigner(t)); var grainState = fnStateExtractor(grain); var bridge = new GrainStorageBridge(storage, serializer, grainState); fnStorageAssign(grain, bridge); await bridge.ReadStateAsync(); } return(grain); }
static TestGrainFactory() { var grainRuntime = Mock.Of <IGrainRuntime>(); Storage = Mock.Of <IStorage>(); GrainCreator = new GrainCreator(null, () => grainRuntime); }
static TestGrainFactory() { var grainRuntime = Mock.Of <IGrainRuntime>(); var mockStorageProvider = new Mock <IStorageProvider>(); StorageProvider = mockStorageProvider.Object; GrainCreator = new GrainCreator(grainRuntime); }