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_interface_does_not_expose_it()
        {
            var propertyInfo = FetcherInterface.GetProperty(_structuralProperty.Name, PermissiveBindingFlags);

            propertyInfo
            .Should().BeNull("Because you cannot independently fetch a complex type.");
        }
        public void It_exposes_an_Expand_Method()
        {
            var expandMethod = FetcherInterface.GetMethod("Expand");

            expandMethod.Should().NotBeNull("Because it allows executing the query.");

            expandMethod.IsPublic.Should().BeTrue("Because it allows executing the query.");

            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, "Because it returns a Task<IConcreteInterface> which" +
                         "allows callers to await a call to the server.");
        }
        public void The_Fetcher_interface_is_attributed_with_LowerCaseProperty()
        {
            var lowerCasePropertyType = typeof(LowerCasePropertyAttribute);

            FetcherInterface.Should().BeDecoratedWith <LowerCasePropertyAttribute>(
                "Because this is used to manage casing when interacting with ODataLib");
        }
 public void The_Fetcher_interface_exposes_a_readonly_CollectionInterface_property()
 {
     FetcherInterface.Should().HaveProperty(
         CSharpAccessModifiers.Public,
         null,
         _navTargetCollectionInterface,
         _navigationProperty.Name);
 }
Exemple #6
0
 public void The_Fetcher_interface_exposes_a_readonly_FetcherInterface_property_with_default_projection()
 {
     FetcherInterface.Should().HaveProperty(
         CSharpAccessModifiers.Public,
         null,
         NavTargetFetcherInterface,
         NavigationProperty.Name);
 }
 public void The_Fetcher_interface_exposes_the_method()
 {
     FetcherInterface.Should().HaveMethod(
         CSharpAccessModifiers.Public,
         _expectedReturnType,
         _expectedMethodName,
         GetMethodParameterTypes());
 }
 public void It_exposes_a_SaveChangesAsync_Method()
 {
     FetcherInterface.Should().HaveMethod(
         CSharpAccessModifiers.Public,
         typeof(Task),
         "SaveChangesAsync",
         new Type[] { typeof(bool), typeof(Microsoft.OData.Client.SaveChangesOptions) },
         "Because it allows saving changes made to an entity.");
 }
 public void It_exposes_a_DeleteAsync_Method()
 {
     FetcherInterface.Should().HaveMethod(
         CSharpAccessModifiers.Public,
         typeof(Task),
         "DeleteAsync",
         new Type[] { ConcreteInterface, typeof(bool) },
         "Because it allows deleting an entity.");
 }
 public void It_exposes_an_ExecuteAsync_Method()
 {
     FetcherInterface.Should().HaveMethod(
         CSharpAccessModifiers.Public,
         typeof(Task <>).MakeGenericType(ConcreteInterface),
         "ExecuteAsync",
         new Type[0],
         "Because it allows executing the query.");
 }
 public void It_exposes_a_SetAsync_Method()
 {
     FetcherInterface.Should().HaveMethod(
         CSharpAccessModifiers.Public,
         false,
         typeof(Task),
         "SetAsync",
         new System.Type[] { typeof(object), ConcreteInterface, typeof(bool) },
         "Because it allows creating new entities.");
 }
 public void It_exposes_a_DeleteLinkAsync_Method()
 {
     FetcherInterface.Should().HaveMethod(
         CSharpAccessModifiers.Public,
         false,
         typeof(Task),
         "DeleteLinkAsync",
         new System.Type[] { ConcreteInterface, typeof(bool) },
         "Because it allows deleting relationship between entities.");
 }
Exemple #13
0
        public void When_collection_valued_nav_prop_Then_Fetcher_interface_exposes_a_readonly_property_with_projected_CollectionInterface()
        {
            Init(true);

            FetcherInterface.Should().HaveProperty(
                CSharpAccessModifiers.Public,
                null,
                m_NavTargetCollectionInterface,
                NavigationProperty.Name);
        }
Exemple #14
0
        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_interface_does_not_expose_a_SaveChangesAsync_Method()
 {
     FetcherInterface.Should()
     .NotHaveMethod("SaveChangesAsync", "Because abstract Entities cannot be changed");
 }
 public void The_Fetcher_interface_does_not_expose_a_DeleteAsync_Method()
 {
     FetcherInterface.Should()
     .NotHaveMethod("DeleteAsync", "Because abstract Entities cannot be deleted");
 }
 public void The_Fetcher_interface_does_not_expose_an_Expand_Method()
 {
     FetcherInterface.Should()
     .NotHaveMethod("Expand", "Because abstract Entities cannot be queried");
 }
Exemple #18
0
 public void The_Fetcher_interface_implements_Base_Fetcher_interface()
 {
     FetcherInterface.Should().Implement(_baseFetcherInterface);
 }
 public void When_it_is_an_instance_property_then_the_Fetcher_interface_does_not_expose_it()
 {
     FetcherInterface.Should().NotHaveProperty(_structuralInstanceProperty.Name);
 }
Exemple #20
0
 public void The_Fetcher_interface_does_not_expose_the_method()
 {
     FetcherInterface.Should().NotHaveMethod(_expectedMethodName);
 }