예제 #1
0
        public void Init(Action<OdcmModel> config)
        {
            base.Init(config);

            NavTargetConcreteType = Proxy.GetClass(NavTargetClass.Namespace, NavTargetClass.Name);

            NavTargetConcreteInterface = Proxy.GetInterface(NavTargetClass.Namespace, "I" + NavTargetClass.Name);

            NavTargetFetcherType = Proxy.GetClass(NavTargetClass.Namespace, NavTargetClass.Name + "Fetcher");

            NavTargetFetcherInterface = Proxy.GetInterface(NavTargetClass.Namespace,
                "I" + NavTargetClass.Name + "Fetcher");

            NavTargetCollectionType = Proxy.GetClass(NavTargetClass.Namespace, NavTargetClass.Name + "Collection");

            NavTargetCollectionInterface = Proxy.GetInterface(NavTargetClass.Namespace,
                "I" + NavTargetClass.Name + "Collection");

            NavTargetEntity = new EntityArtifacts()
            {
                Class = NavTargetClass,
                ConcreteType = NavTargetConcreteType,
                ConcreteInterface = NavTargetConcreteInterface,
                FetcherType = NavTargetFetcherType,
                FetcherInterface = NavTargetFetcherInterface,
                CollectionType = NavTargetCollectionType,
                CollectionInterface = NavTargetCollectionInterface
            };
        }
예제 #2
0
        public void Init(Action <OdcmModel> config)
        {
            base.Init(config);

            NavTargetConcreteType = Proxy.GetClass(NavTargetClass.Namespace, NavTargetClass.Name);

            NavTargetConcreteInterface = Proxy.GetInterface(NavTargetClass.Namespace, "I" + NavTargetClass.Name);

            NavTargetFetcherType = Proxy.GetClass(NavTargetClass.Namespace, NavTargetClass.Name + "Fetcher");

            NavTargetFetcherInterface = Proxy.GetInterface(NavTargetClass.Namespace,
                                                           "I" + NavTargetClass.Name + "Fetcher");

            NavTargetCollectionType = Proxy.GetClass(NavTargetClass.Namespace, NavTargetClass.Name + "Collection");

            NavTargetCollectionInterface = Proxy.GetInterface(NavTargetClass.Namespace,
                                                              "I" + NavTargetClass.Name + "Collection");

            NavTargetEntity = new EntityArtifacts()
            {
                Class               = NavTargetClass,
                ConcreteType        = NavTargetConcreteType,
                ConcreteInterface   = NavTargetConcreteInterface,
                FetcherType         = NavTargetFetcherType,
                FetcherInterface    = NavTargetFetcherInterface,
                CollectionType      = NavTargetCollectionType,
                CollectionInterface = NavTargetCollectionInterface
            };
        }
예제 #3
0
 public static MockService SetupGetEntityProperty(this MockService mockService, EntityArtifacts targetEntity, IEnumerable<Tuple<string, object>> keyValues, OdcmProperty property)
 {
     return mockService
         .OnGetEntityPropertyRequest(targetEntity.Class.GetDefaultEntityPath(keyValues), property.Name)
         .RespondWithGetEntity(targetEntity.Class.GetDefaultEntitySetName(),
             targetEntity.Class.GetSampleJObject());
 }
예제 #4
0
        public static MockService SetupPostEntity(this MockService mockService, EntityArtifacts targetEntity, IEnumerable <Tuple <string, object> > propertyValues = null)
        {
            propertyValues = propertyValues ?? targetEntity.Class.GetSampleKeyArguments();

            return(mockService
                   .OnPostEntityRequest(targetEntity.Class.GetDefaultEntitySetPath())
                   .RespondWithCreateEntity(targetEntity.Class.GetDefaultEntitySetName(), targetEntity.Class.GetSampleJObject(propertyValues)));
        }
