public Instance() { this.NativePartition = new TNativePartition(); this.NativeReplicator = new TNativeReplicator(); this.NativeStateReplicator = new TNativeStateReplicator(); this.Broker = StatefulPartitionTest.CreateDefaultBroker(); this.Partition = new StatefulServicePartition( this.NativePartition, ServicePartitionInformation.FromNative(StatefulPartitionTest.DefaultPartitionInfo)); }
private static Tuple <StatefulNativePartitionStubForStatefulPartitionCreation, StatefulServicePartition, FabricReplicator> ReplicatorCreationHelper(ReplicatorSettings settings = null) { StatefulServiceReplicaBroker broker = StatefulPartitionTest.CreateDefaultBroker(settings); var nativePartition = new StatefulNativePartitionStubForStatefulPartitionCreation { NativePartitionInfo = StatefulPartitionTest.DefaultPartitionInfo, ReplicatorOut = new ReplicatorStubBase(), StateReplicatorOut = new StateReplicatorStubBase() }; StatefulServicePartition partition = new StatefulServicePartition(nativePartition, ServicePartitionInformation.FromNative(nativePartition.GetPartitionInfo())); var fabricReplicator = partition.CreateReplicator((IStateProvider)broker.Service, settings); return(Tuple.Create(nativePartition, partition, fabricReplicator)); }
public static void ClassInitialize(TestContext context) { TestStatefulServiceReplica service = new TestStatefulServiceReplica(); StatefulServiceReplicaBroker broker = new StatefulServiceReplicaBroker(service, ReplicationWithLockingTests.DefaultInitializationParameters, ReplicationWithLockingTests.DefaultReplicaId); TestNativePartition nativePartition = new TestNativePartition(); StatefulServicePartition statefulServicePartition = new StatefulServicePartition(nativePartition, ServicePartitionInformation.CreateFromNative(nativePartition.PartitionInfo)); //((IServiceCatalog)ServiceCatalog.Current).AddService(service.Name, statefulServicePartition.Id, service); ((IStatefulServiceReplica)service).OpenAsync(statefulServicePartition); ((IStatefulServiceReplica)service).ChangeRoleAsync(ReplicaRole.Primary).Wait(); ReplicationWithLockingTests.Context = new StatefulServiceExecutionContext( service, new Dictionary <string, object> { { System.Fabric.Common.Constants.PropertyNames.Service, service.Name }, { System.Fabric.Common.Constants.PropertyNames.PartitionId, service.Partition.Id } }); ReplicationWithLockingTests.TypeInfo = ReplicableTypeInfo.GenerateReplicableTypeInfo(typeof(SampleService)); ReplicationWithLockingTests.ProgramInstance = new StatefulProgramInstance(service, Guid.NewGuid(), TypeInfo, new SampleService()); ReplicationWithLockingTests.StateReplicator = nativePartition.StateReplicator; }