public void ObjectToDynamicMeasurement()
        {
            // Arrange
            Country            entity             = ObjectsFactory.GetCountry();
            Stopwatch          stopWatch          = Stopwatch.StartNew();
            DynamicTableEntity dynamicTableEntity = null;

            // Act
            for (int i = 0; i < IteractionsCount; i++)
            {
                dynamicTableEntity = new DynamicTableEntity(entity.Continent, entity.Name)
                {
                    Properties = new Dictionary <string, EntityProperty>
                    {
                        { "Area", new EntityProperty(entity.Area) },
                        { "TopSecretKey", new EntityProperty(entity.TopSecretKey) },
                        { "Formed", new EntityProperty(entity.Formed) },
                        { "Id", new EntityProperty(entity.Id) },
                        { "IsExists", new EntityProperty(entity.IsExists) },
                        { "Population", new EntityProperty(entity.Population) },
                        { "PresidentsCount", new EntityProperty(entity.PresidentsCount) }
                    }
                };
            }

            stopWatch.Stop();

            Assert.NotNull(dynamicTableEntity);

            Console.WriteLine(ResultFormat, IteractionsCount, stopWatch.ElapsedMilliseconds);
        }
예제 #2
0
        public async Task DeleteEntityByCompositeKeyAsync()
        {
            // Arrange
            TableSet <Country> tableSet = GetTableSet();
            Country            country  = ObjectsFactory.GetCountry();

            // Act
            Country addedEntity = await tableSet.AddAsync(country);

            await tableSet.RemoveAsync(
                new Country
            {
                Continent = addedEntity.Continent,
                Name      = addedEntity.Name
            });
        }
예제 #3
0
        public void DeleteEntityByCompositeKey()
        {
            // Arrange
            TableSet <Country> tableSet = GetTableSet();
            Country            country  = ObjectsFactory.GetCountry();

            // Act
            Country addedEntity = tableSet.Add(country);

            tableSet.Remove(
                new Country
            {
                Continent = addedEntity.Continent,
                Name      = addedEntity.Name
            });
        }
        public async Task RemoveEntityAsync()
        {
            // Arrange
            Mock <ITableRequestExecutor <Country> > mock = MocksFactory.GetQueryExecutorMock <Country>();
            CloudTableClient tableClient = ObjectsFactory.GetCloudTableClient();
            var context = new TableSet <Country>(tableClient)
            {
                RequestExecutor = mock.Object
            };

            Country country = ObjectsFactory.GetCountry();

            // Act
            await context.RemoveAsync(country);

            // Assert
            mock.Verify(executor => executor.ExecuteWithoutResultAsync(country, TableOperation.Delete, It.IsAny <CancellationToken>()));
        }
        public void RemoveEntity()
        {
            // Arrange
            Mock <ITableRequestExecutor <Country> > mock = MocksFactory.GetQueryExecutorMock <Country>();
            CloudTableClient tableClient = ObjectsFactory.GetCloudTableClient();
            var context = new TableSet <Country>(tableClient)
            {
                RequestExecutor = mock.Object
            };

            Country country = ObjectsFactory.GetCountry();

            // Act
            context.Remove(country);

            // Assert
            mock.Verify(executor => executor.ExecuteWithoutResult(country, TableOperation.Delete), Times.Once());
        }
예제 #6
0
        public async Task AddEntityAsync()
        {
            // Arrange
            Mock <ITableRequestExecutor <Country> > mock = MocksFactory.GetQueryExecutorMock <Country>();
            CloudTableClient tableClient = ObjectsFactory.GetCloudTableClient();
            var context = new TableSet <Country>(tableClient)
            {
                RequestExecutor = mock.Object
            };

            Country country = ObjectsFactory.GetCountry();

            // Act
            Country result = await context.AddAsync(country);

            // Assert
            Assert.NotNull(result);
            mock.Verify(executor => executor.ExecuteAsync(country, TableOperation.Insert, It.IsAny <CancellationToken>()));
            Assert.Equal(country, result);
        }
예제 #7
0
        public void AddEntity()
        {
            // Arrange
            Mock <ITableRequestExecutor <Country> > mock = MocksFactory.GetQueryExecutorMock <Country>();
            CloudTableClient tableClient = ObjectsFactory.GetCloudTableClient();
            var context = new TableSet <Country>(tableClient)
            {
                RequestExecutor = mock.Object
            };

            Country country = ObjectsFactory.GetCountry();

            // Act
            Country result = context.Add(country);

            // Assert
            Assert.NotNull(result);
            mock.Verify(executor => executor.Execute(country, TableOperation.Insert), Times.Once());
            Assert.Equal(country, result);
        }
        public void PocoToDynamicMeasurement()
        {
            // Arrange
            var          converter   = new TableEntityConverter <Country>();
            Country      entity      = ObjectsFactory.GetCountry();
            Stopwatch    stopWatch   = Stopwatch.StartNew();
            ITableEntity tableEntity = null;

            // Act
            for (int i = 0; i < IteractionsCount; i++)
            {
                tableEntity = converter.GetEntity(entity);
            }

            stopWatch.Stop();

            Assert.NotNull(tableEntity);

            Console.WriteLine(ResultFormat, IteractionsCount, stopWatch.ElapsedMilliseconds);
        }