Пример #1
0
        public void CreateExecutorWithInvalidMode()
        {
            // Arrange
            Mock <ITableEntityConverter <Country> > entityConverterMock = MocksFactory.GetTableEntityConverterMock <Country>();
            Mock <ICloudTable> cloudTableMock = MocksFactory.GetCloudTableMock();
            var executorFactory = new TableRequestExecutorFactory <Country>(cloudTableMock.Object, entityConverterMock.Object);
            ITableRequestExecutor <Country> executor = null;

            // Act
            Assert.Throws <ArgumentOutOfRangeException>(() => executor = executorFactory.Create((ExecutionMode)2));

            // Assert
            Assert.Null(executor);
        }
        public void CreateExecutorWithInvalidMode()
        {
            // Arrange
            Mock<ITableEntityConverter<Country>> entityConverterMock = MocksFactory.GetTableEntityConverterMock<Country>();
            Mock<ICloudTable> cloudTableMock = MocksFactory.GetCloudTableMock();
            var executorFactory = new TableRequestExecutorFactory<Country>(cloudTableMock.Object, entityConverterMock.Object);
            ITableRequestExecutor<Country> executor = null;

            // Act
            Assert.Throws<ArgumentOutOfRangeException>(() => executor = executorFactory.Create((ExecutionMode) 2));

            // Assert
            Assert.Null(executor);
        }
Пример #3
0
        public void CreateSequentialExecutor()
        {
            // Arrange
            Mock <ITableEntityConverter <Country> > entityConverterMock = MocksFactory.GetTableEntityConverterMock <Country>();
            Mock <ICloudTable> cloudTableMock = MocksFactory.GetCloudTableMock();
            var executorFactory = new TableRequestExecutorFactory <Country>(cloudTableMock.Object, entityConverterMock.Object);

            // Act
            ITableRequestExecutor <Country> executor = executorFactory.Create(ExecutionMode.Sequential);

            // Assert
            Assert.NotNull(executor);
            Assert.IsType <TableRequestSequentialExecutor <Country> >(executor);
            Assert.Equal(cloudTableMock.Object, executorFactory.CloudTable);
        }
        public void CreateSequentialExecutor()
        {
            // Arrange
            Mock<ITableEntityConverter<Country>> entityConverterMock = MocksFactory.GetTableEntityConverterMock<Country>();
            Mock<ICloudTable> cloudTableMock = MocksFactory.GetCloudTableMock();
            var executorFactory = new TableRequestExecutorFactory<Country>(cloudTableMock.Object, entityConverterMock.Object);

            // Act
            ITableRequestExecutor<Country> executor = executorFactory.Create(ExecutionMode.Sequential);

            // Assert
            Assert.NotNull(executor);
            Assert.IsType<TableRequestSequentialExecutor<Country>>(executor);
            Assert.Equal(cloudTableMock.Object, executorFactory.CloudTable);
        }
Пример #5
0
        /// <summary>
        ///     Constructor.
        /// </summary>
        /// <param name="cloudTableClient">Cloud table client.</param>
        /// <param name="tableName">Table name.</param>
        public TableSet(CloudTableClient cloudTableClient, string tableName)
        {
            if (cloudTableClient == null)
            {
                throw new ArgumentNullException(nameof(cloudTableClient));
            }

            if (string.IsNullOrEmpty(tableName))
            {
                throw new ArgumentNullException(nameof(tableName));
            }

            _cloudTable = cloudTableClient.GetTableReference(tableName);
            var cloudTableWrapper = new CloudTableWrapper(_cloudTable);
            var entityConverter   = new TableEntityConverter <TEntity>();

            RequestExecutorFactory = new TableRequestExecutorFactory <TEntity>(cloudTableWrapper, entityConverter);
            Provider        = new TableQueryProvider <TEntity>(cloudTableWrapper, entityConverter);
            RequestExecutor = RequestExecutorFactory.Create(_executionMode);
        }