public void The_Fetcher_class_does_not_expose_it() { var propertyInfo = FetcherType.GetProperty(_structuralProperty.Name, PermissiveBindingFlags); propertyInfo .Should().BeNull(); }
public void When_the_return_type_is_primitive_it_is_mapped_to_an_IEnumerable_of_DotNet_Primitives() { Init(model => model.Namespaces[0].Classes.First() .Methods.Add(Method = Any.OdcmMethod(m => { m.ReturnType = new OdcmPrimitiveType("Stream", OdcmNamespace.Edm); m.IsCollection = IsCollection; }))); _expectedReturnType = ReturnTypeGenerator(typeof(Microsoft.OData.Client.DataServiceStreamLink)); _expectedMethodName = Method.Name + "Async"; var methodInfos = new[] { FetcherInterface.GetMethod(_expectedMethodName), FetcherType.GetMethod(_expectedMethodName) }; foreach (var methodInfo in methodInfos) { methodInfo.ReturnType .Should().Be(_expectedReturnType); } }
public void The_fetcher_proxy_class_explicitly_implements_multiple_fetcher_interface_Expand_methods() { foreach (var projectionFetcherPair in m_projectionFetcherCollectionMap) { if (!projectionFetcherPair.Key.SupportsExpand()) { continue; } var fetcherInterface = projectionFetcherPair.Value.Item1; var expandMethod = FetcherType.GetInterfaceMap(fetcherInterface).TargetMethods.Single(m => m.Name.EndsWith("Expand")); expandMethod.Should().NotBeNull("Because it allows expanding"); expandMethod.GetGenericArguments().Count() .Should().Be(1); var genericArgType = expandMethod.GetGenericArguments()[0]; var expectedParamType = typeof(Expression <>).MakeGenericType(typeof(Func <,>).MakeGenericType(ConcreteInterface, genericArgType)); expandMethod.GetParameters().Count() .Should().Be(1); expandMethod.GetParameters()[0].ParameterType .Should().Be(expectedParamType); expandMethod.ReturnType .Should().Be(fetcherInterface); } }
public void The_Fetcher_class_exposes_a_readonly_CollectionInterface_property() { FetcherType.Should().HaveProperty( CSharpAccessModifiers.Public, null, _navTargetCollectionInterface, _navigationProperty.Name); }
public void The_Fetcher_class_exposes_a_readonly_Fetcher_Interface_property_with_default_projection() { FetcherType.Should().HaveProperty( CSharpAccessModifiers.Public, null, NavTargetFetcherInterface, NavigationProperty.Name); }
public void The_Fetcher_class_exposes_the_async_method() { FetcherType.Should().HaveMethod( CSharpAccessModifiers.Public, true, _expectedReturnType, _expectedMethodName, GetMethodParameterTypes()); }
public void When_collection_valued_nav_prop_Then_Fetcher_class_exposes_a_readonly_property_with_projected_CollectionInterface() { Init(true); FetcherType.Should().HaveProperty( CSharpAccessModifiers.Public, null, m_NavTargetCollectionInterface, NavigationProperty.Name); }
public void The_Fetcher_class_implements_a_new_async_ExecuteAsync_method() { FetcherType.Should().HaveMethod( CSharpAccessModifiers.Public, true, typeof(Task <>).MakeGenericType(ConcreteInterface), "ExecuteAsync", new System.Type[0], "Because it allows executing queries."); }
public void The_fetcher_proxy_class_implements_multiple_fetcher_interfaces() { foreach (var projectionFetcherPair in m_projectionFetcherCollectionMap) { var fetcherInterface = projectionFetcherPair.Value.Item1; FetcherType .Should() .Implement(fetcherInterface, "Because the implementation is internal and only accessible via the interface."); } }
public void When_the_return_type_is_primitive_it_is_mapped_to_a_DotNet_Primitive() { Init(model => model.Namespaces[0].Classes.First() .Methods.Add(_method = Any.OdcmMethod(m => m.ReturnType = new OdcmPrimitiveType("Stream", "Edm")))); _expectedReturnType = typeof(Task <>).MakeGenericType(typeof(Microsoft.OData.Client.DataServiceStreamLink)); _expectedMethodName = _method.Name + "Async"; var methodInfos = new[] { ConcreteInterface.GetMethod(_expectedMethodName), ConcreteType.GetMethod(_expectedMethodName), FetcherInterface.GetMethod(_expectedMethodName), FetcherType.GetMethod(_expectedMethodName) }; foreach (var methodInfo in methodInfos) { methodInfo.ReturnType .Should().Be(_expectedReturnType); } }
public void The_Fetcher_class_does_not_expose_a_SaveChangesAsync_Method() { FetcherType.Should() .NotHaveMethod("SaveChangesAsync", "Because abstract Entities cannot be changed"); }
public void The_Fetcher_class_does_not_expose_a_DeleteAsync_Method() { FetcherType.Should() .NotHaveMethod("DeleteAsync", "Because abstract Entities cannot be deleted"); }
public void The_Fetcher_class_does_not_expose_an_Expand_Method() { FetcherType.Should() .NotHaveMethod("Expand", "Because abstract Entities cannot be queried"); }
public void The_Fetcher_class_derives_from_Base_Fetcher_class() { FetcherType.Should().BeDerivedFrom(_baseFetcherType); }
public void The_fetcher_proxy_class_implements_the_Fetcher_Interface() { FetcherType.Should().Implement( FetcherInterface, "Because the implementaiton is internal and only accessible via the interface."); }
public void The_fetcher_proxy_class_inherits_from_RestShallowObjectFetcher() { FetcherType.Should().BeDerivedFrom( typeof(RestShallowObjectFetcher), "Because it manages access to the Uri to this logical entity relative to the query."); }
public void The_Collection_class_is_Internal() { FetcherType.IsInternal() .Should().BeTrue("Because entity types are accessed by the Concrete, Fetcher, " + "and Collection interfaces they implement."); }
public void When_it_is_an_instance_property_then_the_Fetcher_class_does_not_expose_it() { FetcherType.Should().NotHaveProperty(_structuralInstanceProperty.Name); }
public void The_Fetcher_class_does_not_expose_the_method() { FetcherType.Should().NotHaveMethod(_expectedMethodName); }