예제 #5
0
        public static MockService SetupPostEntity(this MockService mockService, EntityArtifacts targetEntity, IEnumerable<Tuple<string, object>> propertyValues = null)
        {
            propertyValues = propertyValues ?? targetEntity.Class.GetSampleKeyArguments();

            return mockService
                .OnPostEntityRequest(targetEntity.Class.GetDefaultEntitySetPath())
                .RespondWithCreateEntity(targetEntity.Class.GetDefaultEntitySetName(), targetEntity.Class.GetSampleJObject(propertyValues));
        }
예제 #6
0
        public static MockService SetupGetEntitySet(this MockService mockService, EntityArtifacts targetEntity,
                                                    IEnumerable <string> expandTargets = null)
        {
            var responseBuilder = expandTargets == null
                ? mockService.OnGetEntityRequest(targetEntity.Class.GetDefaultEntitySetPath())
                : mockService.OnGetEntityWithExpandRequest(targetEntity.Class.GetDefaultEntitySetPath(), expandTargets);

            return(responseBuilder
                   .RespondWithGetEntity(targetEntity.Class.GetDefaultEntitySetName(),
                                         targetEntity.Class.GetSampleJObject(targetEntity.Class.GetSampleKeyArguments())));
        }
예제 #7
0
        public static MockService SetupGetEntitySet(this MockService mockService, EntityArtifacts targetEntity,
            IEnumerable<string> expandTargets = null)
        {
            var responseBuilder = expandTargets == null
                ? mockService.OnGetEntityRequest(targetEntity.Class.GetDefaultEntitySetPath())
                : mockService.OnGetEntityWithExpandRequest(targetEntity.Class.GetDefaultEntitySetPath(), expandTargets);

            return responseBuilder
                .RespondWithGetEntity(targetEntity.Class.GetDefaultEntitySetName(),
                    targetEntity.Class.GetSampleJObject(targetEntity.Class.GetSampleKeyArguments()));
        }
예제 #8
0
        public void Init(Action <OdcmModel> config = null, bool generateMocks = false)
        {
            Model = new OdcmModel(Any.ServiceMetadata());

            Namespace = Any.EmptyOdcmNamespace();

            Model.Namespaces.Add(Namespace);

            Class = Any.OdcmEntityClass(Namespace);

            Model.AddType(Class);

            OdcmContainer = Any.ServiceOdcmClass(Namespace);

            Model.AddType(OdcmContainer);

            if (config != null)
            {
                config(Model);
            }

            Model.ServiceMetadata["$metadata"] = Model.ToEdmx(true);

            Proxy = GetProxy(Model, ConfigurationProvider, generateMocks ? new[] { "DynamicProxyGenAssembly2" } : null);

            ConcreteType = Proxy.GetClass(Class.Namespace, Class.Name);

            ConcreteInterface = Proxy.GetInterface(Class.Namespace, "I" + Class.Name);

            FetcherType = Proxy.GetClass(Class.Namespace, Class.Name + "Fetcher");

            FetcherInterface = Proxy.GetInterface(Class.Namespace, "I" + Class.Name + "Fetcher");

            CollectionType = Proxy.GetClass(Class.Namespace, Class.Name + "Collection");

            CollectionInterface = Proxy.GetInterface(Class.Namespace, "I" + Class.Name + "Collection");

            EntityContainerType = Proxy.GetClass(Model.EntityContainer.Namespace, Model.EntityContainer.Name);

            EntityContainerInterface = Proxy.GetInterface(Model.EntityContainer.Namespace, "I" + Model.EntityContainer.Name);

            TargetEntity = new EntityArtifacts()
            {
                Class               = Class,
                ConcreteType        = ConcreteType,
                ConcreteInterface   = ConcreteInterface,
                FetcherType         = FetcherType,
                FetcherInterface    = FetcherInterface,
                CollectionType      = CollectionType,
                CollectionInterface = CollectionInterface
            };
        }
