Exemple #1
0
        public void GetProductById_NoneExistingId()
        {
            ChemiCleanDBEntities _dbContext = new ChemiCleanDBEntities();

            ProductRepository         productsRepository        = new ProductRepository(_dbContext);
            ProductDocumentRepository productDocumentRepository = new ProductDocumentRepository(_dbContext);

            UrlFileService urlFileService = new UrlFileService();
            UnitOfWork     unitOfWork     = new UnitOfWork(_dbContext);

            ProductDocumentService productDocumentService = new ProductDocumentService(productDocumentRepository, urlFileService, unitOfWork);
            ProductService         productsService        = new ProductService(productsRepository, productDocumentService, unitOfWork);

            var NonExistingFile = productsService.GetProduct(0);

            Assert.Null(NonExistingFile);
        }
Exemple #2
0
        /// <summary>
        /// Creates a new ProductDocumentService proxy instance
        /// </summary>
        /// <returns>Nettiers.AdventureWorks.Contracts.Services.IProductDocumentService</returns>
        public static Nettiers.AdventureWorks.Contracts.Services.IProductDocumentService ProductDocumentServiceProxyInstance(CommunicationPlatform platform)
        {
            Nettiers.AdventureWorks.Contracts.Services.IProductDocumentService proxy = null;

            try
            {
                switch (platform)
                {
                    case CommunicationPlatform.Direct:
                        proxy = new ProductDocumentService() as IProductDocumentService;
                        break;

                    case CommunicationPlatform.WCF:
                        if (factoryProductDocumentService == null)
                        {
                            factoryProductDocumentService = new ChannelFactory<Nettiers.AdventureWorks.Contracts.Services.IProductDocumentService>("ProductDocumentService");                            
                            factoryProductDocumentService.Credentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Delegation;
                            //factoryProductDocumentService.Credentials.Windows.AllowNtlm = true;
                        }

                        if (ClientCredentials != null)
                            factoryProductDocumentService.Credentials.Windows.ClientCredential = ClientCredentials;    
                            
                        proxy = factoryProductDocumentService.CreateChannel();
                        break;
						
					case CommunicationPlatform.BaseAddress:
                         CustomBinding binding = new CustomBinding(bindingConfigName);
                        //WSHttpBinding binding = new WSHttpBinding("WSHttpBindingConfig");
                        //BasicHttpBinding binding = new BasicHttpBinding("BasicHttpBindingConfig");
                    	EndpointAddress endpoint = new EndpointAddress(BaseAddress + "ProductDocumentService.svc/gzip");                    
                    	factoryProductDocumentService = new ChannelFactory<Nettiers.AdventureWorks.Contracts.Services.IProductDocumentService>(binding, endpoint);
                        factoryProductDocumentService.Endpoint.Behaviors.Add(new SecurityEndpointBehavior());
                        factoryProductDocumentService.Credentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Delegation;
                        //factoryProductDocumentService.Credentials.Windows.AllowNtlm = true;
                        
                        if (ClientCredentials != null)
                            factoryProductDocumentService.Credentials.Windows.ClientCredential = ClientCredentials;    
                        
						proxy = factoryProductDocumentService.CreateChannel();
						break;
                }
                
                if (proxy != null)
                {
                    OperationContextScope scope = new OperationContextScope((IContextChannel)proxy);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return proxy;
        }