public void TestFromServiceDescription_Overloaded()
        {
            var runtime = RpcServerRuntime.Create(RpcServerConfiguration.Default, new SerializationContext());
            ServiceDescription service = ServiceDescription.FromServiceType(typeof(Overloaded));

            OperationDescription.FromServiceDescription(runtime, service).ToArray();
        }
        public void TestFromServiceDescription_WithOutMethods_Empty()
        {
            var runtime = RpcServerRuntime.Create(RpcServerConfiguration.Default, new SerializationContext());
            ServiceDescription service = ServiceDescription.FromServiceType(typeof(NoMember));

            var result = OperationDescription.FromServiceDescription(runtime, service).ToArray();

            Assert.That(result, Is.Not.Null.And.Empty);
        }
        public void TestFromServiceType_NoMethods_PropertiesSetAsAttributeValue()
        {
            Type serviceType = typeof(ServiceWithoutMembers);

            var result = ServiceDescription.FromServiceType(serviceType);

            Assert.That(result.Initializer, Is.Not.Null);
            Assert.That(result.Name, Is.EqualTo(ServiceWithoutMembers.Name));
            Assert.That(result.ServiceType, Is.EqualTo(serviceType));
            Assert.That(result.Version, Is.EqualTo(0));

            Assert.That(result.Initializer(), Is.Not.Null.And.TypeOf(serviceType));
        }
        public void TestFromServiceDescription_WithMethods_CreateForPublicAnnotatedMembers()
        {
            var runtime = RpcServerRuntime.Create(RpcServerConfiguration.Default, new SerializationContext());
            ServiceDescription service = ServiceDescription.FromServiceType(typeof(Service));

            var result = OperationDescription.FromServiceDescription(runtime, service).OrderBy(item => item.Id).ToArray();

            Assert.That(result, Is.Not.Null.And.Length.EqualTo(2));
            Assert.That(result[0].Id, Is.StringStarting(Service.ExpectedOperationId1));
            Assert.That(result[0].Operation, Is.Not.Null);
            Assert.That(result[0].Service, Is.EqualTo(service));
            Assert.That(result[1].Id, Is.StringStarting(Service.ExpectedOperationId2));
            Assert.That(result[1].Operation, Is.Not.Null);
            Assert.That(result[1].Service, Is.EqualTo(service));
        }
Ejemplo n.º 5
0
        private static ServiceDescription ExtractServiceDescription(string svcFile, string directory, IDictionary <string, Type> serviceTypeCatalog)
        {
            ServiceHostDirective directive;

            using (var stream = new FileStream(svcFile, FileMode.Open, FileAccess.Read, FileShare.Read, 1024, FileOptions.SequentialScan))
                using (var reader = new StreamReader(stream))
                {
                    directive = SvcFileParser.Parse(reader);
                }

            if (directive.Service == null)
            {
                throw new InvalidOperationException(
                          String.Format(
                              CultureInfo.CurrentCulture,
                              "'Service' attribute is not found in '{0}' file.",
                              svcFile
                              )
                          );
            }

            Type serviceType;

            if (!serviceTypeCatalog.TryGetValue(directive.Service, out serviceType))
            {
                throw new InvalidOperationException(
                          String.Format(
                              CultureInfo.CurrentCulture,
                              "Cannot load the service type for name '{0}' from directory '{1}'. Note that service type name is case sensitive.",
                              directive.Service,
                              directory
                              )
                          );
            }

            return(ServiceDescription.FromServiceType(serviceType));
        }
        public void TestFromServiceDescription_RuntimeIsNull()
        {
            ServiceDescription service = ServiceDescription.FromServiceType(typeof(Overloaded));

            OperationDescription.FromServiceDescription(null, service).ToArray();
        }
Ejemplo n.º 7
0
 /// <summary>
 ///		Adds the specified service.
 /// </summary>
 /// <param name="serviceType">Type of the service.</param>
 /// <returns>
 ///		<c>true</c> if the specified service newly added; otherwise, <c>false</c>.
 /// </returns>
 /// <exception cref="ArgumentNullException">
 ///		<paramref name="serviceType"/> is <c>null</c>.
 /// </exception>
 /// <exception cref="ArgumentException">
 ///		<paramref name="serviceType"/> is invalid.
 ///		See <see cref="M:ServiceDescription.FromServiceType"/> for details.
 /// </exception>
 public bool AddService(Type serviceType)
 {
     return(this._serviceTypes.Add(ServiceDescription.FromServiceType(serviceType)));
 }
        public void TestFromServiceType_ServiceWithoutDefaultPublicConstructor()
        {
            Type serviceType = typeof(ServiceWithoutDefaultPublicConstructor);

            ServiceDescription.FromServiceType(serviceType);
        }
        public void TestFromServiceType_WithoutMessagePackRpcServiceContract()
        {
            Type serviceType = typeof(ServiceWithoutServiceContract);

            ServiceDescription.FromServiceType(serviceType);
        }
        public void TestFromServiceType_Null()
        {
            Type serviceType = null;

            ServiceDescription.FromServiceType(serviceType);
        }