public DevicePartitionsTest() { this.clusteringConfig = new Mock <IClusteringConfig>(); this.config = new Mock <IServicesConfig>(); this.simulations = new Mock <ISimulations>(); this.factory = new Mock <IFactory>(); this.log = new Mock <ILogger>(); this.partitionsStorage = new Mock <IStorageRecords>(); this.mockClusterNodes = new Mock <IClusterNodes>(); // Inject configuration settings with a collection name which is then used // to intercept the call to .InitAsync() this.config.SetupGet(x => x.PartitionsStorage) .Returns(new StorageConfig { DocumentDbCollection = PARTITIONS }); // Intercept the call to IStorageRecords.InitAsync() and return the right storage mock var storageMockFactory = new Mock <IStorageRecords>(); storageMockFactory .Setup(x => x.Init(It.Is <StorageConfig>(c => c.DocumentDbCollection == PARTITIONS))) .Returns(this.partitionsStorage.Object); // When IStorageRecords is instantiated, return the factory above this.factory.Setup(x => x.Resolve <IStorageRecords>()).Returns(storageMockFactory.Object); this.target = this.GetTargetInstance(1000); }
public DevicePartitionsTest() { this.clusteringConfig = new Mock <IClusteringConfig>(); this.config = new Mock <IServicesConfig>(); this.simulations = new Mock <ISimulations>(); this.enginesFactory = new Mock <IEngines>(); this.log = new Mock <ILogger>(); this.clusterNodes = new Mock <IClusterNodes>(); // Inject configuration settings with a collection name which is then used // to intercept the call to .InitAsync() this.config.SetupGet(x => x.PartitionsStorage) .Returns(new Config { CosmosDbSqlCollection = PARTITIONS }); // Intercept the call to IStorageRecords.InitAsync() and return the right storage mock this.partitionsStorage = new Mock <IEngine>(); this.partitionsStorage .Setup(x => x.Init(It.Is <Config>(c => c.CosmosDbSqlCollection == PARTITIONS))) .Returns(this.partitionsStorage.Object); this.partitionsStorage.Setup(x => x.BuildRecord(It.IsAny <string>(), It.IsAny <string>())) .Returns((string id, string json) => new DataRecord { Id = id, Data = json }); // When IStorageRecords is instantiated, return the factory above this.enginesFactory.Setup(x => x.Build(It.IsAny <Config>())).Returns(this.partitionsStorage.Object); this.target = this.GetTargetInstance(1000); }