public static void AssertEquality(ComplexEntity a, ComplexEntity b)
 {
     Assert.AreEqual(a.String, b.String);
     Assert.AreEqual(a.Int64, b.Int64);
     Assert.AreEqual(a.Int64N, b.Int64N);
     Assert.AreEqual(a.Int64Null, b.Int64Null);
     Assert.AreEqual(a.LongPrimitive, b.LongPrimitive);
     Assert.AreEqual(a.LongPrimitiveN, b.LongPrimitiveN);
     Assert.AreEqual(a.LongPrimitiveNull, b.LongPrimitiveNull);
     Assert.AreEqual(a.Int32, b.Int32);
     Assert.AreEqual(a.Int32N, b.Int32N);
     Assert.AreEqual(a.Int32Null, b.Int32Null);
     Assert.AreEqual(a.IntegerPrimitive, b.IntegerPrimitive);
     Assert.AreEqual(a.integerPrimitiveN, b.IntegerPrimitiveN);
     Assert.AreEqual(a.IntegerPrimitiveNull, b.IntegerPrimitiveNull);
     Assert.AreEqual(a.Guid, b.Guid);
     Assert.AreEqual(a.GuidN, b.GuidN);
     Assert.AreEqual(a.GuidNull, b.GuidNull);
     Assert.AreEqual(a.Double, b.Double);
     Assert.AreEqual(a.DoubleN, b.DoubleN);
     Assert.AreEqual(a.DoubleNull, b.DoubleNull);
     Assert.AreEqual(a.DoublePrimitive, b.DoublePrimitive);
     Assert.AreEqual(a.DoublePrimitiveN, b.DoublePrimitiveN);
     Assert.AreEqual(a.DoublePrimitiveNull, b.DoublePrimitiveNull);
     Assert.AreEqual(a.BinaryPrimitive.GetValue(0), b.BinaryPrimitive.GetValue(0));
     Assert.AreEqual(a.BinaryPrimitive.GetValue(1), b.BinaryPrimitive.GetValue(1));
     Assert.AreEqual(a.BinaryPrimitive.GetValue(2), b.BinaryPrimitive.GetValue(2));
     Assert.AreEqual(a.BinaryPrimitive.GetValue(3), b.BinaryPrimitive.GetValue(3));
     Assert.AreEqual(a.Binary.GetValue(0), b.Binary.GetValue(0));
     Assert.AreEqual(a.Binary.GetValue(1), b.Binary.GetValue(1));
     Assert.AreEqual(a.Binary.GetValue(2), b.Binary.GetValue(2));
     Assert.AreEqual(a.Binary.GetValue(3), b.Binary.GetValue(3));
     Assert.AreEqual(a.BoolPrimitive, b.BoolPrimitive);
     Assert.AreEqual(a.BoolPrimitiveN, b.BoolPrimitiveN);
     Assert.AreEqual(a.BoolPrimitiveNull, b.BoolPrimitiveNull);
     Assert.AreEqual(a.Bool, b.Bool);
     Assert.AreEqual(a.BoolN, b.BoolN);
     Assert.AreEqual(a.BoolNull, b.BoolNull);
     Assert.AreEqual(a.DateTimeOffsetN, b.DateTimeOffsetN);
     Assert.AreEqual(a.DateTimeOffset, b.DateTimeOffset);
     Assert.AreEqual(a.DateTimeOffsetNull, b.DateTimeOffsetNull);
     Assert.AreEqual(a.DateTime, b.DateTime);
     Assert.AreEqual(a.DateTimeN, b.DateTimeN);
     Assert.AreEqual(a.DateTimeNull, b.DateTimeNull);
     Assert.AreEqual(a.SingleByte, b.SingleByte);
 }
Пример #2
0
 public static void AssertEquality(ComplexEntity a, ComplexEntity b)
 {
     Assert.AreEqual(a.String, b.String);
     Assert.AreEqual(a.Int64, b.Int64);
     Assert.AreEqual(a.LongPrimitive, b.LongPrimitive);
     Assert.AreEqual(a.Int32, b.Int32);
     Assert.AreEqual(a.IntegerPrimitive, b.IntegerPrimitive);
     Assert.AreEqual(a.Guid, b.Guid);
     Assert.AreEqual(a.Double, b.Double);
     Assert.AreEqual(a.DoublePrimitive, b.DoublePrimitive);
     Assert.AreEqual(a.BinaryPrimitive, b.BinaryPrimitive);
     Assert.AreEqual(a.Binary, b.Binary);
     Assert.AreEqual(a.BoolPrimitive, b.BoolPrimitive);
     Assert.AreEqual(a.Bool, b.Bool);
     Assert.AreEqual(a.DateTimeOffsetN, b.DateTimeOffsetN);
     Assert.AreEqual(a.DateTimeOffset, b.DateTimeOffset);
     Assert.AreEqual(a.DateTime, b.DateTime);
     Assert.AreEqual(a.DateTimeN, b.DateTimeN);
 }
 public static void AssertEquality(ComplexEntity a, ComplexEntity b)
 {
     Assert.AreEqual(a.String, b.String);
     Assert.AreEqual(a.Int64, b.Int64);
     Assert.AreEqual(a.LongPrimitive, b.LongPrimitive);
     Assert.AreEqual(a.Int32, b.Int32);
     Assert.AreEqual(a.IntegerPrimitive, b.IntegerPrimitive);
     Assert.AreEqual(a.Guid, b.Guid);
     Assert.AreEqual(a.Double, b.Double);
     Assert.AreEqual(a.DoublePrimitive, b.DoublePrimitive);
     Assert.AreEqual(a.BinaryPrimitive, b.BinaryPrimitive);
     Assert.AreEqual(a.Binary, b.Binary);
     Assert.AreEqual(a.BoolPrimitive, b.BoolPrimitive);
     Assert.AreEqual(a.Bool, b.Bool);
     Assert.AreEqual(a.DateTimeOffsetN, b.DateTimeOffsetN);
     Assert.AreEqual(a.DateTimeOffset, b.DateTimeOffset);
     Assert.AreEqual(a.DateTime, b.DateTime);
     Assert.AreEqual(a.DateTimeN, b.DateTimeN);
 }
