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[] { 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_Concrete_interface_exposes_a_readonly_IPagedCollectionOfConcreteInterface_property() { ConcreteInterface.Should().HaveProperty( CSharpAccessModifiers.Public, null, typeof(IPagedCollection <>).MakeGenericType(_navTargetConcreteInterface), _navigationProperty.Name); }
public void The_Concrete_interface_exposes_the_method() { ConcreteInterface.Should().HaveMethod( CSharpAccessModifiers.Public, _expectedReturnType, _expectedMethodName, GetMethodParameterTypes()); }
public void The_Concrete_interface_exposes_a_ConcreteInterface_property() { ConcreteInterface.Should().HaveProperty( CSharpAccessModifiers.Public, CSharpAccessModifiers.Public, NavTargetConcreteInterface, NavigationProperty.Name); }
public void When_it_is_a_collection_property_then_the_Concrete_interface_exposes_an_IList_of_instance_property() { ConcreteInterface.Should().HaveProperty( CSharpAccessModifiers.Public, CSharpAccessModifiers.Public, typeof(IList <>).MakeGenericType(EdmToClrTypeMap[_structuralInstanceProperty.Type.Name]), _structuralCollectionProperty.Name); }
public void When_it_is_an_instance_property_then_the_Concrete_interface_exposes_an_instance_property() { ConcreteInterface.Should().HaveProperty( CSharpAccessModifiers.Public, CSharpAccessModifiers.Public, EdmToClrTypeMap[_structuralInstanceProperty.Type.Name], _structuralInstanceProperty.Name); }
public void CanBindToInstance() { var obj = new ConcreteInterface(); var binding1 = new Binding <Interface, ConcreteInterface>(obj); var resolvedObj = binding1.Resolve(null, null); Assert.NotNull(resolvedObj); Assert.NotNull(obj); }
public void InstancedBindingResolvesSameObject() { var obj = new ConcreteInterface(); var binding1 = new Binding <Interface, ConcreteInterface>(obj); var resolvedObj1 = binding1.Resolve(null, null); var resolvedObj2 = binding1.Resolve(null, null); Assert.NotNull(resolvedObj1); Assert.NotNull(resolvedObj2); Assert.AreEqual(obj, resolvedObj2); Assert.AreEqual(obj, resolvedObj2); Assert.AreEqual(resolvedObj1, resolvedObj2); }
public void BindingsGivenTheSameInstanceResolveToTheSameObject() { var instance = new ConcreteInterface(); var container = new ExtraContainer1(); container.Bind <Interface, ConcreteInterface>("Binding1", instance); container.Bind <Interface, ConcreteInterface>("Binding2", instance); var interface1 = container.Resolve <Interface>("Binding1"); var interface2 = container.Resolve <Interface>("Binding2"); Assert.NotNull(interface1); Assert.NotNull(interface2); Assert.AreEqual(interface1, interface2); }
public void CanResolveInheritedInstanced() { var obj = new ConcreteInterface(); _container.Bind <Interface, ConcreteInterface>("Instanced", obj).AsTransient(); var resolved = _container.Resolve <Interface>("Instanced"); var nonInstanced = _container.Resolve <Interface>(); Assert.NotNull(obj); Assert.NotNull(resolved); Assert.AreEqual(typeof(ConcreteInterface), obj.GetType()); Assert.AreEqual(typeof(ConcreteInterface), resolved.GetType()); Assert.AreEqual(obj.GetHashCode(), resolved.GetHashCode()); Assert.AreNotEqual(obj, nonInstanced); }
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_concrete_proxy_interface_implements_IEntityBase() { ConcreteInterface.Should() .Implement(typeof(IEntityBase), "Because it gives access to entity operations like Update and Delete."); }
public void It_is_decorated_with_LowerCasePropertyAttribute() { ConcreteInterface.Should() .BeDecoratedWith <LowerCasePropertyAttribute>(); }
public void The_Concrete_interface_does_not_expose_the_method() { ConcreteInterface.Should().NotHaveMethod(_expectedMethodName); }