Ejemplo n.º 1
0
        public void UnifyingSerializationHelpers_Roundtrip_WithEnums()
        {
            var metadata = new MetadataMock();
            var uri1     = new Uri("test://id/1");
            var uri2     = new Uri("test://id/2");

            metadata.Observables.Add(uri1, new MockObservable <EntityEnum>(uri1));
            metadata.Observables.Add(uri2, new MockObservable <TypeWithEnum>(uri2));

            Expression <Func <IAsyncReactiveQbservable <EntityEnum>, IAsyncReactiveQbservable <TypeWithEnum>, IAsyncReactiveQbservable <TypeWithEnum> > > f = (io1, io2) => Concat(Select(io1, x => new TypeWithEnum {
                Enum = x
            }), io2);
            var invoked = BetaReducer.Reduce(
                Expression.Invoke(
                    f,
                    Expression.Parameter(typeof(IAsyncReactiveQbservable <EntityEnum>), uri1.ToCanonicalString()),
                    Expression.Parameter(typeof(IAsyncReactiveQbservable <TypeWithEnum>), uri2.ToCanonicalString())));
            var normalized = new ReactiveExpressionServices(typeof(object)).Normalize(invoked);

            var clientSerializer  = new ClientSerializationHelpers();
            var serviceSerializer = new UnifyingSerializationHelpers(metadata);
            var bonsai            = clientSerializer.Serialize(normalized);
            var roundtrip         = serviceSerializer.Deserialize <Expression>(bonsai);

            Assert.AreEqual(typeof(IAsyncReactiveQbservable <TypeWithEnum>), roundtrip.Type);
        }
 public void ReactiveExpressionServices_ArgumentChecking()
 {
     var expression = default(Expression);
     var uri = default(Uri);
     var expressionServices = new ReactiveExpressionServices(typeof(ITestClient));
     Assert.ThrowsException<ArgumentNullException>(() => expressionServices.RegisterObject(null, Expression.Default(typeof(int))));
     Assert.ThrowsException<ArgumentNullException>(() => expressionServices.RegisterObject("foo", null));
     Assert.ThrowsException<ArgumentNullException>(() => expressionServices.TryGetObject(null, out expression));
     Assert.ThrowsException<ArgumentNullException>(() => expressionServices.Normalize(null));
     Assert.ThrowsException<ArgumentNullException>(() => expressionServices.GetNamedExpression(null, new Uri("eg:/foo")));
     Assert.ThrowsException<ArgumentNullException>(() => expressionServices.GetNamedExpression(typeof(int), null));
     Assert.ThrowsException<ArgumentNullException>(() => expressionServices.TryGetName(null, out uri));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a new reactive metadata service proxy using the specified service provider and expression tree normalization services.
 /// </summary>
 /// <param name="serviceProvider">Metadata service provider exposing the underlying query provider for use by IRP facilities.</param>
 /// <param name="expressionServices">Expression tree normalization services.</param>
 private AzureReactiveMetadataProxy(AzureMetadataServiceProvider serviceProvider, ReactiveExpressionServices expressionServices)
     : base(serviceProvider, expressionServices)
 {
     _queryProvider = (AzureMetadataQueryProvider)serviceProvider.Provider;
 }