예제 #9
0
        public void Init(Action<OdcmModel> config = null, bool generateMocks = false)
        {
            Model = new OdcmModel(Any.ServiceMetadata());

            Namespace = Any.EmptyOdcmNamespace();

            Model.Namespaces.Add(Namespace);

            Class = Any.OdcmEntityClass(Namespace);

            Model.AddType(Class);

            OdcmContainer = Any.ServiceOdcmClass(Namespace);

            Model.AddType(OdcmContainer);

            if (config != null) config(Model);

            Model.ServiceMetadata["$metadata"] = Model.ToEdmx(true);

            Proxy = GetProxy(Model, ConfigurationProvider, generateMocks ? new[] { "DynamicProxyGenAssembly2" } : null);

            ConcreteType = Proxy.GetClass(Class.Namespace, Class.Name);

            ConcreteInterface = Proxy.GetInterface(Class.Namespace, "I" + Class.Name);

            FetcherType = Proxy.GetClass(Class.Namespace, Class.Name + "Fetcher");

            FetcherInterface = Proxy.GetInterface(Class.Namespace, "I" + Class.Name + "Fetcher");

            CollectionType = Proxy.GetClass(Class.Namespace, Class.Name + "Collection");

            CollectionInterface = Proxy.GetInterface(Class.Namespace, "I" + Class.Name + "Collection");

            EntityContainerType = Proxy.GetClass(Model.EntityContainer.Namespace, Model.EntityContainer.Name);

            EntityContainerInterface = Proxy.GetInterface(Model.EntityContainer.Namespace, "I" + Model.EntityContainer.Name);

            TargetEntity = new EntityArtifacts()
            {
                Class = Class,
                ConcreteType = ConcreteType,
                ConcreteInterface = ConcreteInterface,
                FetcherType = FetcherType,
                FetcherInterface = FetcherInterface,
                CollectionType = CollectionType,
                CollectionInterface = CollectionInterface
            };
        }
예제 #10
0
        public static EntityArtifacts GetArtifactsFrom(this OdcmEntityClass Class, Assembly Proxy)
        {
            var retVal = new EntityArtifacts
            {
                Class               = Class,
                ConcreteType        = Proxy.GetClass(Class.Namespace, Class.Name),
                ConcreteInterface   = Proxy.GetInterface(Class.Namespace, "I" + Class.Name),
                FetcherType         = Proxy.GetClass(Class.Namespace, Class.Name + "Fetcher"),
                FetcherInterface    = Proxy.GetInterface(Class.Namespace, "I" + Class.Name + "Fetcher"),
                CollectionType      = Proxy.GetClass(Class.Namespace, Class.Name + "Collection"),
                CollectionInterface = Proxy.GetInterface(Class.Namespace, "I" + Class.Name + "Collection")
            };

            return(retVal);
        }
예제 #11
0
        public static MockService SetupGetEntity(this MockService mockService, EntityArtifacts targetEntity, 
            IEnumerable<Tuple<string, object>> keyValues = null, IEnumerable<string> expandTargets = null)
        {
            keyValues = keyValues ?? targetEntity.Class.GetSampleKeyArguments();

            keyValues = keyValues.ToList();

            var responseBuilder = expandTargets == null
                ? mockService.OnGetEntityRequest(targetEntity.Class.GetDefaultEntityPath(keyValues))
                : mockService.OnGetEntityWithExpandRequest(targetEntity.Class.GetDefaultEntityPath(keyValues),
                    expandTargets);

            return responseBuilder
                .RespondWithGetEntity(targetEntity.Class.GetDefaultEntitySetName(),
                    targetEntity.Class.GetSampleJObject(keyValues));
        }
예제 #12
0
        public static void ValidateParameterPassing(this MockService mockService, string httpMethod, object instance, string instancePath, OdcmMethod method, string serverMethodName, EntityArtifacts entityArtifacts)
        {
            var expectedMethodName = method.Name + "Async";

            var methodArguments = method.GetSampleArguments().ToArray();
            var uriArguments    = method.UriParameters()
                                  .Select(p => methodArguments.First(a => a.Item1 == p.Name));
            var bodyArguments = method.BodyParameters()
                                .Select(p => methodArguments.First(a => a.Item1 == p.Name));

            var responseBuilder = mockService
                                  .OnInvokeMethodRequest(httpMethod,
                                                         instancePath + "/" + serverMethodName,
                                                         uriArguments.ToTestReadableStringCollection(),
                                                         ArgumentOfTupleExtensions.ToJObject(bodyArguments));

            if (entityArtifacts == null)
            {
                responseBuilder.RespondWith(r => r.Response.StatusCode = 200);
            }
            else
            {
                responseBuilder.RespondWithGetEntity(entityArtifacts.Class.GetDefaultEntitySetName(),
                                                     entityArtifacts.Class.GetSampleJObject());
            }

            instance.InvokeMethod <Task>(expectedMethodName, methodArguments.Select(t => t.Item2).ToArray())
            .Wait();
        }
