Exemplo n.º 1
0
        public Property GetProperty <T>(string name)
        {
            EntityType entityTypes = Assertions.Contains(typeof(T).FullName, (IDictionary <string, EntityType>)ReflectionHelper.GetField(Model, "_entityTypes"));
            IDictionary <string, Property> properties = (IDictionary <string, Property>)ReflectionHelper.GetField(entityTypes, "_properties");

            return(Assertions.Contains(name, properties));
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Get index for specified entity and property.
        /// </summary>
        /// <typeparam name="T">entity</typeparam>
        /// <param name="propertyNames">property</param>
        /// <returns></returns>
        public Index GetIndex <T>(params string[] propertyNames)
        {
            EntityType entityType = Assertions.Contains(typeof(T).FullName, (IDictionary <string, EntityType>)ReflectionHelper.GetField(Model, "_entityTypes"));
            IDictionary <IReadOnlyList <IProperty>, Index>  indexes = (IDictionary <IReadOnlyList <IProperty>, Index>)ReflectionHelper.GetField(entityType, "_indexes");
            KeyValuePair <IReadOnlyList <IProperty>, Index> index   = indexes.FirstOrDefault(x => x.Key.Select(y => y.Name).SequenceEqual(propertyNames));

            Assertions.NotNull(index.Value);
            return(index.Value);
        }
Exemplo n.º 3
0
 public void ContainsMustThrowExceptionWhenCollectionDoesNotContainExpectedValue()
 {
     Assert.Equal("Collection does not contain expected value.", Assert.Throws <ArgumentException>(() => Assertions.Contains("42", new Dictionary <string, string> {
         { "41", "Alice" }
     })).Message);
 }
Exemplo n.º 4
0
 public void ContainsMustReturnExpectedValueWhenCollectionContainsExpectedValue()
 {
     Assert.Equal("Bob", Assertions.Contains("42", new Dictionary <string, string> {
         { "41", "Alice" }, { "42", "Bob" }
     }));
 }