public void EnsureTableExistsIsCalledForEachSet() { MockTableEntityContext entityContext = new MockTableEntityContext(); Assert.IsFalse(entityContext.EnsureTableExistsCounts.ContainsKey("MockEntity1"), "There should not have been any calls to ensure MockEntity1 exists."); Assert.IsFalse(entityContext.EnsureTableExistsCounts.ContainsKey("MockEntity2"), "There should not have been any calls to ensure MockEntity2 exists."); Assert.AreEqual(1, entityContext.EnsureTableExistsCounts["MockEntity3"], "There should have been one call to ensure MockEntity3 exists."); Assert.IsNotNull(entityContext.MockEntities1, "The MockEntity1 set should not be null."); Assert.IsNotNull(entityContext.MockEntities2, "The MockEntity2 set should not be null."); Assert.IsNotNull(entityContext.MockEntities3, "The MockEntity3 set should not be null."); Assert.AreEqual(1, entityContext.EnsureTableExistsCounts["MockEntity1"], "There should have been one call to ensure MockEntity1 exists."); Assert.AreEqual(1, entityContext.EnsureTableExistsCounts["MockEntity2"], "There should have been one call to ensure MockEntity2 exists."); Assert.AreEqual(1, entityContext.EnsureTableExistsCounts["MockEntity3"], "There should still have been one call to ensure MockEntity3 exists."); }
public void GetEntitySetCallsCreateEntitySetOnce() { MockTableEntityContext entityContext = new MockTableEntityContext(); Assert.IsFalse(entityContext.CreateEntitySetCounts.ContainsKey(typeof(MockEntity1)), "There should not have been any calls to create a MockEntity1 entity set."); Assert.IsFalse(entityContext.CreateEntitySetCounts.ContainsKey(typeof(MockEntity2)), "There should not have been any calls to create a MockEntity2 entity set."); Assert.IsNotNull(entityContext.MockEntities1, "The MockEntity1 set should not be null."); Assert.IsNotNull(entityContext.MockEntities2, "The MockEntity2 set should not be null."); Assert.AreEqual(1, entityContext.CreateEntitySetCounts[typeof(MockEntity1)], "CreateEntitySet should have been called once for MockEntity1."); Assert.AreEqual(1, entityContext.CreateEntitySetCounts[typeof(MockEntity2)], "CreateEntitySet should have been called once for MockEntity2."); Assert.IsNotNull(entityContext.MockEntities1, "The MockEntity1 set should still not be null."); Assert.IsNotNull(entityContext.MockEntities2, "The MockEntity2 set should still not be null."); Assert.AreEqual(1, entityContext.CreateEntitySetCounts[typeof(MockEntity1)], "CreateEntitySet should still have been called once for MockEntity1."); Assert.AreEqual(1, entityContext.CreateEntitySetCounts[typeof(MockEntity2)], "CreateEntitySet should still have been called once for MockEntity2."); }
public void PartitionKey() { MockTableEntityContext entityContext = new MockTableEntityContext(); Assert.IsNull(entityContext.PartitionKey, "The PartitionKey should be null by default."); Assert.IsNull(entityContext.MockEntities1.PartitionKey, "The first TableEntitySet PartitionKey should be null by default."); Assert.IsNull(entityContext.MockEntities2.PartitionKey, "The second TableEntitySet PartitionKey should be null by default."); string partitionKey = "PK"; entityContext.PartitionKey = partitionKey; Assert.AreEqual(partitionKey, entityContext.PartitionKey, "The PartitionKeys should be equal."); Assert.AreEqual(entityContext.PartitionKey, entityContext.MockEntities1.PartitionKey, "The first TableEntitySet PartitionKey should be equal to the context PartitionKey."); Assert.AreEqual(entityContext.PartitionKey, entityContext.MockEntities2.PartitionKey, "The second TableEntitySet PartitionKey should be equal to the context PartitionKey."); entityContext.PartitionKey = null; Assert.IsNull(entityContext.PartitionKey, "The PartitionKey should be null again."); Assert.IsNull(entityContext.MockEntities1.PartitionKey, "The first TableEntitySet PartitionKey should be null again."); Assert.IsNull(entityContext.MockEntities2.PartitionKey, "The second TableEntitySet PartitionKey should be null again."); }
public void GetEntitySetDoesNotCreateWhenSetExists() { MockTableEntityContext entityContext = new MockTableEntityContext(); Assert.IsFalse(entityContext.CreateEntitySetCounts.ContainsKey(typeof(MockEntity3)), "There should not have been any calls to create a MockEntity3 entity set."); Assert.AreEqual(entityContext.MockEntity3EntitySet, entityContext.MockEntities3, "The MockEntity3 set should equal the preset member."); Assert.IsFalse(entityContext.CreateEntitySetCounts.ContainsKey(typeof(MockEntity3)), "There should still not have been any calls to create a MockEntity3 entity set."); }
public void ResolveEntityTypes() { MockTableEntityContext entityContext = new MockTableEntityContext(); Assert.IsNotNull(entityContext.MockEntities1, "The MockEntity1 set should not be null."); Assert.IsNotNull(entityContext.MockEntities2, "The MockEntity2 set should not be null."); Assert.IsNotNull(entityContext.MockEntities3, "The MockEntity3 set should not be null."); Assert.AreEqual(typeof(MockEntity1), entityContext.ResolveType(entityContext.StorageCredentials.AccountName + "." + entityContext.MockEntities1.TableName), "The type for MockEntities1 should be MockEntity1."); Assert.AreEqual(typeof(MockEntity2), entityContext.ResolveType(entityContext.StorageCredentials.AccountName + "." + entityContext.MockEntities2.TableName), "The type for MockEntities2 should be MockEntity2."); Assert.AreEqual(typeof(MockEntity3), entityContext.ResolveType(entityContext.StorageCredentials.AccountName + "." + entityContext.MockEntities3.TableName), "The type for MockEntities3 should be MockEntity3."); Assert.AreEqual(1, entityContext.ResolveEntityTypeCounts["MockEntity1"], "There should have been one call to resolve MockEntity1."); Assert.AreEqual(1, entityContext.ResolveEntityTypeCounts["MockEntity2"], "There should have been one call to resolve MockEntity2."); Assert.AreEqual(1, entityContext.ResolveEntityTypeCounts["MockEntity3"], "There should have been one call to resolve MockEntity3."); Assert.AreEqual(typeof(MockEntity1), entityContext.ResolveType(entityContext.StorageCredentials.AccountName + "." + entityContext.MockEntities1.TableName), "The type for MockEntities1 should be MockEntity1."); Assert.AreEqual(typeof(MockEntity2), entityContext.ResolveType(entityContext.StorageCredentials.AccountName + "." + entityContext.MockEntities2.TableName), "The type for MockEntities2 should be MockEntity2."); Assert.AreEqual(typeof(MockEntity3), entityContext.ResolveType(entityContext.StorageCredentials.AccountName + "." + entityContext.MockEntities3.TableName), "The type for MockEntities3 should be MockEntity3."); Assert.AreEqual(1, entityContext.ResolveEntityTypeCounts["MockEntity1"], "There should only have been one call to resolve MockEntity1."); Assert.AreEqual(1, entityContext.ResolveEntityTypeCounts["MockEntity2"], "There should only have been one call to resolve MockEntity2."); Assert.AreEqual(1, entityContext.ResolveEntityTypeCounts["MockEntity3"], "There should only have been one call to resolve MockEntity3."); }