コード例 #1
0
        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());
            }
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
        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());
            }
        }
コード例 #5
0
ファイル: Azure.cs プロジェクト: yonglehou/SnowMaker
 protected override IOptimisticDataStore BuildStore(TestScope scope)
 {
     return(new BlobOptimisticDataStore(storageAccount, scope.ContainerName));
 }
コード例 #6
0
ファイル: File.cs プロジェクト: vbodurov/AzureAutoNumber
 protected override IOptimisticDataStore BuildStore(TestScope scope)
 {
     return(new DebugOnlyFileDataStore(scope.DirectoryPath));
 }