public static void AddTestRowToTable(string tableName)
        {
            var cloudTable = GetCloudTable(tableName);
            cloudTable.CreateIfNotExists();

            var testTableEntity = new TestTableEntity
            {
                PartitionKey = Guid.NewGuid().ToString(),
                RowKey = Guid.NewGuid().ToString(),
                TestProperty = "test"
            };

            cloudTable.Execute(TableOperation.Insert(testTableEntity));
        }
Пример #2
0
        public void insert_or_replace_dynamic_record_into_the_table_when_record_does_not_exist_and_record_count_should_be_greater_than_zero()
        {
            // Arrange
            var testEntity = new TestTableEntity("John", "Smith")
            {
                Age = 21, Email = "*****@*****.**"
            };

            // Act
            _tableStorageDynamic.InsertOrReplace(testEntity);

            var result = _tableStorageDynamic.GetByRowKey <TestTableEntity>("John").ToList();

            // Assert
            result.Count.Should().BeGreaterThan(0);
        }
Пример #3
0
        public void insert_record_into_the_table_and_record_count_should_be_greater_than_zero()
        {
            // Arrange
            var testEntity = new TestTableEntity("John", "Smith")
            {
                Age = 21, Email = "*****@*****.**"
            };

            // Act
            _tableStorage.Insert(testEntity);

            var result = _tableStorage.GetByRowKey("John").ToList();

            // Assert
            result.Count.Should().BeGreaterThan(0);
        }
        public async Task insert_or_replace_async_record_into_the_table_when_record_does_not_exist_and_record_count_should_be_greater_than_zero()
        {
            // Arrange
            var testEntity = new TestTableEntity("John", "Smith")
            {
                Age = 21, Email = "*****@*****.**"
            };

            // Act
            await _tableStorage.InsertOrReplaceAsync(testEntity);

            var result = (await _tableStorage.GetByRowKeyAsync("John")).ToList();

            // Assert
            result.Count.Should().BeGreaterThan(0);
        }
        public async Task insert_dynamic_record_into_the_table_async_inserts_with_a_count_greater_than_zero()
        {
            // Arrange
            var testEntity = new TestTableEntity("John", "Smith")
            {
                Age = 21, Email = "*****@*****.**"
            };

            // Act
            await _tableStorageDynamic.InsertAsync(testEntity);

            var result = await _tableStorageDynamic.GetByRowKeyAsync <TestTableEntity>("John");

            // Assert
            result.Count().Should().BeGreaterThan(0);
        }
Пример #6
0
        public async Task get_record_with_an_entry_returns_the_expected_entry()
        {
            // Arrange
            await TestDataHelper.SetupRecords(_tableStorage);

            var expected = new TestTableEntity("Bill", "Jones")
            {
                Age = 45, Email = "*****@*****.**"
            };

            // Act
            var result = _tableStorage.GetRecord("Jones", "Bill");

            // Assert
            result.Should().BeEquivalentTo(expected, op => op.Excluding(o => o.Timestamp).Excluding(o => o.ETag).Excluding(o => o.SelectedMemberPath == "CompiledRead"));
        }
Пример #7
0
        public void insert_or_replace_dynamic_record_into_the_table_when_record_does_exist_and_record_should_have_updated_fields()
        {
            // Arrange
            var testEntity = new TestTableEntity("John", "Smith")
            {
                Age = 21, Email = "*****@*****.**"
            };

            _tableStorageDynamic.Insert(testEntity);
            // Act
            testEntity = new TestTableEntity("John", "Smith")
            {
                Age = 45, Email = "*****@*****.**"
            };
            _tableStorageDynamic.InsertOrReplace(testEntity);

            var result = _tableStorageDynamic.GetByRowKey <TestTableEntity>("John").ToList();

            // Assert
            result[0].Age.Should().Be(45);
        }
        public async Task insert_or_replace_async_record_into_the_table_when_record_does_exist_and_record_should_have_updated_fields()
        {
            // Arrange
            var testEntity = new TestTableEntity("John", "Smith")
            {
                Age = 21, Email = "*****@*****.**"
            };
            await _tableStorage.InsertAsync(testEntity);

            // Act
            testEntity = new TestTableEntity("John", "Smith")
            {
                Age = 45, Email = "*****@*****.**"
            };
            await _tableStorage.InsertOrReplaceAsync(testEntity);

            var result = (await _tableStorage.GetByRowKeyAsync("John")).ToList();

            // Assert
            result[0].Age.Should().Be(45);
        }
Пример #9
0
        protected void uiButtonTestJson_Click(object sender, EventArgs e)
        {
            List<IBQEntityObject> listaToImport = new List<IBQEntityObject>();

            TestTableMeta testMeta = new TestTableMeta();

            Random rand = new Random(DateTime.Now.Millisecond);

            for (int i = 0; i < 100; i++)
            {
                TestTableEntity testEntity = new TestTableEntity();
                testEntity.Word = "blah_" + rand.Next(1000).ToString();
                testEntity.WordCount = rand.Next(9000);
                testEntity.Corpus = "Corpus_" + rand.Next(1000);
                testEntity.CorpusDate = (DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc)).Seconds;

                listaToImport.Add(testEntity);
            }

            this.uiTestJsonLabel.Text = JsonConvert.SerializeObject(DataManager.ImportDataJsonBQ(listaToImport, testMeta, false, false));
        }
Пример #10
0
        public async Task UpdateSinglePropertyTest()
        {
            TestTableEntity firstRow    = null;
            TestTableEntity afterUpdate = null;

            using (var connection = new SqlConnection(Settings.ConnectionString))
            {
                await TableUtils.ClearTestDB(connection);

                int id = await connection.Insert("TestTable", new { TestString = "HI", TestInt = 5 });

                firstRow = await connection.QuerySingleAsync <TestTableEntity>("Select * from TestTable WHERE TestTableID = @ID", new { ID = id });

                await connection.Update("TestTable", new { TestTableID = id }, new { TestString = "UPDATED" });

                afterUpdate = await connection.QuerySingleAsync <TestTableEntity>("Select * from TestTable WHERE TestTableID = @ID", new { ID = id });
            }

            Assert.AreEqual("HI", firstRow.TestString);
            Assert.AreEqual("UPDATED", afterUpdate.TestString);
        }
Пример #11
0
        public void GivenUnsupportedProperty_WhenWrite_ThenSerializeUnsupportedPropertyAsJson()
        {
            // Arrange

            var entity = new TestTableEntity
            {
                SomeProperty = new MyCustomClass
                {
                    FirstName = "Tom",
                    LastName  = "Hardy"
                }
            };

            // Act

            var actualProperties = entity.WriteEntity(new OperationContext());

            // Assert

            const string expectedUnsupportedProperty = "{\"FirstName\":\"Tom\",\"LastName\":\"Hardy\"}";

            Assert.True(actualProperties.ContainsKey("SomeProperty"));
            Assert.Equal(expectedUnsupportedProperty, actualProperties["SomeProperty"].StringValue);
        }