Esempio n. 1
0
        private void AnalyzeServiceAndInterfaces(Type serviceType)
        {
            var tree = new InterfaceTree(serviceType);

            for (var i = 0; i < tree.Services.Count; i++)
            {
                var service = tree.Services[i];
                var interfaceDescription = new InterfaceDescription(service.ServiceType);
                Services.Add(interfaceDescription);

                foreach (var method in ReflectionTools.GetMethods(service.ServiceType))
                {
                    if (!ServiceContract.IsServiceOperation(method))
                    {
                        interfaceDescription.Methods.Add(CreateNonServiceOperation(service.ServiceType, method));
                        continue;
                    }

                    if (TryCreateMessage(method, out var message, out var error))
                    {
                        interfaceDescription.Operations.Add(new OperationDescription(
                                                                service.ServiceName,
                                                                ServiceContract.GetServiceOperationName(method),
                                                                message));
                    }
Esempio n. 2
0
        public void NonServiceContractTree()
        {
            var sut = new InterfaceTree(typeof(NonServiceContract.IService));

            sut.Interfaces.Count.ShouldBe(1);
            sut.Interfaces[0].ShouldBe(typeof(NonServiceContract.IService));

            sut.Services.ShouldBeEmpty();
        }
Esempio n. 3
0
        public void TransientInterfaceTree()
        {
            var sut = new InterfaceTree(typeof(TransientInterface.IContract));

            sut.Interfaces.Count.ShouldBe(1);
            sut.Interfaces[0].ShouldBe(typeof(TransientInterface.IService2));

            sut.Services.Count.ShouldBe(2);

            sut.Services[0].ServiceName.ShouldBe(nameof(TransientInterface.IContract));
            sut.Services[0].ServiceType.ShouldBe(typeof(TransientInterface.IContract));

            sut.Services[1].ServiceName.ShouldBe(nameof(TransientInterface.IContract));
            sut.Services[1].ServiceType.ShouldBe(typeof(TransientInterface.IService1));
        }
Esempio n. 4
0
        public void RootNotFoundTree()
        {
            var sut = new InterfaceTree(typeof(RootNotFound.Contract));

            sut.Interfaces.ShouldBeEmpty();

            sut.Services.Count.ShouldBe(3);

            sut.Services[0].ServiceName.ShouldBe(nameof(RootNotFound.IContract1));
            sut.Services[0].ServiceType.ShouldBe(typeof(RootNotFound.IContract1));

            sut.Services[1].ServiceName.ShouldBe(nameof(RootNotFound.IContract2));
            sut.Services[1].ServiceType.ShouldBe(typeof(RootNotFound.IContract2));

            sut.Services[2].ServiceName.ShouldBe(nameof(RootNotFound.IContract1));
            sut.Services[2].ServiceType.ShouldBe(typeof(RootNotFound.IService));
        }
Esempio n. 5
0
        public void OneContractRootTree(Type rootType)
        {
            var sut = new InterfaceTree(rootType);

            sut.Interfaces.Count.ShouldBe(1);
            sut.Interfaces[0].ShouldBe(typeof(IDisposable));

            sut.Services.Count.ShouldBe(3);

            sut.Services[0].ServiceName.ShouldBe(nameof(OneContractRoot.IContract));
            sut.Services[0].ServiceType.ShouldBe(typeof(OneContractRoot.IContract));

            sut.Services[1].ServiceName.ShouldBe(nameof(OneContractRoot.IContract));
            sut.Services[1].ServiceType.ShouldBe(typeof(OneContractRoot.IService1));

            sut.Services[2].ServiceName.ShouldBe(nameof(OneContractRoot.IContract));
            sut.Services[2].ServiceType.ShouldBe(typeof(OneContractRoot.IService2));
        }
Esempio n. 6
0
        public void AttachToMostTopContractTree()
        {
            var sut = new InterfaceTree(typeof(AttachToMostTopContract.IContract2));

            sut.Interfaces.ShouldBeEmpty();

            sut.Services.Count.ShouldBe(4);

            sut.Services[0].ServiceName.ShouldBe(nameof(AttachToMostTopContract.IContract2));
            sut.Services[0].ServiceType.ShouldBe(typeof(AttachToMostTopContract.IContract2));

            sut.Services[1].ServiceName.ShouldBe(nameof(AttachToMostTopContract.IContract1));
            sut.Services[1].ServiceType.ShouldBe(typeof(AttachToMostTopContract.IContract1));

            sut.Services[2].ServiceName.ShouldBe(nameof(AttachToMostTopContract.IContract2));
            sut.Services[2].ServiceType.ShouldBe(typeof(AttachToMostTopContract.IService1));

            sut.Services[3].ServiceName.ShouldBe(nameof(AttachToMostTopContract.IContract2));
            sut.Services[3].ServiceType.ShouldBe(typeof(AttachToMostTopContract.IService2));
        }