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 }; }
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 }; }
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()); }
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))); }
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)); }
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()))); }
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())); }
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 }; }
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 }; }
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); }
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)); }
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(); }
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())); }
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; }
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(); }
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()); }
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(); }