예제 #13
0
 public static MockService SetupGetEntityProperty(this MockService mockService, EntityArtifacts targetEntity, IEnumerable <Tuple <string, object> > keyValues, OdcmProperty property)
 {
     return(mockService
            .OnGetEntityPropertyRequest(targetEntity.Class.GetDefaultEntityPath(keyValues), property.Name)
            .RespondWithGetEntity(targetEntity.Class.GetDefaultEntitySetName(),
                                  targetEntity.Class.GetSampleJObject()));
 }
예제 #14
0
        public static EntityArtifacts GetArtifactsFrom(this OdcmEntityClass Class, Assembly Proxy)
        {
            var retVal = new EntityArtifacts
            {
                Class = Class,
                ConcreteType = Proxy.GetClass(Class.Namespace, Class.Name),
                ConcreteInterface = Proxy.GetInterface(Class.Namespace, "I" + Class.Name),
                FetcherType = Proxy.GetClass(Class.Namespace, Class.Name + "Fetcher"),
                FetcherInterface = Proxy.GetInterface(Class.Namespace, "I" + Class.Name + "Fetcher"),
                CollectionType = Proxy.GetClass(Class.Namespace, Class.Name + "Collection"),
                CollectionInterface = Proxy.GetInterface(Class.Namespace, "I" + Class.Name + "Collection")
            };

            return retVal;
        }
예제 #15
0
        public static void ValidateParameterPassing(this MockService mockService, string httpMethod, object instance, string instancePath, OdcmMethod method, string serverMethodName, EntityArtifacts entityArtifacts)
        {
            var expectedMethodName = method.Name + "Async";

            var methodArguments = method.GetSampleArguments().ToArray();
            var uriArguments = method.UriParameters()
                .Select(p => methodArguments.First(a => a.Item1 == p.Name));
            var bodyArguments = method.BodyParameters()
                .Select(p => methodArguments.First(a => a.Item1 == p.Name));

            var responseBuilder = mockService
                .OnInvokeMethodRequest(httpMethod,
                    instancePath + "/" + serverMethodName,
                    uriArguments.ToTestReadableStringCollection(),
                    ArgumentOfTupleExtensions.ToJObject(bodyArguments));

            if (entityArtifacts == null)
                responseBuilder.RespondWith(r => r.Response.StatusCode = 200);
            else
                responseBuilder.RespondWithGetEntity(entityArtifacts.Class.GetDefaultEntitySetName(),
                    entityArtifacts.Class.GetSampleJObject());

            instance.InvokeMethod<Task>(expectedMethodName, methodArguments.Select(t => t.Item2).ToArray())
                .Wait();
        }
예제 #16
0
 public static MockService SetupPostEntityPropertyChanges(this MockService mockService, EntityArtifacts targetEntity, IEnumerable <Tuple <string, object> > keyValues, OdcmProperty property)
 {
     return(mockService
            .OnPostEntityRequest(targetEntity.Class.GetDefaultEntityPropertyPath(property, keyValues))
            .RespondWithODataOk());
 }
예제 #17
0
 public static MockService SetupPostEntityPropertyChanges(this MockService mockService, EntityArtifacts targetEntity, IEnumerable<Tuple<string, object>> keyValues, OdcmProperty property)
 {
     return mockService
         .OnPostEntityRequest(targetEntity.Class.GetDefaultEntityPropertyPath(property, keyValues))
         .RespondWithODataOk();
 }