public void ShouldInitializeBlobForFirstIdInNewScope() { // Arrange var account = CloudStorageAccount.DevelopmentStorageAccount; using (var testScope = new TestScope(account)) { var store = new BlobOptimisticDataStore(account, testScope.ContainerName); var generator = new UniqueIdGenerator(store) { BatchSize = 3 }; // Act generator.NextId(testScope.IdScopeName); //1 // Assert Assert.AreEqual("4", testScope.ReadCurrentBlobValue()); } }
public void ShouldReturnOneForFirstIdInNewScope() { // Arrange var account = CloudStorageAccount.DevelopmentStorageAccount; using (var testScope = new TestScope(account)) { var store = new BlobOptimisticDataStore(account, testScope.ContainerName); var generator = new UniqueIdGenerator(store) { BatchSize = 3 }; // Act var generatedId = generator.NextId(testScope.IdScopeName); // Assert Assert.AreEqual(1, generatedId); } }
public void ShouldReturnIdsAcrossMultipleGenerators() { // Arrange var account = CloudStorageAccount.DevelopmentStorageAccount; using (var testScope = new TestScope(account)) { var store1 = new BlobOptimisticDataStore(account, testScope.ContainerName); var generator1 = new UniqueIdGenerator(store1) { BatchSize = 3 }; var store2 = new BlobOptimisticDataStore(account, testScope.ContainerName); var generator2 = new UniqueIdGenerator(store2) { BatchSize = 3 }; // Act var generatedIds = new[] { generator1.NextId(testScope.IdScopeName), //1 generator1.NextId(testScope.IdScopeName), //2 generator1.NextId(testScope.IdScopeName), //3 generator2.NextId(testScope.IdScopeName), //4 generator1.NextId(testScope.IdScopeName), //7 generator2.NextId(testScope.IdScopeName), //5 generator2.NextId(testScope.IdScopeName), //6 generator2.NextId(testScope.IdScopeName), //10 generator1.NextId(testScope.IdScopeName), //8 generator1.NextId(testScope.IdScopeName) //9 }; // Assert CollectionAssert.AreEqual( new[] { 1, 2, 3, 4, 7, 5, 6, 10, 8, 9 }, generatedIds); } }
public void ShouldUpdateBlobWhenGeneratingNextIdAfterEndOfBatch() { // Arrange var account = CloudStorageAccount.DevelopmentStorageAccount; using (var testScope = new TestScope(account)) { var store = new BlobOptimisticDataStore(account, testScope.ContainerName); var generator = new UniqueIdGenerator(store) { BatchSize = 3 }; // Act generator.NextId(testScope.IdScopeName); //1 generator.NextId(testScope.IdScopeName); //2 generator.NextId(testScope.IdScopeName); //3 generator.NextId(testScope.IdScopeName); //4 // Assert Assert.AreEqual("7", testScope.ReadCurrentBlobValue()); } }
protected override IOptimisticDataStore BuildStore(TestScope scope) { return(new BlobOptimisticDataStore(storageAccount, scope.ContainerName)); }
protected override IOptimisticDataStore BuildStore(TestScope scope) { return(new DebugOnlyFileDataStore(scope.DirectoryPath)); }