Пример #4
0
 public static void AssertEquality(ComplexEntity a, ComplexEntity b)
 {
     Assert.AreEqual(a.String, b.String);
     Assert.AreEqual(a.Int64, b.Int64);
     Assert.AreEqual(a.Int64N, b.Int64N);
     Assert.AreEqual(a.Int64Null, b.Int64Null);
     Assert.AreEqual(a.LongPrimitive, b.LongPrimitive);
     Assert.AreEqual(a.LongPrimitiveN, b.LongPrimitiveN);
     Assert.AreEqual(a.LongPrimitiveNull, b.LongPrimitiveNull);
     Assert.AreEqual(a.Int32, b.Int32);
     Assert.AreEqual(a.Int32N, b.Int32N);
     Assert.AreEqual(a.Int32Null, b.Int32Null);
     Assert.AreEqual(a.IntegerPrimitive, b.IntegerPrimitive);
     Assert.AreEqual(a.integerPrimitiveN, b.IntegerPrimitiveN);
     Assert.AreEqual(a.IntegerPrimitiveNull, b.IntegerPrimitiveNull);
     Assert.AreEqual(a.Guid, b.Guid);
     Assert.AreEqual(a.GuidN, b.GuidN);
     Assert.AreEqual(a.GuidNull, b.GuidNull);
     Assert.AreEqual(a.Double, b.Double);
     Assert.AreEqual(a.DoubleN, b.DoubleN);
     Assert.AreEqual(a.DoubleNull, b.DoubleNull);
     Assert.AreEqual(a.DoublePrimitive, b.DoublePrimitive);
     Assert.AreEqual(a.DoublePrimitiveN, b.DoublePrimitiveN);
     Assert.AreEqual(a.DoublePrimitiveNull, b.DoublePrimitiveNull);
     Assert.AreEqual(a.BinaryPrimitive.GetValue(0), b.BinaryPrimitive.GetValue(0));
     Assert.AreEqual(a.BinaryPrimitive.GetValue(1), b.BinaryPrimitive.GetValue(1));
     Assert.AreEqual(a.BinaryPrimitive.GetValue(2), b.BinaryPrimitive.GetValue(2));
     Assert.AreEqual(a.BinaryPrimitive.GetValue(3), b.BinaryPrimitive.GetValue(3));
     Assert.AreEqual(a.Binary.GetValue(0), b.Binary.GetValue(0));
     Assert.AreEqual(a.Binary.GetValue(1), b.Binary.GetValue(1));
     Assert.AreEqual(a.Binary.GetValue(2), b.Binary.GetValue(2));
     Assert.AreEqual(a.Binary.GetValue(3), b.Binary.GetValue(3));
     Assert.AreEqual(a.BoolPrimitive, b.BoolPrimitive);
     Assert.AreEqual(a.BoolPrimitiveN, b.BoolPrimitiveN);
     Assert.AreEqual(a.BoolPrimitiveNull, b.BoolPrimitiveNull);
     Assert.AreEqual(a.Bool, b.Bool);
     Assert.AreEqual(a.BoolN, b.BoolN);
     Assert.AreEqual(a.BoolNull, b.BoolNull);
     Assert.AreEqual(a.DateTimeOffsetN, b.DateTimeOffsetN);
     Assert.AreEqual(a.DateTimeOffset, b.DateTimeOffset);
     Assert.AreEqual(a.DateTimeOffsetNull, b.DateTimeOffsetNull);
     Assert.AreEqual(a.DateTime, b.DateTime);
     Assert.AreEqual(a.DateTimeN, b.DateTimeN);
     Assert.AreEqual(a.DateTimeNull, b.DateTimeNull);
 }
        public void TableEntityCompiledVSReflectionDeSerializationEqualityTest()
        {
            string pk = Guid.NewGuid().ToString();
            string rk = Guid.NewGuid().ToString();
            TableEntity.DisableCompiledSerializers = true;
            ComplexEntity sendEnt = new ComplexEntity(pk, rk);
            sendEnt.Binary = new Byte[] { 5, 6, 7, 8 };
            sendEnt.BinaryNull = null;
            sendEnt.BinaryPrimitive = new byte[] { 5, 6, 7, 8 };
            sendEnt.Bool = true;
            sendEnt.BoolN = true;
            sendEnt.BoolNull = null;
            sendEnt.BoolPrimitive = true;
            sendEnt.BoolPrimitiveN = true;
            sendEnt.BoolPrimitiveNull = null;
            sendEnt.DateTime = DateTime.UtcNow.AddMinutes(1);
            sendEnt.DateTimeN = DateTime.UtcNow.AddMinutes(1);
            sendEnt.DateTimeNull = null;
            sendEnt.DateTimeOffset = DateTimeOffset.Now.AddMinutes(1);
            sendEnt.DateTimeOffsetN = DateTimeOffset.Now.AddMinutes(1);
            sendEnt.DateTimeOffsetNull = null;
            sendEnt.Double = (Double)5678.5678;
            sendEnt.DoubleN = (Double)5678.5678;
            sendEnt.DoubleNull = null;
            sendEnt.DoublePrimitive = (double)5678.5678;
            sendEnt.DoublePrimitiveN = (double)5678.5678;
            sendEnt.DoublePrimitiveNull = null;
            sendEnt.Guid = Guid.NewGuid();
            sendEnt.GuidN = Guid.NewGuid();
            sendEnt.GuidNull = null;
            sendEnt.Int32 = 5678;
            sendEnt.Int32N = 5678;
            sendEnt.Int32Null = null;
            sendEnt.Int64 = (long)5678;
            sendEnt.Int64N = (long)5678;
            sendEnt.Int64Null = null;
            sendEnt.IntegerPrimitive = 5678;
            sendEnt.IntegerPrimitiveN = 5678;
            sendEnt.IntegerPrimitiveNull = null;
            sendEnt.LongPrimitive = 5678;
            sendEnt.LongPrimitiveN = 5678;
            sendEnt.LongPrimitiveNull = null;
            sendEnt.String = "ResetTestTotested";
            currentTable.Execute(TableOperation.Insert(sendEnt));

            TableEntity.DisableCompiledSerializers = true;
            TableResult res = currentTable.Execute(TableOperation.Retrieve<ComplexEntity>(sendEnt.PartitionKey, sendEnt.RowKey));
            ComplexEntity reflectionEntity = res.Result as ComplexEntity;
            Assert.IsNull(reflectionEntity.CompiledRead);

            TableEntity.DisableCompiledSerializers = false;
            TableResult res2 = currentTable.Execute(TableOperation.Retrieve<ComplexEntity>(sendEnt.PartitionKey, sendEnt.RowKey));
            ComplexEntity compiledEntity = res2.Result as ComplexEntity;
            Assert.IsNotNull(compiledEntity.CompiledRead);

            // Assert Deserialized Entities are the same
            Assert.AreEqual(compiledEntity.String, reflectionEntity.String);

            Assert.AreEqual(compiledEntity.Int64, reflectionEntity.Int64);
            Assert.AreEqual(compiledEntity.Int64N, reflectionEntity.Int64N);
            Assert.AreEqual(compiledEntity.Int64Null, reflectionEntity.Int64Null);

            Assert.AreEqual(compiledEntity.LongPrimitive, reflectionEntity.LongPrimitive);
            Assert.AreEqual(compiledEntity.LongPrimitiveN, reflectionEntity.LongPrimitiveN);
            Assert.AreEqual(compiledEntity.LongPrimitiveNull, reflectionEntity.LongPrimitiveNull);

            Assert.AreEqual(compiledEntity.Int32, reflectionEntity.Int32);
            Assert.AreEqual(compiledEntity.Int32N, reflectionEntity.Int32N);
            Assert.AreEqual(compiledEntity.Int32Null, reflectionEntity.Int32Null);
            Assert.AreEqual(compiledEntity.IntegerPrimitive, reflectionEntity.IntegerPrimitive);
            Assert.AreEqual(compiledEntity.IntegerPrimitiveN, reflectionEntity.IntegerPrimitiveN);
            Assert.AreEqual(compiledEntity.IntegerPrimitiveNull, reflectionEntity.IntegerPrimitiveNull);

            Assert.AreEqual(compiledEntity.Guid, reflectionEntity.Guid);
            Assert.AreEqual(compiledEntity.GuidN, reflectionEntity.GuidN);
            Assert.AreEqual(compiledEntity.GuidNull, reflectionEntity.GuidNull);

            Assert.AreEqual(compiledEntity.Double, reflectionEntity.Double);
            Assert.AreEqual(compiledEntity.DoubleN, reflectionEntity.DoubleN);
            Assert.AreEqual(compiledEntity.DoubleNull, reflectionEntity.DoubleNull);
            Assert.AreEqual(compiledEntity.DoublePrimitive, reflectionEntity.DoublePrimitive);
            Assert.AreEqual(compiledEntity.DoublePrimitiveN, reflectionEntity.DoublePrimitiveN);
            Assert.AreEqual(compiledEntity.DoublePrimitiveNull, reflectionEntity.DoublePrimitiveNull);

            Assert.AreEqual(compiledEntity.BinaryPrimitive.GetValue(0), reflectionEntity.BinaryPrimitive.GetValue(0));
            Assert.AreEqual(compiledEntity.BinaryPrimitive.GetValue(1), reflectionEntity.BinaryPrimitive.GetValue(1));
            Assert.AreEqual(compiledEntity.BinaryPrimitive.GetValue(2), reflectionEntity.BinaryPrimitive.GetValue(2));
            Assert.AreEqual(compiledEntity.BinaryPrimitive.GetValue(3), reflectionEntity.BinaryPrimitive.GetValue(3));

            Assert.AreEqual(compiledEntity.BinaryNull, reflectionEntity.BinaryNull);
            Assert.AreEqual(compiledEntity.Binary.GetValue(0), reflectionEntity.Binary.GetValue(0));
            Assert.AreEqual(compiledEntity.Binary.GetValue(1), reflectionEntity.Binary.GetValue(1));
            Assert.AreEqual(compiledEntity.Binary.GetValue(2), reflectionEntity.Binary.GetValue(2));
            Assert.AreEqual(compiledEntity.Binary.GetValue(3), reflectionEntity.Binary.GetValue(3));

            Assert.AreEqual(compiledEntity.BoolPrimitive, reflectionEntity.BoolPrimitive);
            Assert.AreEqual(compiledEntity.BoolPrimitiveN, reflectionEntity.BoolPrimitiveN);
            Assert.AreEqual(compiledEntity.BoolPrimitiveNull, reflectionEntity.BoolPrimitiveNull);
            Assert.AreEqual(compiledEntity.Bool, reflectionEntity.Bool);
            Assert.AreEqual(compiledEntity.BoolN, reflectionEntity.BoolN);
            Assert.AreEqual(compiledEntity.BoolNull, reflectionEntity.BoolNull);

            Assert.AreEqual(compiledEntity.DateTimeOffset, reflectionEntity.DateTimeOffset);
            Assert.AreEqual(compiledEntity.DateTimeOffsetN, reflectionEntity.DateTimeOffsetN);
            Assert.AreEqual(compiledEntity.DateTimeOffsetNull, reflectionEntity.DateTimeOffsetNull);
            Assert.AreEqual(compiledEntity.DateTime, reflectionEntity.DateTime);
            Assert.AreEqual(compiledEntity.DateTimeN, reflectionEntity.DateTimeN);
            Assert.AreEqual(compiledEntity.DateTimeNull, reflectionEntity.DateTimeNull);
        }
        public void TableEntityCompiledVSReflectionSerializationEqualityTest()
        {
            string pk = Guid.NewGuid().ToString();
            string rk = Guid.NewGuid().ToString();
            ComplexEntity sendEnt = new ComplexEntity(pk, rk);
            sendEnt.Binary = new Byte[] { 5, 6, 7, 8 };
            sendEnt.BinaryNull = null;
            sendEnt.BinaryPrimitive = new byte[] { 5, 6, 7, 8 };
            sendEnt.Bool = true;
            sendEnt.BoolN = true;
            sendEnt.BoolNull = null;
            sendEnt.BoolPrimitive = true;
            sendEnt.BoolPrimitiveN = true;
            sendEnt.BoolPrimitiveNull = null;
            sendEnt.DateTime = DateTime.UtcNow.AddMinutes(1);
            sendEnt.DateTimeN = DateTime.UtcNow.AddMinutes(1);
            sendEnt.DateTimeNull = null;
            sendEnt.DateTimeOffset = DateTimeOffset.Now.AddMinutes(1);
            sendEnt.DateTimeOffsetN = DateTimeOffset.Now.AddMinutes(1);
            sendEnt.DateTimeOffsetNull = null;
            sendEnt.Double = (Double)5678.5678;
            sendEnt.DoubleN = (Double)5678.5678;
            sendEnt.DoubleNull = null;
            sendEnt.DoublePrimitive = (double)5678.5678;
            sendEnt.DoublePrimitiveN = (double)5678.5678;
            sendEnt.DoublePrimitiveNull = null;
            sendEnt.Guid = Guid.NewGuid();
            sendEnt.GuidN = Guid.NewGuid();
            sendEnt.GuidNull = null;
            sendEnt.Int32 = 5678;
            sendEnt.Int32N = 5678;
            sendEnt.Int32Null = null;
            sendEnt.Int64 = (long)5678;
            sendEnt.Int64N = (long)5678;
            sendEnt.Int64Null = null;
            sendEnt.IntegerPrimitive = 5678;
            sendEnt.IntegerPrimitiveN = 5678;
            sendEnt.IntegerPrimitiveNull = null;
            sendEnt.LongPrimitive = 5678;
            sendEnt.LongPrimitiveN = 5678;
            sendEnt.LongPrimitiveNull = null;
            sendEnt.String = "ResetTestTotested";

            TableEntity.DisableCompiledSerializers = true;
            var reflectionDict = sendEnt.WriteEntity(null);
            Assert.IsNull(sendEnt.CompiledWrite);

            TableEntity.DisableCompiledSerializers = false;
            var compiledDict = sendEnt.WriteEntity(null);
            Assert.IsNotNull(sendEnt.CompiledWrite);

            // Assert Serialized Dictionaries are the same
            Assert.AreEqual(reflectionDict.Count, compiledDict.Count);
            foreach (var kvp in reflectionDict)
            {
                Assert.IsTrue(compiledDict.ContainsKey(kvp.Key));
                Assert.AreEqual(reflectionDict[kvp.Key], compiledDict[kvp.Key]);
            }
        }
        public void TableRetrieveSyncWithReflection()
        {
            CloudTableClient tableClient = GenerateCloudTableClient();
            string pk = Guid.NewGuid().ToString();
            string rk = Guid.NewGuid().ToString();

            ComplexEntity sendEnt = new ComplexEntity(pk, rk);
            currentTable.Execute(TableOperation.Insert(sendEnt));


            TableQuery<ComplexEntity> query = new TableQuery<ComplexEntity>().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, pk));
            IEnumerable<ComplexEntity> result = currentTable.ExecuteQuery(query);
            ComplexEntity retrievedEntity = result.ToList().First() as ComplexEntity;

            Assert.AreEqual(sendEnt.String, retrievedEntity.String);

            Assert.AreEqual(sendEnt.Int64, retrievedEntity.Int64);
            Assert.AreEqual(sendEnt.Int64N, retrievedEntity.Int64N);
            Assert.AreEqual(sendEnt.Int64Null, retrievedEntity.Int64Null);

            Assert.AreEqual(sendEnt.LongPrimitive, retrievedEntity.LongPrimitive);
            Assert.AreEqual(sendEnt.LongPrimitiveN, retrievedEntity.LongPrimitiveN);
            Assert.AreEqual(sendEnt.LongPrimitiveNull, retrievedEntity.LongPrimitiveNull);

            Assert.AreEqual(sendEnt.Int32, retrievedEntity.Int32);
            Assert.AreEqual(sendEnt.Int32N, retrievedEntity.Int32N);
            Assert.AreEqual(sendEnt.Int32Null, retrievedEntity.Int32Null);
            Assert.AreEqual(sendEnt.IntegerPrimitive, retrievedEntity.IntegerPrimitive);
            Assert.AreEqual(sendEnt.IntegerPrimitiveN, retrievedEntity.IntegerPrimitiveN);
            Assert.AreEqual(sendEnt.IntegerPrimitiveNull, retrievedEntity.IntegerPrimitiveNull);

            Assert.AreEqual(sendEnt.Guid, retrievedEntity.Guid);
            Assert.AreEqual(sendEnt.GuidN, retrievedEntity.GuidN);
            Assert.AreEqual(sendEnt.GuidNull, retrievedEntity.GuidNull);

            Assert.AreEqual(sendEnt.Double, retrievedEntity.Double);
            Assert.AreEqual(sendEnt.DoubleN, retrievedEntity.DoubleN);
            Assert.AreEqual(sendEnt.DoubleNull, retrievedEntity.DoubleNull);
            Assert.AreEqual(sendEnt.DoublePrimitive, retrievedEntity.DoublePrimitive);
            Assert.AreEqual(sendEnt.DoublePrimitiveN, retrievedEntity.DoublePrimitiveN);
            Assert.AreEqual(sendEnt.DoublePrimitiveNull, retrievedEntity.DoublePrimitiveNull);

            Assert.AreEqual(sendEnt.BinaryPrimitive.GetValue(0), retrievedEntity.BinaryPrimitive.GetValue(0));
            Assert.AreEqual(sendEnt.BinaryPrimitive.GetValue(1), retrievedEntity.BinaryPrimitive.GetValue(1));
            Assert.AreEqual(sendEnt.BinaryPrimitive.GetValue(2), retrievedEntity.BinaryPrimitive.GetValue(2));
            Assert.AreEqual(sendEnt.BinaryPrimitive.GetValue(3), retrievedEntity.BinaryPrimitive.GetValue(3));

            Assert.AreEqual(sendEnt.BinaryNull, retrievedEntity.BinaryNull);
            Assert.AreEqual(sendEnt.Binary.GetValue(0), retrievedEntity.Binary.GetValue(0));
            Assert.AreEqual(sendEnt.Binary.GetValue(1), retrievedEntity.Binary.GetValue(1));
            Assert.AreEqual(sendEnt.Binary.GetValue(2), retrievedEntity.Binary.GetValue(2));
            Assert.AreEqual(sendEnt.Binary.GetValue(3), retrievedEntity.Binary.GetValue(3));


            Assert.AreEqual(sendEnt.BoolPrimitive, retrievedEntity.BoolPrimitive);
            Assert.AreEqual(sendEnt.BoolPrimitiveN, retrievedEntity.BoolPrimitiveN);
            Assert.AreEqual(sendEnt.BoolPrimitiveNull, retrievedEntity.BoolPrimitiveNull);
            Assert.AreEqual(sendEnt.Bool, retrievedEntity.Bool);
            Assert.AreEqual(sendEnt.BoolN, retrievedEntity.BoolN);
            Assert.AreEqual(sendEnt.BoolNull, retrievedEntity.BoolNull);

            Assert.AreEqual(sendEnt.DateTimeOffset, retrievedEntity.DateTimeOffset);
            Assert.AreEqual(sendEnt.DateTimeOffsetN, retrievedEntity.DateTimeOffsetN);
            Assert.AreEqual(sendEnt.DateTimeOffsetNull, retrievedEntity.DateTimeOffsetNull);
            Assert.AreEqual(sendEnt.DateTime, retrievedEntity.DateTime);
            Assert.AreEqual(sendEnt.DateTimeN, retrievedEntity.DateTimeN);
            Assert.AreEqual(sendEnt.DateTimeNull, retrievedEntity.DateTimeNull);
        }
        private void DoTableGenericQueryComplexWithoutPropertyResolverSync(TablePayloadFormat format)
        {
            tableClient.DefaultRequestOptions.PayloadFormat = format;
            CloudTable currentTestTable = tableClient.GetTableReference("tbl" + Guid.NewGuid().ToString("N"));
            try
            {
                currentTestTable.CreateIfNotExists();

                ComplexEntity ent = new ComplexEntity("tables_batch_1", Guid.NewGuid().ToString());
                currentTestTable.Execute(TableOperation.Insert(ent));

                TableQuery<ComplexEntity> query = new TableQuery<ComplexEntity>().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "tables_batch_1"));

                TableQuerySegment<ComplexEntity> seg = currentTestTable.ExecuteQuerySegmented(query, null);

                foreach (ComplexEntity retrievedEnt in seg)
                {
                    Assert.AreEqual(retrievedEnt.PartitionKey, "tables_batch_1");
                    ComplexEntity.AssertEquality(ent, retrievedEnt);
                }
            }
            finally
            {
                currentTestTable.DeleteIfExists();
            }
        }
        private async Task DoTableRegionalQueryOnSupportedTypesAsync(TablePayloadFormat format)
        {
            CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
            Thread.CurrentThread.CurrentCulture = new CultureInfo("tr-TR");

            CloudTableClient client = GenerateCloudTableClient();
            client.DefaultRequestOptions.PayloadFormat = format;

            CloudTable table = client.GetTableReference(GenerateRandomTableName());
            await table.CreateAsync();

            try
            {
                // Setup
                TableBatchOperation batch = new TableBatchOperation();
                string pk = Guid.NewGuid().ToString();
                DynamicTableEntity middleRef = null;
                for (int m = 0; m < 100; m++)
                {
                    ComplexEntity complexEntity = new ComplexEntity();
                    complexEntity.String = string.Format("{0:0000}", m);
                    complexEntity.Binary = new byte[] { 0x01, 0x02, (byte)m };
                    complexEntity.BinaryPrimitive = new byte[] { 0x01, 0x02, (byte)m };
                    complexEntity.Bool = m % 2 == 0 ? true : false;
                    complexEntity.BoolPrimitive = m % 2 == 0 ? true : false;
                    complexEntity.Double = m + ((double)m / 100);
                    complexEntity.DoublePrimitive = m + ((double)m / 100);
                    complexEntity.Int32 = m;
                    complexEntity.IntegerPrimitive = m;
                    complexEntity.Int64 = (long)int.MaxValue + m;
                    complexEntity.LongPrimitive = (long)int.MaxValue + m;
                    complexEntity.Guid = Guid.NewGuid();

                    DynamicTableEntity dynEnt = new DynamicTableEntity(pk, string.Format("{0:0000}", m));
                    dynEnt.Properties = complexEntity.WriteEntity(null);
                    batch.Insert(dynEnt);

                    if (m == 50)
                    {
                        middleRef = dynEnt;
                    }

                    // Add delay to make times unique
                    await Task.Delay(100);
                }

                await table.ExecuteBatchAsync(batch);

                // 1. Filter on String
                ExecuteQueryAndAssertResults(table,
                        TableQuery.GenerateFilterCondition("String", QueryComparisons.GreaterThanOrEqual, "0050"), 50);

                // 2. Filter on Guid
                ExecuteQueryAndAssertResults(table,
                        TableQuery.GenerateFilterConditionForGuid("Guid", QueryComparisons.Equal, middleRef.Properties["Guid"].GuidValue.Value), 1);

                // 3. Filter on Long
                ExecuteQueryAndAssertResults(table,
                        TableQuery.GenerateFilterConditionForLong("Int64", QueryComparisons.GreaterThanOrEqual,
                                middleRef.Properties["LongPrimitive"].Int64Value.Value), 50);

                ExecuteQueryAndAssertResults(table, TableQuery.GenerateFilterConditionForLong("LongPrimitive",
                        QueryComparisons.GreaterThanOrEqual, middleRef.Properties["LongPrimitive"].Int64Value.Value), 50);

                // 4. Filter on Double
                ExecuteQueryAndAssertResults(table,
                        TableQuery.GenerateFilterConditionForDouble("Double", QueryComparisons.GreaterThanOrEqual,
                                middleRef.Properties["Double"].DoubleValue.Value), 50);

                ExecuteQueryAndAssertResults(table, TableQuery.GenerateFilterConditionForDouble("DoublePrimitive",
                        QueryComparisons.GreaterThanOrEqual, middleRef.Properties["DoublePrimitive"].DoubleValue.Value), 50);

                // 5. Filter on Integer
                ExecuteQueryAndAssertResults(table,
                        TableQuery.GenerateFilterConditionForInt("Int32", QueryComparisons.GreaterThanOrEqual,
                                middleRef.Properties["Int32"].Int32Value.Value), 50);

                ExecuteQueryAndAssertResults(table, TableQuery.GenerateFilterConditionForInt("IntegerPrimitive",
                        QueryComparisons.GreaterThanOrEqual, middleRef.Properties["IntegerPrimitive"].Int32Value.Value), 50);

                // 6. Filter on Date
                ExecuteQueryAndAssertResults(table,
                        TableQuery.GenerateFilterConditionForDate("DateTimeOffset", QueryComparisons.GreaterThanOrEqual,
                                middleRef.Properties["DateTimeOffset"].DateTimeOffsetValue.Value), 50);

                // 7. Filter on Boolean
                ExecuteQueryAndAssertResults(table,
                        TableQuery.GenerateFilterConditionForBool("Bool", QueryComparisons.Equal, middleRef.Properties["Bool"].BooleanValue.Value), 50);

                ExecuteQueryAndAssertResults(table,
                        TableQuery.GenerateFilterConditionForBool("BoolPrimitive", QueryComparisons.Equal, middleRef.Properties["BoolPrimitive"].BooleanValue.Value),
                        50);

                // 8. Filter on Binary 
                ExecuteQueryAndAssertResults(table,
                        TableQuery.GenerateFilterConditionForBinary("Binary", QueryComparisons.Equal, middleRef.Properties["Binary"].BinaryValue), 1);

                ExecuteQueryAndAssertResults(table,
                        TableQuery.GenerateFilterConditionForBinary("BinaryPrimitive", QueryComparisons.Equal,
                                middleRef.Properties["BinaryPrimitive"].BinaryValue), 1);

                // 9. Filter on Binary GTE
                ExecuteQueryAndAssertResults(table,
                        TableQuery.GenerateFilterConditionForBinary("Binary", QueryComparisons.GreaterThanOrEqual,
                                middleRef.Properties["Binary"].BinaryValue), 50);

                ExecuteQueryAndAssertResults(table, TableQuery.GenerateFilterConditionForBinary("BinaryPrimitive",
                        QueryComparisons.GreaterThanOrEqual, middleRef.Properties["BinaryPrimitive"].BinaryValue), 50);

                // 10. Complex Filter on Binary GTE
                ExecuteQueryAndAssertResults(table, TableQuery.CombineFilters(
                        TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal,
                                middleRef.PartitionKey),
                        TableOperators.And,
                        TableQuery.GenerateFilterConditionForBinary("Binary", QueryComparisons.GreaterThanOrEqual,
                                middleRef.Properties["Binary"].BinaryValue)), 50);

                ExecuteQueryAndAssertResults(table, TableQuery.GenerateFilterConditionForBinary("BinaryPrimitive",
                        QueryComparisons.GreaterThanOrEqual, middleRef.Properties["BinaryPrimitive"].BinaryValue), 50);
            }
            finally
            {
                Thread.CurrentThread.CurrentCulture = currentCulture;
                table.DeleteIfExistsAsync().Wait();
            }
        }
        private void DoTableRetrieveWithGenericOverloadWithProjectionSync(TablePayloadFormat format)
        {
            tableClient.DefaultRequestOptions.PayloadFormat = format;

            // Insert entity
            string pk = Guid.NewGuid().ToString();
            string rk = Guid.NewGuid().ToString();
            TableEntity.DisableCompiledSerializers = true;
            ComplexEntity sendEnt = new ComplexEntity(pk, rk);
            sendEnt.String = "ResetTestTotested";
            sendEnt.Double = (Double)5678.5678;
            sendEnt.IntegerPrimitive = 5678;
            currentTable.Execute(TableOperation.Insert(sendEnt));

            List<string> selectedColumns = new List<string>
            {
                "Double",
                "IntegerPrimitive"
            };

            // Retrieve entity
            TableResult result = currentTable.Execute(TableOperation.Retrieve<ComplexEntity>(sendEnt.PartitionKey, sendEnt.RowKey, selectedColumns));
            ComplexEntity retEntity = result.Result as ComplexEntity;

            // Validate entity
            Assert.AreEqual(retEntity.Double, sendEnt.Double);
            Assert.AreEqual(retEntity.IntegerPrimitive, sendEnt.IntegerPrimitive);
            Assert.AreNotEqual(retEntity.String, sendEnt.String);
        }
        public void TableEdmTypeCheck()
        {
            CloudTableClient tableClient = GenerateCloudTableClient();
            string pk = Guid.NewGuid().ToString();

            DynamicTableEntity sendEnt = new DynamicTableEntity();
            sendEnt.PartitionKey = pk;
            sendEnt.RowKey = Guid.NewGuid().ToString();

            ComplexEntity ent = new ComplexEntity();

            ent.String = null;
            sendEnt.Properties = ent.WriteEntity(null);

            string value = sendEnt.Properties["String"].StringValue;
            Assert.AreEqual(EdmType.String, sendEnt.Properties["String"].PropertyType);

            sendEnt.Properties["String"].StringValue = "helloworld";
            Assert.AreEqual(EdmType.String, sendEnt.Properties["String"].PropertyType);

            sendEnt.Properties["String"].StringValue = null;
            Assert.AreEqual(EdmType.String, sendEnt.Properties["String"].PropertyType);

            ent.Binary = null;
            sendEnt.Properties = ent.WriteEntity(null);

            byte[] binaryValue = sendEnt.Properties["Binary"].BinaryValue;
            Assert.AreEqual(EdmType.Binary, sendEnt.Properties["Binary"].PropertyType);

            sendEnt.Properties["Binary"].BinaryValue = new byte[] { 1, 2 };
            Assert.AreEqual(EdmType.Binary, sendEnt.Properties["Binary"].PropertyType);

            sendEnt.Properties["Binary"].BinaryValue = null;
            Assert.AreEqual(EdmType.Binary, sendEnt.Properties["Binary"].PropertyType);

            ent.DateTimeN = null;
            sendEnt.Properties = ent.WriteEntity(null);

            DateTime? dateTimeValue = sendEnt.Properties["DateTimeN"].DateTime;
            Assert.AreEqual(EdmType.DateTime, sendEnt.Properties["DateTimeN"].PropertyType);

            sendEnt.Properties["DateTimeN"].DateTime = DateTime.Now;
            Assert.AreEqual(EdmType.DateTime, sendEnt.Properties["DateTimeN"].PropertyType);

            sendEnt.Properties["DateTimeN"].DateTime = null;
            Assert.AreEqual(EdmType.DateTime, sendEnt.Properties["DateTimeN"].PropertyType);

            ent.DateTimeOffsetN = null;
            sendEnt.Properties = ent.WriteEntity(null);

            DateTimeOffset? dateTimeOffsetValue = sendEnt.Properties["DateTimeOffsetN"].DateTimeOffsetValue;
            Assert.AreEqual(EdmType.DateTime, sendEnt.Properties["DateTimeOffsetN"].PropertyType);

            sendEnt.Properties["DateTimeOffsetN"].DateTimeOffsetValue = DateTimeOffset.Now;
            Assert.AreEqual(EdmType.DateTime, sendEnt.Properties["DateTimeOffsetN"].PropertyType);

            sendEnt.Properties["DateTimeOffsetN"].DateTimeOffsetValue = null;
            Assert.AreEqual(EdmType.DateTime, sendEnt.Properties["DateTimeOffsetN"].PropertyType);

            ent.DoubleN = null;
            sendEnt.Properties = ent.WriteEntity(null);

            double? doubleValue = sendEnt.Properties["DoubleN"].DoubleValue;
            Assert.AreEqual(EdmType.Double, sendEnt.Properties["DoubleN"].PropertyType);

            sendEnt.Properties["DoubleN"].DoubleValue = 1234.5678;
            Assert.AreEqual(EdmType.Double, sendEnt.Properties["DoubleN"].PropertyType);

            sendEnt.Properties["DoubleN"].DoubleValue = null;
            Assert.AreEqual(EdmType.Double, sendEnt.Properties["DoubleN"].PropertyType);

            ent.GuidN = null;
            sendEnt.Properties = ent.WriteEntity(null);

            Guid? guidValue = sendEnt.Properties["GuidN"].GuidValue;
            Assert.AreEqual(EdmType.Guid, sendEnt.Properties["GuidN"].PropertyType);

            sendEnt.Properties["GuidN"].GuidValue = Guid.NewGuid();
            Assert.AreEqual(EdmType.Guid, sendEnt.Properties["GuidN"].PropertyType);

            sendEnt.Properties["GuidN"].GuidValue = null;
            Assert.AreEqual(EdmType.Guid, sendEnt.Properties["GuidN"].PropertyType);

            ent.Int32N = null;
            sendEnt.Properties = ent.WriteEntity(null);

            int? intValue = sendEnt.Properties["Int32N"].Int32Value;
            Assert.AreEqual(EdmType.Int32, sendEnt.Properties["Int32N"].PropertyType);

            sendEnt.Properties["Int32N"].Int32Value = 123;
            Assert.AreEqual(EdmType.Int32, sendEnt.Properties["Int32N"].PropertyType);

            sendEnt.Properties["Int32N"].Int32Value = null;
            Assert.AreEqual(EdmType.Int32, sendEnt.Properties["Int32N"].PropertyType);

            ent.LongPrimitiveN = null;
            sendEnt.Properties = ent.WriteEntity(null);

            long? longValue = sendEnt.Properties["LongPrimitiveN"].Int64Value;
            Assert.AreEqual(EdmType.Int64, sendEnt.Properties["LongPrimitiveN"].PropertyType);

            sendEnt.Properties["LongPrimitiveN"].Int64Value = 1234;
            Assert.AreEqual(EdmType.Int64, sendEnt.Properties["LongPrimitiveN"].PropertyType);

            sendEnt.Properties["LongPrimitiveN"].Int64Value = null;
            Assert.AreEqual(EdmType.Int64, sendEnt.Properties["LongPrimitiveN"].PropertyType);

            ent.BoolN = null;
            sendEnt.Properties = ent.WriteEntity(null);

            bool? booleanValue = sendEnt.Properties["BoolN"].BooleanValue;
            Assert.AreEqual(EdmType.Boolean, sendEnt.Properties["BoolN"].PropertyType);

            sendEnt.Properties["BoolN"].BooleanValue = true;
            Assert.AreEqual(EdmType.Boolean, sendEnt.Properties["BoolN"].PropertyType);

            sendEnt.Properties["BoolN"].BooleanValue = null;
            Assert.AreEqual(EdmType.Boolean, sendEnt.Properties["BoolN"].PropertyType);
        }
 public void ReflectionBasedSerializationTest()
 {
     ComplexEntity ent = new ComplexEntity();
     ComplexEntity secondEnt = new ComplexEntity();
     secondEnt.ReadEntity(ent.WriteEntity(null), null);
     ComplexEntity.AssertEquality(ent, secondEnt);
 }
        public void TableRetrieveSyncWithReflection()
        {
            CloudTableClient tableClient = GenerateCloudTableClient();
            string pk = Guid.NewGuid().ToString();
            string rk = Guid.NewGuid().ToString();

            ComplexEntity sendEnt = new ComplexEntity(pk, rk);
            sendEnt.Binary = new Byte[] { 5, 6, 7, 8 };
            sendEnt.BinaryNull = null;
            sendEnt.BinaryPrimitive = new byte[] { 5, 6, 7, 8 };
            sendEnt.Bool = true;
            sendEnt.BoolN = true;
            sendEnt.BoolNull = null;
            sendEnt.BoolPrimitive = true;
            sendEnt.BoolPrimitiveN = true;
            sendEnt.BoolPrimitiveNull = null;
            sendEnt.DateTime = DateTime.UtcNow.AddMinutes(1);
            sendEnt.DateTimeN = DateTime.UtcNow.AddMinutes(1);
            sendEnt.DateTimeNull = null;
            sendEnt.DateTimeOffset = DateTimeOffset.Now.AddMinutes(1);
            sendEnt.DateTimeOffsetN = DateTimeOffset.Now.AddMinutes(1);
            sendEnt.DateTimeOffsetNull = null;
            sendEnt.Double = (Double)5678.5678;
            sendEnt.DoubleN = (Double)5678.5678;
            sendEnt.DoubleNull = null;
            sendEnt.DoublePrimitive = (double)5678.5678;
            sendEnt.DoublePrimitiveN = (double)5678.5678;
            sendEnt.DoublePrimitiveNull = null;
            sendEnt.Guid = Guid.NewGuid();
            sendEnt.GuidN = Guid.NewGuid();
            sendEnt.GuidNull = null;
            sendEnt.Int32 = 5678;
            sendEnt.Int32N = 5678;
            sendEnt.Int32Null = null;
            sendEnt.Int64 = (long)5678;
            sendEnt.Int64N = (long)5678;
            sendEnt.Int64Null = null;
            sendEnt.IntegerPrimitive = 5678;
            sendEnt.IntegerPrimitiveN = 5678;
            sendEnt.IntegerPrimitiveNull = null;
            sendEnt.LongPrimitive = 5678;
            sendEnt.LongPrimitiveN = 5678;
            sendEnt.LongPrimitiveNull = null;
            sendEnt.String = "ResetTestTotested";
            currentTable.Execute(TableOperation.Insert(sendEnt));

            TableQuery<ComplexEntity> query = new TableQuery<ComplexEntity>().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, pk));
            IEnumerable<ComplexEntity> result = currentTable.ExecuteQuery(query);
            ComplexEntity retrievedEntity = result.ToList().First() as ComplexEntity;

            Assert.AreEqual(sendEnt.String, retrievedEntity.String);

            Assert.AreEqual(sendEnt.Int64, retrievedEntity.Int64);
            Assert.AreEqual(sendEnt.Int64N, retrievedEntity.Int64N);
            Assert.AreEqual(sendEnt.Int64Null, retrievedEntity.Int64Null);

            Assert.AreEqual(sendEnt.LongPrimitive, retrievedEntity.LongPrimitive);
            Assert.AreEqual(sendEnt.LongPrimitiveN, retrievedEntity.LongPrimitiveN);
            Assert.AreEqual(sendEnt.LongPrimitiveNull, retrievedEntity.LongPrimitiveNull);

            Assert.AreEqual(sendEnt.Int32, retrievedEntity.Int32);
            Assert.AreEqual(sendEnt.Int32N, retrievedEntity.Int32N);
            Assert.AreEqual(sendEnt.Int32Null, retrievedEntity.Int32Null);
            Assert.AreEqual(sendEnt.IntegerPrimitive, retrievedEntity.IntegerPrimitive);
            Assert.AreEqual(sendEnt.IntegerPrimitiveN, retrievedEntity.IntegerPrimitiveN);
            Assert.AreEqual(sendEnt.IntegerPrimitiveNull, retrievedEntity.IntegerPrimitiveNull);

            Assert.AreEqual(sendEnt.Guid, retrievedEntity.Guid);
            Assert.AreEqual(sendEnt.GuidN, retrievedEntity.GuidN);
            Assert.AreEqual(sendEnt.GuidNull, retrievedEntity.GuidNull);

            Assert.AreEqual(sendEnt.Double, retrievedEntity.Double);
            Assert.AreEqual(sendEnt.DoubleN, retrievedEntity.DoubleN);
            Assert.AreEqual(sendEnt.DoubleNull, retrievedEntity.DoubleNull);
            Assert.AreEqual(sendEnt.DoublePrimitive, retrievedEntity.DoublePrimitive);
            Assert.AreEqual(sendEnt.DoublePrimitiveN, retrievedEntity.DoublePrimitiveN);
            Assert.AreEqual(sendEnt.DoublePrimitiveNull, retrievedEntity.DoublePrimitiveNull);

            Assert.AreEqual(sendEnt.BinaryPrimitive.GetValue(0), retrievedEntity.BinaryPrimitive.GetValue(0));
            Assert.AreEqual(sendEnt.BinaryPrimitive.GetValue(1), retrievedEntity.BinaryPrimitive.GetValue(1));
            Assert.AreEqual(sendEnt.BinaryPrimitive.GetValue(2), retrievedEntity.BinaryPrimitive.GetValue(2));
            Assert.AreEqual(sendEnt.BinaryPrimitive.GetValue(3), retrievedEntity.BinaryPrimitive.GetValue(3));

            Assert.AreEqual(sendEnt.BinaryNull, retrievedEntity.BinaryNull);
            Assert.AreEqual(sendEnt.Binary.GetValue(0), retrievedEntity.Binary.GetValue(0));
            Assert.AreEqual(sendEnt.Binary.GetValue(1), retrievedEntity.Binary.GetValue(1));
            Assert.AreEqual(sendEnt.Binary.GetValue(2), retrievedEntity.Binary.GetValue(2));
            Assert.AreEqual(sendEnt.Binary.GetValue(3), retrievedEntity.Binary.GetValue(3));


            Assert.AreEqual(sendEnt.BoolPrimitive, retrievedEntity.BoolPrimitive);
            Assert.AreEqual(sendEnt.BoolPrimitiveN, retrievedEntity.BoolPrimitiveN);
            Assert.AreEqual(sendEnt.BoolPrimitiveNull, retrievedEntity.BoolPrimitiveNull);
            Assert.AreEqual(sendEnt.Bool, retrievedEntity.Bool);
            Assert.AreEqual(sendEnt.BoolN, retrievedEntity.BoolN);
            Assert.AreEqual(sendEnt.BoolNull, retrievedEntity.BoolNull);

            Assert.AreEqual(sendEnt.DateTimeOffset, retrievedEntity.DateTimeOffset);
            Assert.AreEqual(sendEnt.DateTimeOffsetN, retrievedEntity.DateTimeOffsetN);
            Assert.AreEqual(sendEnt.DateTimeOffsetNull, retrievedEntity.DateTimeOffsetNull);
            Assert.AreEqual(sendEnt.DateTime, retrievedEntity.DateTime);
            Assert.AreEqual(sendEnt.DateTimeN, retrievedEntity.DateTimeN);
            Assert.AreEqual(sendEnt.DateTimeNull, retrievedEntity.DateTimeNull);
        }
