public void The_Concrete_parses_the_response() { Init(m => { m.Verbs = OdcmAllowedVerbs.Get; m.Parameters.Clear(); }); var entityKeyValues = Class.GetSampleKeyArguments().ToArray(); var instancePath = Class.GetDefaultEntityPath(entityKeyValues); var responseKeyValues = Class.GetSampleKeyArguments().ToArray(); var response = Class.GetSampleJObject(responseKeyValues); using (var mockService = new MockService() .SetupPostEntity(TargetEntity, entityKeyValues)) { mockService .OnInvokeMethodRequest("GET", instancePath + "/" + ServerMethodNameGenerator(), null, null) .RespondWithGetEntity(TargetEntity.Class.GetDefaultEntitySetName(), response); var concrete = mockService .GetDefaultContext(Model) .CreateConcrete(ConcreteType); var result = concrete.InvokeMethod<Task>(Method.Name + "Async").GetPropertyValue<EntityBase>("Result"); result.ValidatePropertyValues(responseKeyValues); } }
private void ValidateCollectionResponseParsing( Func<MockService, EntityArtifacts, Tuple<string, object>> instanceGenerator) { Init(m => { m.Verbs = OdcmAllowedVerbs.Get; m.Parameters.Clear(); }); var responseKeyValues = Class.GetSampleKeyArguments().ToArray(); var response = Class.GetSampleJObject(responseKeyValues); using (var mockService = new MockService()) { var instanceAndPath = instanceGenerator(mockService, TargetEntity); mockService .OnInvokeMethodRequest("GET", instanceAndPath.Item1 + "/" + ServerMethodNameGenerator(), null, null) .RespondWithGetEntity(TargetEntity.Class.GetDefaultEntitySetName(), response); var instance = instanceAndPath.Item2; var result = instance.InvokeMethod<Task>(Method.Name + "Async").GetPropertyValue<IEnumerable<EntityBase>>("Result"); result.ValidateCollectionPropertyValues(new List<IEnumerable<Tuple<string, object>>> { responseKeyValues.ToList() }); } }
public void The_Service_parses_the_response() { var responseKeyValues = Class.GetSampleKeyArguments().ToArray(); var response = Class.GetSampleJObject(responseKeyValues); using (var mockService = new MockService()) { mockService .OnInvokeMethodRequest("GET", "/" + ServerMethodNameGenerator(), null, null) .RespondWithGetEntity(TargetEntity.Class.GetDefaultEntitySetName(), response); var service = mockService .CreateContainer(EntityContainerType, Any.TokenGetterFunction()); var result = service.InvokeMethod<Task>(Method.Name + "Async").GetPropertyValue<EntityBase>("Result"); result.ValidatePropertyValues(responseKeyValues); } }