public async Task TableRetrieveWithIgnoreAttributeReadAsync() { CloudTableClient tableClient = GenerateCloudTableClient(); string pk = Guid.NewGuid().ToString(); // Add insert DynamicTableEntity sendEnt = new DynamicTableEntity(); sendEnt.Properties.Add("foo", new EntityProperty("bar")); sendEnt.Properties.Add("Bool", new EntityProperty(true)); sendEnt.Properties.Add("BoolN", new EntityProperty(true)); sendEnt.Properties.Add("BoolNull", new EntityProperty(true)); sendEnt.Properties.Add("BoolPrimitive", new EntityProperty(true)); sendEnt.Properties.Add("BoolPrimitiveN", new EntityProperty(true)); sendEnt.Properties.Add("BoolPrimitiveNull", new EntityProperty(true)); sendEnt.Properties.Add("DateTime", new EntityProperty(DateTime.UtcNow.AddMinutes(1))); sendEnt.Properties.Add("DateTimeN", new EntityProperty(DateTime.UtcNow.AddMinutes(1))); sendEnt.Properties.Add("DateTimeNull", new EntityProperty(DateTime.UtcNow.AddMinutes(1))); sendEnt.Properties.Add("DateTimeOffset", new EntityProperty(DateTimeOffset.Now.AddMinutes(1))); sendEnt.Properties.Add("DateTimeOffsetN", new EntityProperty(DateTimeOffset.Now.AddMinutes(1))); sendEnt.Properties.Add("DateTimeOffsetNull", new EntityProperty(DateTimeOffset.Now.AddMinutes(1))); sendEnt.PartitionKey = pk; sendEnt.RowKey = Guid.NewGuid().ToString(); // insert entity await currentTable.ExecuteAsync(TableOperation.Insert(sendEnt)); TableQuery <IgnoreEntity> query = new TableQuery <IgnoreEntity>().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, pk)); IEnumerable <IgnoreEntity> result = await currentTable.ExecuteQuerySegmentedAsync(query, null); IgnoreEntity retrievedEntity = result.ToList().First() as IgnoreEntity; Assert.AreEqual(sendEnt.Properties["BoolPrimitive"].BooleanValue, retrievedEntity.BoolPrimitive); Assert.AreEqual(sendEnt.Properties["BoolPrimitiveN"].BooleanValue, retrievedEntity.BoolPrimitiveN); Assert.AreNotEqual(sendEnt.Properties["BoolPrimitiveNull"].BooleanValue, retrievedEntity.BoolPrimitiveNull); Assert.AreNotEqual(sendEnt.Properties["Bool"].BooleanValue, retrievedEntity.Bool); Assert.AreEqual(sendEnt.Properties["BoolN"].BooleanValue, retrievedEntity.BoolN); Assert.AreEqual(sendEnt.Properties["BoolNull"].BooleanValue, retrievedEntity.BoolNull); Assert.AreNotEqual(sendEnt.Properties["DateTimeOffset"].DateTimeOffsetValue, retrievedEntity.DateTimeOffset); Assert.AreEqual(sendEnt.Properties["DateTimeOffsetN"].DateTimeOffsetValue, retrievedEntity.DateTimeOffsetN); Assert.AreNotEqual(sendEnt.Properties["DateTimeOffsetNull"].DateTimeOffsetValue, retrievedEntity.DateTimeOffsetNull); Assert.IsNull(retrievedEntity.DateTimeOffsetNull); Assert.AreEqual(sendEnt.Properties["DateTime"].DateTime, retrievedEntity.DateTime); Assert.AreEqual(sendEnt.Properties["DateTimeN"].DateTime, retrievedEntity.DateTimeN); Assert.AreEqual(sendEnt.Properties["DateTimeNull"].DateTime, retrievedEntity.DateTimeNull); }
public async Task TableRetrieveSyncWithIgnoreAttributesAsync() { string pk = Guid.NewGuid().ToString(); string rk = Guid.NewGuid().ToString(); IgnoreEntity sendEnt = new IgnoreEntity(pk, rk); sendEnt.Bool = true; sendEnt.BoolN = true; sendEnt.BoolNull = null; sendEnt.BoolPrimitive = true; sendEnt.BoolPrimitiveN = true; sendEnt.BoolPrimitiveNull = true; 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 = DateTimeOffset.Now.AddMinutes(1); await currentTable.ExecuteAsync(TableOperation.Insert(sendEnt)); TableQuery <IgnoreEntity> query = new TableQuery <IgnoreEntity>().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, pk)); IEnumerable <IgnoreEntity> result = await currentTable.ExecuteQuerySegmentedAsync(query, null); IgnoreEntity retrievedEntity = result.ToList().First() as IgnoreEntity; Assert.AreEqual(sendEnt.BoolPrimitive, retrievedEntity.BoolPrimitive); Assert.AreEqual(sendEnt.BoolPrimitiveN, retrievedEntity.BoolPrimitiveN); Assert.AreNotEqual(sendEnt.BoolPrimitiveNull, retrievedEntity.BoolPrimitiveNull); Assert.AreNotEqual(sendEnt.Bool, retrievedEntity.Bool); Assert.AreEqual(sendEnt.BoolN, retrievedEntity.BoolN); Assert.AreEqual(sendEnt.BoolNull, retrievedEntity.BoolNull); Assert.AreNotEqual(sendEnt.DateTimeOffset, retrievedEntity.DateTimeOffset); Assert.AreEqual(sendEnt.DateTimeOffsetN, retrievedEntity.DateTimeOffsetN); Assert.AreNotEqual(sendEnt.DateTimeOffsetNull, retrievedEntity.DateTimeOffsetNull); Assert.IsNull(retrievedEntity.DateTimeOffsetNull); Assert.AreEqual(sendEnt.DateTime, retrievedEntity.DateTime); Assert.AreEqual(sendEnt.DateTimeN, retrievedEntity.DateTimeN); Assert.AreEqual(sendEnt.DateTimeNull, retrievedEntity.DateTimeNull); }
public async Task TableRetrieveWithIgnoreAttributeWriteAsync() { string pk = Guid.NewGuid().ToString(); string rk = Guid.NewGuid().ToString(); IgnoreEntity sendEnt = new IgnoreEntity(pk, rk); sendEnt.Bool = true; sendEnt.BoolN = true; sendEnt.BoolNull = null; sendEnt.BoolPrimitive = true; sendEnt.BoolPrimitiveN = true; sendEnt.BoolPrimitiveNull = true; 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 = DateTimeOffset.Now.AddMinutes(1); await currentTable.ExecuteAsync(TableOperation.Insert(sendEnt)); TableResult result = await currentTable.ExecuteAsync(TableOperation.Retrieve(sendEnt.PartitionKey, sendEnt.RowKey)); DynamicTableEntity retrievedEntity = result.Result as DynamicTableEntity; Assert.IsFalse(retrievedEntity.Properties.ContainsKey("BoolPrimitiveNull")); Assert.IsFalse(retrievedEntity.Properties.ContainsKey("Bool")); Assert.AreEqual(sendEnt.BoolPrimitive, retrievedEntity.Properties["BoolPrimitive"].BooleanValue); Assert.AreEqual(sendEnt.BoolPrimitiveN, retrievedEntity.Properties["BoolPrimitiveN"].BooleanValue); Assert.AreEqual(sendEnt.BoolN, retrievedEntity.Properties["BoolN"].BooleanValue); Assert.IsFalse(retrievedEntity.Properties.ContainsKey("DateTimeOffset")); Assert.IsFalse(retrievedEntity.Properties.ContainsKey("DateTimeOffsetNull")); Assert.AreEqual(sendEnt.DateTimeOffsetN, retrievedEntity.Properties["DateTimeOffsetN"].DateTimeOffsetValue); Assert.AreEqual(sendEnt.DateTime, retrievedEntity.Properties["DateTime"].DateTime); Assert.AreEqual(sendEnt.DateTimeN, retrievedEntity.Properties["DateTimeN"].DateTime); }