Пример #14
0
        public static void AssertEquality(ComplexEntityWithNestedComplexProperties a, ComplexEntityWithNestedComplexProperties b)
        {
            if (ReferenceEquals(a, b))
            {
                return;
            }

            Assert.IsNotNull(a);
            Assert.IsNotNull(b);

            // Validate ComplexEntity type complex property
            ComplexEntity.AssertEquality(a.ComplexEntity, b.ComplexEntity);

            // Validate Shape type complex property
            Assert.AreEqual(a.ShapeEntity.PartitionKey, b.ShapeEntity.PartitionKey);
            Assert.AreEqual(a.ShapeEntity.RowKey, b.ShapeEntity.RowKey);
            Assert.AreEqual(a.ShapeEntity.Breadth, b.ShapeEntity.Breadth);
            Assert.AreEqual(a.ShapeEntity.Length, b.ShapeEntity.Length);
            Assert.AreEqual(a.ShapeEntity.Name, b.ShapeEntity.Name);

            //Validate simple properties

            Assert.AreEqual(a.String, b.String);
            Assert.AreEqual(a.Int64, b.Int64);
            Assert.AreEqual(a.Int64N, b.Int64N);
            Assert.AreEqual(a.Int64Null, b.Int64Null);
            Assert.AreEqual(a.LongPrimitive, b.LongPrimitive);
            Assert.AreEqual(a.LongPrimitiveN, b.LongPrimitiveN);
            Assert.AreEqual(a.LongPrimitiveNull, b.LongPrimitiveNull);
            Assert.AreEqual(a.Int32, b.Int32);
            Assert.AreEqual(a.Int32N, b.Int32N);
            Assert.AreEqual(a.Int32Null, b.Int32Null);
            Assert.AreEqual(a.IntegerPrimitive, b.IntegerPrimitive);
            Assert.AreEqual(a.integerPrimitiveN, b.IntegerPrimitiveN);
            Assert.AreEqual(a.IntegerPrimitiveNull, b.IntegerPrimitiveNull);
            Assert.AreEqual(a.Guid, b.Guid);
            Assert.AreEqual(a.GuidN, b.GuidN);
            Assert.AreEqual(a.GuidNull, b.GuidNull);
            Assert.AreEqual(a.Double, b.Double);
            Assert.AreEqual(a.DoubleN, b.DoubleN);
            Assert.AreEqual(a.DoubleNull, b.DoubleNull);
            Assert.AreEqual(a.DoublePrimitive, b.DoublePrimitive);
            Assert.AreEqual(a.DoublePrimitiveN, b.DoublePrimitiveN);
            Assert.AreEqual(a.DoublePrimitiveNull, b.DoublePrimitiveNull);
            Assert.AreEqual(a.BinaryPrimitive.GetValue(0), b.BinaryPrimitive.GetValue(0));
            Assert.AreEqual(a.BinaryPrimitive.GetValue(1), b.BinaryPrimitive.GetValue(1));
            Assert.AreEqual(a.BinaryPrimitive.GetValue(2), b.BinaryPrimitive.GetValue(2));
            Assert.AreEqual(a.BinaryPrimitive.GetValue(3), b.BinaryPrimitive.GetValue(3));
            Assert.AreEqual(a.Binary.GetValue(0), b.Binary.GetValue(0));
            Assert.AreEqual(a.Binary.GetValue(1), b.Binary.GetValue(1));
            Assert.AreEqual(a.Binary.GetValue(2), b.Binary.GetValue(2));
            Assert.AreEqual(a.Binary.GetValue(3), b.Binary.GetValue(3));
            Assert.AreEqual(a.BoolPrimitive, b.BoolPrimitive);
            Assert.AreEqual(a.BoolPrimitiveN, b.BoolPrimitiveN);
            Assert.AreEqual(a.BoolPrimitiveNull, b.BoolPrimitiveNull);
            Assert.AreEqual(a.Bool, b.Bool);
            Assert.AreEqual(a.BoolN, b.BoolN);
            Assert.AreEqual(a.BoolNull, b.BoolNull);
            Assert.AreEqual(a.DateTimeOffsetN, b.DateTimeOffsetN);
            Assert.AreEqual(a.DateTimeOffset, b.DateTimeOffset);
            Assert.AreEqual(a.DateTimeOffsetNull, b.DateTimeOffsetNull);
            Assert.AreEqual(a.DateTime, b.DateTime);
            Assert.AreEqual(a.DateTimeN, b.DateTimeN);
            Assert.AreEqual(a.DateTimeNull, b.DateTimeNull);

            // Validate ComplexEntityWithComplexProperties type composite property
            AssertEquality(a.InnerComplexEntityWithNestedComplexProperties, b.InnerComplexEntityWithNestedComplexProperties);
        }
        public async Task TableOperationInsertSingleQuoteAsync()
        {
            CloudTableClient tableClient = GenerateCloudTableClient();

            DynamicTableEntity ent = new DynamicTableEntity() { PartitionKey = "partition'key", RowKey = "row'key" };
            ent.Properties.Add("stringprop", new EntityProperty("string'value"));
            await currentTable.ExecuteAsync(TableOperation.InsertOrReplace(ent));

            TableQuery<DynamicTableEntity> query = new TableQuery<DynamicTableEntity>().Where(TableQuery.CombineFilters(
                (TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, ent.PartitionKey)),
                TableOperators.And,
                (TableQuery.GenerateFilterCondition("stringprop", QueryComparisons.Equal, ent.Properties["stringprop"].StringValue))));

            TableQuerySegment<DynamicTableEntity> seg = await currentTable.ExecuteQuerySegmentedAsync(query, null);

            foreach (DynamicTableEntity retrievedEntity in seg)
            {
                Assert.IsNotNull(retrievedEntity);
                Assert.AreEqual(ent.PartitionKey, retrievedEntity.PartitionKey);
                Assert.AreEqual(ent.RowKey, retrievedEntity.RowKey);
                Assert.AreEqual(ent.Properties["stringprop"].StringValue, retrievedEntity.Properties["stringprop"].StringValue);
            }

            ComplexEntity complexEntity = new ComplexEntity() { PartitionKey = "partition'key", RowKey = "row'key" };
            await currentTable.ExecuteAsync(TableOperation.InsertOrReplace(complexEntity));

            TableQuery<ComplexEntity> query2 = new TableQuery<ComplexEntity>().Where(TableQuery.CombineFilters(
              (TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, ent.PartitionKey)),
              TableOperators.And,
              (TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.Equal, ent.RowKey))));

            TableQuerySegment<ComplexEntity> seg2 = await currentTable.ExecuteQuerySegmentedAsync(query2, null);
            foreach (ComplexEntity retrievedComplexEntity in seg2)
            {
                Assert.IsNotNull(retrievedComplexEntity);
                Assert.AreEqual(ent.PartitionKey, retrievedComplexEntity.PartitionKey);
                Assert.AreEqual(ent.RowKey, retrievedComplexEntity.RowKey);
            }
        }
        public static void MyClassInitialize(TestContext testContext)
        {
            CloudTableClient tableClient = GenerateCloudTableClient();
            currentTable = tableClient.GetTableReference(GenerateRandomTableName());
            currentTable.CreateIfNotExists();

            // Bulk Query Entities
            for (int i = 0; i < 15; i++)
            {
                TableBatchOperation batch = new TableBatchOperation();

                for (int j = 0; j < 100; j++)
                {
                    var ent = GenerateRandomEnitity("tables_batch_" + i.ToString());
                    ent.RowKey = string.Format("{0:0000}", j);
                 
                    batch.Insert(ent);
                }

                currentTable.ExecuteBatch(batch);
            }

            complexEntityTable = tableClient.GetTableReference(GenerateRandomTableName());
            complexEntityTable.Create();

            // Setup
            TableBatchOperation complexBatch = new TableBatchOperation();
            string pk = Guid.NewGuid().ToString();

            for (int m = 0; m < 100; m++)
            {
                ComplexEntity complexEntity = new ComplexEntity(pk, string.Format("{0:0000}", m));
                complexEntity.String = string.Format("{0:0000}", m);
                complexEntity.Binary = new byte[] { 0x01, 0x02, (byte)m };
                complexEntity.BinaryPrimitive = new byte[] { 0x01, 0x02, (byte)m };
                complexEntity.Bool = m % 2 == 0 ? true : false;
                complexEntity.BoolPrimitive = m % 2 == 0 ? true : false;
                complexEntity.Double = m + ((double)m / 100);
                complexEntity.DoublePrimitive = m + ((double)m / 100);
                complexEntity.Int32 = m;
                complexEntity.Int32N = m;
                complexEntity.IntegerPrimitive = m;
                complexEntity.IntegerPrimitiveN = m;
                complexEntity.Int64 = (long)int.MaxValue + m;
                complexEntity.LongPrimitive = (long)int.MaxValue + m;
                complexEntity.LongPrimitiveN = (long)int.MaxValue + m;
                complexEntity.Guid = Guid.NewGuid();

                complexBatch.Insert(complexEntity);

                if (m == 50)
                {
                    middleRef = complexEntity;
                }

                // Add delay to make times unique
                Thread.Sleep(100);
            }

            complexEntityTable.ExecuteBatch(complexBatch);
        }
        private void DoTableRetrieveSyncWithReflection(TablePayloadFormat format)
        {
            tableClient.DefaultRequestOptions.PayloadFormat = format;
            string pk = Guid.NewGuid().ToString();
            string rk = Guid.NewGuid().ToString();

            ComplexEntity sendEnt = new ComplexEntity(pk, rk);
            sendEnt.Binary = new Byte[] { 5, 6, 7, 8 };
            sendEnt.BinaryNull = null;
            sendEnt.BinaryPrimitive = new byte[] { 5, 6, 7, 8 };
            sendEnt.Bool = true;
            sendEnt.BoolN = true;
            sendEnt.BoolNull = null;
            sendEnt.BoolPrimitive = true;
            sendEnt.BoolPrimitiveN = true;
            sendEnt.BoolPrimitiveNull = null;
            sendEnt.DateTime = DateTime.UtcNow.AddMinutes(1);
            sendEnt.DateTimeN = DateTime.UtcNow.AddMinutes(1);
            sendEnt.DateTimeNull = null;
            sendEnt.DateTimeOffset = DateTimeOffset.Now.AddMinutes(1);
            sendEnt.DateTimeOffsetN = DateTimeOffset.Now.AddMinutes(1);
            sendEnt.DateTimeOffsetNull = null;
            sendEnt.Double = (Double)5678.5678;
            sendEnt.DoubleN = (Double)5678.5678;
            sendEnt.DoubleNull = null;
            sendEnt.DoublePrimitive = (double)5678.5678;
            sendEnt.DoublePrimitiveN = (double)5678.5678;
            sendEnt.DoublePrimitiveNull = null;
            sendEnt.Guid = Guid.NewGuid();
            sendEnt.GuidN = Guid.NewGuid();
            sendEnt.GuidNull = null;
            sendEnt.Int32 = 5678;
            sendEnt.Int32N = 5678;
            sendEnt.Int32Null = null;
            sendEnt.Int64 = (long)5678;
            sendEnt.Int64N = (long)5678;
            sendEnt.Int64Null = null;
            sendEnt.IntegerPrimitive = 5678;
            sendEnt.IntegerPrimitiveN = 5678;
            sendEnt.IntegerPrimitiveNull = null;
            sendEnt.LongPrimitive = 5678;
            sendEnt.LongPrimitiveN = 5678;
            sendEnt.LongPrimitiveNull = null;
            sendEnt.String = "ResetTestTotested";
            currentTable.Execute(TableOperation.Insert(sendEnt));

            TableResult res = currentTable.Execute(TableOperation.Retrieve<ComplexEntity>(sendEnt.PartitionKey, sendEnt.RowKey));
            ComplexEntity retrievedEntity = res.Result as ComplexEntity;

            Assert.AreEqual(sendEnt.String, retrievedEntity.String);

            Assert.AreEqual(sendEnt.Int64, retrievedEntity.Int64);
            Assert.AreEqual(sendEnt.Int64N, retrievedEntity.Int64N);
            Assert.AreEqual(sendEnt.Int64Null, retrievedEntity.Int64Null);

            Assert.AreEqual(sendEnt.LongPrimitive, retrievedEntity.LongPrimitive);
            Assert.AreEqual(sendEnt.LongPrimitiveN, retrievedEntity.LongPrimitiveN);
            Assert.AreEqual(sendEnt.LongPrimitiveNull, retrievedEntity.LongPrimitiveNull);

            Assert.AreEqual(sendEnt.Int32, retrievedEntity.Int32);
            Assert.AreEqual(sendEnt.Int32N, retrievedEntity.Int32N);
            Assert.AreEqual(sendEnt.Int32Null, retrievedEntity.Int32Null);
            Assert.AreEqual(sendEnt.IntegerPrimitive, retrievedEntity.IntegerPrimitive);
            Assert.AreEqual(sendEnt.IntegerPrimitiveN, retrievedEntity.IntegerPrimitiveN);
            Assert.AreEqual(sendEnt.IntegerPrimitiveNull, retrievedEntity.IntegerPrimitiveNull);

            Assert.AreEqual(sendEnt.Guid, retrievedEntity.Guid);
            Assert.AreEqual(sendEnt.GuidN, retrievedEntity.GuidN);
            Assert.AreEqual(sendEnt.GuidNull, retrievedEntity.GuidNull);

            Assert.AreEqual(sendEnt.Double, retrievedEntity.Double);
            Assert.AreEqual(sendEnt.DoubleN, retrievedEntity.DoubleN);
            Assert.AreEqual(sendEnt.DoubleNull, retrievedEntity.DoubleNull);
            Assert.AreEqual(sendEnt.DoublePrimitive, retrievedEntity.DoublePrimitive);
            Assert.AreEqual(sendEnt.DoublePrimitiveN, retrievedEntity.DoublePrimitiveN);
            Assert.AreEqual(sendEnt.DoublePrimitiveNull, retrievedEntity.DoublePrimitiveNull);

            Assert.AreEqual(sendEnt.BinaryPrimitive.GetValue(0), retrievedEntity.BinaryPrimitive.GetValue(0));
            Assert.AreEqual(sendEnt.BinaryPrimitive.GetValue(1), retrievedEntity.BinaryPrimitive.GetValue(1));
            Assert.AreEqual(sendEnt.BinaryPrimitive.GetValue(2), retrievedEntity.BinaryPrimitive.GetValue(2));
            Assert.AreEqual(sendEnt.BinaryPrimitive.GetValue(3), retrievedEntity.BinaryPrimitive.GetValue(3));

            Assert.AreEqual(sendEnt.BinaryNull, retrievedEntity.BinaryNull);
            Assert.AreEqual(sendEnt.Binary.GetValue(0), retrievedEntity.Binary.GetValue(0));
            Assert.AreEqual(sendEnt.Binary.GetValue(1), retrievedEntity.Binary.GetValue(1));
            Assert.AreEqual(sendEnt.Binary.GetValue(2), retrievedEntity.Binary.GetValue(2));
            Assert.AreEqual(sendEnt.Binary.GetValue(3), retrievedEntity.Binary.GetValue(3));


            Assert.AreEqual(sendEnt.BoolPrimitive, retrievedEntity.BoolPrimitive);
            Assert.AreEqual(sendEnt.BoolPrimitiveN, retrievedEntity.BoolPrimitiveN);
            Assert.AreEqual(sendEnt.BoolPrimitiveNull, retrievedEntity.BoolPrimitiveNull);
            Assert.AreEqual(sendEnt.Bool, retrievedEntity.Bool);
            Assert.AreEqual(sendEnt.BoolN, retrievedEntity.BoolN);
            Assert.AreEqual(sendEnt.BoolNull, retrievedEntity.BoolNull);

            Assert.AreEqual(sendEnt.DateTimeOffset, retrievedEntity.DateTimeOffset);
            Assert.AreEqual(sendEnt.DateTimeOffsetN, retrievedEntity.DateTimeOffsetN);
            Assert.AreEqual(sendEnt.DateTimeOffsetNull, retrievedEntity.DateTimeOffsetNull);
            Assert.AreEqual(sendEnt.DateTime, retrievedEntity.DateTime);
            Assert.AreEqual(sendEnt.DateTimeN, retrievedEntity.DateTimeN);
            Assert.AreEqual(sendEnt.DateTimeNull, retrievedEntity.DateTimeNull);
        }
        private void DoTableGenericQueryWithSpecificOnSupportedTypes(TablePayloadFormat format)
        {
            CloudTableClient client = GenerateCloudTableClient();

            CloudTable table = client.GetTableReference(GenerateRandomTableName());
            table.Create();
            client.DefaultRequestOptions.PayloadFormat = format;

            try
            {
                // Setup
                TableBatchOperation batch = new TableBatchOperation();
                string pk = Guid.NewGuid().ToString();
                ComplexEntity middleRef = null;
                for (int m = 0; m < 100; m++)
                {
                    ComplexEntity complexEntity = new ComplexEntity(pk, string.Format("{0:0000}", m));
                    complexEntity.String = string.Format("{0:0000}", m);
                    complexEntity.Binary = new byte[] { 0x01, 0x02, (byte)m };
                    complexEntity.BinaryPrimitive = new byte[] { 0x01, 0x02, (byte)m };
                    complexEntity.Bool = m % 2 == 0 ? true : false;
                    complexEntity.BoolPrimitive = m % 2 == 0 ? true : false;
                    complexEntity.Double = m + ((double)m / 100);
                    complexEntity.DoublePrimitive = m + ((double)m / 100);
                    complexEntity.Int32 = m;
                    complexEntity.IntegerPrimitive = m;
                    complexEntity.Int64 = (long)int.MaxValue + m;
                    complexEntity.LongPrimitive = (long)int.MaxValue + m;
                    complexEntity.Guid = Guid.NewGuid();

                    batch.Insert(complexEntity);

                    if (m == 50)
                    {
                        middleRef = complexEntity;
                    }

                    // Add delay to make times unique
                    Thread.Sleep(100);
                }

                table.ExecuteBatch(batch);

                // 1. Filter on String
                ExecuteQueryAndAssertResults(table,
                        TableQuery.GenerateFilterCondition("String", QueryComparisons.GreaterThanOrEqual, "0050"), 50);

                // 2. Filter on Guid
                ExecuteQueryAndAssertResults(table,
                        TableQuery.GenerateFilterConditionForGuid("Guid", QueryComparisons.Equal, middleRef.Guid), 1);

                // 3. Filter on Long
                ExecuteQueryAndAssertResults(table,
                        TableQuery.GenerateFilterConditionForLong("Int64", QueryComparisons.GreaterThanOrEqual,
                                middleRef.LongPrimitive), 50);

                ExecuteQueryAndAssertResults(table, TableQuery.GenerateFilterConditionForLong("LongPrimitive",
                        QueryComparisons.GreaterThanOrEqual, middleRef.LongPrimitive), 50);

                // 4. Filter on Double
                ExecuteQueryAndAssertResults(table,
                        TableQuery.GenerateFilterConditionForDouble("Double", QueryComparisons.GreaterThanOrEqual,
                                middleRef.Double), 50);

                ExecuteQueryAndAssertResults(table, TableQuery.GenerateFilterConditionForDouble("DoublePrimitive",
                        QueryComparisons.GreaterThanOrEqual, middleRef.DoublePrimitive), 50);

                // 5. Filter on Integer
                ExecuteQueryAndAssertResults(table,
                        TableQuery.GenerateFilterConditionForInt("Int32", QueryComparisons.GreaterThanOrEqual,
                                middleRef.Int32), 50);

                ExecuteQueryAndAssertResults(table, TableQuery.GenerateFilterConditionForInt("IntegerPrimitive",
                        QueryComparisons.GreaterThanOrEqual, middleRef.IntegerPrimitive), 50);

                // 6. Filter on Date
                ExecuteQueryAndAssertResults(table,
                        TableQuery.GenerateFilterConditionForDate("DateTimeOffset", QueryComparisons.GreaterThanOrEqual,
                                middleRef.DateTimeOffset), 50);

                // 7. Filter on Boolean
                ExecuteQueryAndAssertResults(table,
                        TableQuery.GenerateFilterConditionForBool("Bool", QueryComparisons.Equal, middleRef.Bool), 50);

                ExecuteQueryAndAssertResults(table,
                        TableQuery.GenerateFilterConditionForBool("BoolPrimitive", QueryComparisons.Equal, middleRef.BoolPrimitive),
                        50);

                // 8. Filter on Binary 
                ExecuteQueryAndAssertResults(table,
                        TableQuery.GenerateFilterConditionForBinary("Binary", QueryComparisons.Equal, middleRef.Binary), 1);

                ExecuteQueryAndAssertResults(table,
                        TableQuery.GenerateFilterConditionForBinary("BinaryPrimitive", QueryComparisons.Equal,
                                middleRef.BinaryPrimitive), 1);

                // 9. Filter on Binary GTE
                ExecuteQueryAndAssertResults(table,
                        TableQuery.GenerateFilterConditionForBinary("Binary", QueryComparisons.GreaterThanOrEqual,
                                middleRef.Binary), 50);

                ExecuteQueryAndAssertResults(table, TableQuery.GenerateFilterConditionForBinary("BinaryPrimitive",
                        QueryComparisons.GreaterThanOrEqual, middleRef.BinaryPrimitive), 50);

                // 10. Complex Filter on Binary GTE
                ExecuteQueryAndAssertResults(table, TableQuery.CombineFilters(
                        TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal,
                                middleRef.PartitionKey),
                        TableOperators.And,
                        TableQuery.GenerateFilterConditionForBinary("Binary", QueryComparisons.GreaterThanOrEqual,
                                middleRef.Binary)), 50);

                ExecuteQueryAndAssertResults(table, TableQuery.GenerateFilterConditionForBinary("BinaryPrimitive",
                        QueryComparisons.GreaterThanOrEqual, middleRef.BinaryPrimitive), 50);
            }
            finally
            {
                table.DeleteIfExists();
            }
        }
        public void TableRetrieveEntityPropertySetter()
        {
            CloudTableClient tableClient = GenerateCloudTableClient();
            string pk = Guid.NewGuid().ToString();

            // Add insert
            ComplexEntity sendEnt = new ComplexEntity();
            sendEnt.PartitionKey = pk;
            sendEnt.RowKey = Guid.NewGuid().ToString();

            Dictionary<string, EntityProperty> properties = new Dictionary<string, EntityProperty>();

            EntityProperty prop1 = properties["BoolN"] = EntityProperty.GeneratePropertyForBool(null);
            sendEnt.BoolN = prop1.BooleanValue = true;

            EntityProperty prop2 = properties["DoubleN"] = EntityProperty.GeneratePropertyForDouble(null);
            sendEnt.DoubleN = prop2.DoubleValue = 3.1415;

            EntityProperty prop3 = properties["GuidN"] = EntityProperty.GeneratePropertyForGuid(null);
            sendEnt.GuidN = prop3.GuidValue = Guid.NewGuid();

            EntityProperty prop4 = properties["Int32N"] = EntityProperty.GeneratePropertyForInt(null);
            sendEnt.Int32N = prop4.Int32Value = 1;

            EntityProperty prop5 = properties["Int64N"] = EntityProperty.GeneratePropertyForLong(null);
            sendEnt.Int64N = prop5.Int64Value = 1234;

            EntityProperty prop6 = properties["String"] = EntityProperty.GeneratePropertyForString(null);
            sendEnt.String = prop6.StringValue = "hello";

            EntityProperty prop7 = properties["DateTimeOffsetN"] = EntityProperty.GeneratePropertyForDateTimeOffset(null);
            sendEnt.DateTimeOffsetN = prop7.DateTimeOffsetValue = DateTimeOffset.UtcNow;

            ComplexEntity retrievedEntity = new ComplexEntity();
            retrievedEntity.ReadEntity(properties, null);

            Assert.AreEqual(sendEnt.BoolN, retrievedEntity.BoolN);
            Assert.AreEqual(sendEnt.DoubleN, retrievedEntity.DoubleN);
            Assert.AreEqual(sendEnt.GuidN, retrievedEntity.GuidN);
            Assert.AreEqual(sendEnt.Int32N, retrievedEntity.Int32N);
            Assert.AreEqual(sendEnt.Int64N, retrievedEntity.Int64N);
            Assert.AreEqual(sendEnt.String, retrievedEntity.String);
            Assert.AreEqual(sendEnt.DateTimeOffsetN, retrievedEntity.DateTimeOffsetN);
        }
        private void DoTableQueryWithPropertyResolverCache(bool disableCache)
        {
            CloudTable table = tableClient.GetTableReference(GenerateRandomTableName());
            try
            {
                table.CreateIfNotExists();

                tableClient.DefaultRequestOptions.PayloadFormat = TablePayloadFormat.JsonNoMetadata;
                TableEntity.DisablePropertyResolverCache = disableCache;

                string pk = Guid.NewGuid().ToString();

                // Add insert
                ComplexEntity sendEnt = new ComplexEntity();
                sendEnt.PartitionKey = pk;
                sendEnt.RowKey = Guid.NewGuid().ToString();

                // insert entity
                table.Execute(TableOperation.Insert(sendEnt));

                // Success
                TableQuery<ComplexEntity> query = new TableQuery<ComplexEntity>().Where(TableQuery.CombineFilters(
                    TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, sendEnt.PartitionKey),
                    TableOperators.And,
                    TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.Equal, sendEnt.RowKey)));
                IEnumerable<ComplexEntity> result = table.ExecuteQuery<ComplexEntity>(query);

                foreach (ComplexEntity retrievedEntity in result)
                {
                    // Validate entity
                    Assert.AreEqual(sendEnt.String, retrievedEntity.String);

                    Assert.AreEqual(sendEnt.Int64, retrievedEntity.Int64);
                    Assert.AreEqual(sendEnt.Int64N, retrievedEntity.Int64N);

                    Assert.AreEqual(sendEnt.LongPrimitive, retrievedEntity.LongPrimitive);
                    Assert.AreEqual(sendEnt.LongPrimitiveN, retrievedEntity.LongPrimitiveN);

                    Assert.AreEqual(sendEnt.Int32, retrievedEntity.Int32);
                    Assert.AreEqual(sendEnt.Int32N, retrievedEntity.Int32N);
                    Assert.AreEqual(sendEnt.IntegerPrimitive, retrievedEntity.IntegerPrimitive);
                    Assert.AreEqual(sendEnt.IntegerPrimitiveN, retrievedEntity.IntegerPrimitiveN);

                    Assert.AreEqual(sendEnt.Guid, retrievedEntity.Guid);
                    Assert.AreEqual(sendEnt.GuidN, retrievedEntity.GuidN);

                    Assert.AreEqual(sendEnt.Double, retrievedEntity.Double);
                    Assert.AreEqual(sendEnt.DoubleN, retrievedEntity.DoubleN);
                    Assert.AreEqual(sendEnt.DoublePrimitive, retrievedEntity.DoublePrimitive);
                    Assert.AreEqual(sendEnt.DoublePrimitiveN, retrievedEntity.DoublePrimitiveN);

                    Assert.AreEqual(sendEnt.BinaryPrimitive.GetValue(0), retrievedEntity.BinaryPrimitive.GetValue(0));
                    Assert.AreEqual(sendEnt.BinaryPrimitive.GetValue(1), retrievedEntity.BinaryPrimitive.GetValue(1));
                    Assert.AreEqual(sendEnt.BinaryPrimitive.GetValue(2), retrievedEntity.BinaryPrimitive.GetValue(2));
                    Assert.AreEqual(sendEnt.BinaryPrimitive.GetValue(3), retrievedEntity.BinaryPrimitive.GetValue(3));

                    Assert.AreEqual(sendEnt.Binary.GetValue(0), retrievedEntity.Binary.GetValue(0));
                    Assert.AreEqual(sendEnt.Binary.GetValue(1), retrievedEntity.Binary.GetValue(1));
                    Assert.AreEqual(sendEnt.Binary.GetValue(2), retrievedEntity.Binary.GetValue(2));
                    Assert.AreEqual(sendEnt.Binary.GetValue(3), retrievedEntity.Binary.GetValue(3));


                    Assert.AreEqual(sendEnt.BoolPrimitive, retrievedEntity.BoolPrimitive);
                    Assert.AreEqual(sendEnt.BoolPrimitiveN, retrievedEntity.BoolPrimitiveN);
                    Assert.AreEqual(sendEnt.Bool, retrievedEntity.Bool);
                    Assert.AreEqual(sendEnt.BoolN, retrievedEntity.BoolN);

                    Assert.AreEqual(sendEnt.DateTimeOffset, retrievedEntity.DateTimeOffset);
                    Assert.AreEqual(sendEnt.DateTimeOffsetN, retrievedEntity.DateTimeOffsetN);
                    Assert.AreEqual(sendEnt.DateTime, retrievedEntity.DateTime);
                    Assert.AreEqual(sendEnt.DateTimeN, retrievedEntity.DateTimeN);
                }
            }
            finally
            {
                table.DeleteIfExists();
                tableClient.DefaultRequestOptions.PayloadFormat = TablePayloadFormat.Json;
            }
        }
        private void DoTableOperationInsertSingleQuoteSync(TablePayloadFormat format)
        {
            tableClient.DefaultRequestOptions.PayloadFormat = format;
            DynamicTableEntity ent = new DynamicTableEntity() { PartitionKey = "partition'key", RowKey = "row'key" };
            ent.Properties.Add("stringprop", new EntityProperty("string'value"));
            currentTable.Execute(TableOperation.InsertOrReplace(ent));

            TableQuery<DynamicTableEntity> query = new TableQuery<DynamicTableEntity>().Where(TableQuery.CombineFilters(
                (TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, ent.PartitionKey)),
                TableOperators.And,
                (TableQuery.GenerateFilterCondition("stringprop", QueryComparisons.Equal, ent.Properties["stringprop"].StringValue))));

            foreach (DynamicTableEntity retrievedEntity in currentTable.ExecuteQuery(query))
            {
                Assert.IsNotNull(retrievedEntity);
                Assert.AreEqual(ent.PartitionKey, retrievedEntity.PartitionKey);
                Assert.AreEqual(ent.RowKey, retrievedEntity.RowKey);
                Assert.AreEqual(ent.Properties["stringprop"].StringValue, retrievedEntity.Properties["stringprop"].StringValue);
            }

            // Check the iqueryable way.
            IEnumerable<DynamicTableEntity> result = (from entity in currentTable.CreateQuery<DynamicTableEntity>()
                                                      where entity.PartitionKey == ent.PartitionKey && entity.Properties["stringprop"].StringValue == ent.Properties["stringprop"].StringValue
                                                      select entity);

            foreach (DynamicTableEntity retrievedEntity in result.ToList())
            {
                Assert.IsNotNull(retrievedEntity);
                Assert.AreEqual(ent.PartitionKey, retrievedEntity.PartitionKey);
                Assert.AreEqual(ent.RowKey, retrievedEntity.RowKey);
                Assert.AreEqual(ent.Properties["stringprop"].StringValue, retrievedEntity.Properties["stringprop"].StringValue);
            }

            ComplexEntity tableEntity = new ComplexEntity() { PartitionKey = "partition'key", RowKey = "row'key" };
            currentTable.Execute(TableOperation.InsertOrReplace(tableEntity));

            TableQuery<ComplexEntity> query2 = new TableQuery<ComplexEntity>().Where(TableQuery.CombineFilters(
                (TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, ent.PartitionKey)),
                TableOperators.And,
                (TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.Equal, ent.RowKey))));

            foreach (ComplexEntity retrievedComplexEntity in currentTable.ExecuteQuery(query2))
            {
                Assert.IsNotNull(retrievedComplexEntity);
                Assert.AreEqual(ent.PartitionKey, retrievedComplexEntity.PartitionKey);
                Assert.AreEqual(ent.RowKey, retrievedComplexEntity.RowKey);
                Assert.AreEqual(tableEntity.Int64, retrievedComplexEntity.Int64);
            }
        }