Example #1
0
        /// <summary>
        /// 此测试用例的目的在于测试消息头的发送是否成功
        /// </summary>
        static void Main()
        {
            //初始化容器
            InitContainer();

            //伪造一个登录信息
            IAuthenticationContract authenticationContract = ResolveMediator.Resolve <IAuthenticationContract>();
            LoginInfo fakeLoginInfo = authenticationContract.Login(CommonConstants.AdminLoginId, CommonConstants.InitialPassword);

            //将登录信息存入约定位置
            AppDomain.CurrentDomain.SetData(SessionKey.CurrentUser, fakeLoginInfo);

            //实例化服务接口
            IServerContract serverContract = ResolveMediator.Resolve <IServerContract>();

            //调用服务获取消息头
            string header = serverContract.GetHeader();

            //如果消息头内容即是上述伪造的公钥,即说明整个认证过程没问题
            if (fakeLoginInfo.PublicKey.ToString() == header)
            {
                Console.WriteLine("认证通过!");
            }

            ResolveMediator.Dispose();
            Console.ReadKey();
        }
Example #2
0
        /// <summary>
        /// 此测试用例的目的在于测试消息头的发送是否成功
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            //初始化容器
            InitContainer();

            //伪造一个登录信息
            IAuthenticationContract authenticationContract = ResolveMediator.Resolve <IAuthenticationContract>();
            LoginInfo fakeLoginInfo = authenticationContract.Login(CommonConstants.AdminLoginId, CommonConstants.InitialPassword);

            //将登录信息存入约定位置
            base.Session.Add(SessionKey.CurrentUser, fakeLoginInfo);

            //实例化WCF服务端服务接口
            IServerContract serverContract = ResolveMediator.Resolve <IServerContract>();

            //调用服务获取消息头
            string header = serverContract.GetHeader();

            //如果消息头内容即是上述伪造的公钥,即说明整个认证过程没问题
            if (fakeLoginInfo.PublicKey.ToString() == header)
            {
                base.Response.Write("认证通过!");
            }

            ResolveMediator.Dispose();
        }
        public void CreateProduct(string productNo, string productName, IEnumerable <PriceParam> priceParams)
        {
            Trace.WriteLine(productNo);
            Trace.WriteLine(productName);
            Trace.WriteLine(priceParams);

            //伪造一个登录信息
            IAuthenticationContract authenticationContract = ResolveMediator.Resolve <IAuthenticationContract>();
            LoginInfo fakeLoginInfo = authenticationContract.Login(CommonConstants.AdminLoginId, CommonConstants.InitialPassword);

            //实例化服务接口
            IServerContract serverContract = ResolveMediator.Resolve <IServerContract>();

            //调用服务获取消息头
            string header = serverContract.GetHeader();

            //如果消息头内容即是上述伪造的公钥,即说明整个认证过程没问题
            if (fakeLoginInfo.PublicKey.ToString() == header)
            {
                Console.WriteLine("认证通过!");
            }
        }
        public string GetProducts(string keywords, int pageIndex, int pageSize)
        {
            Trace.WriteLine(keywords);
            Trace.WriteLine(pageIndex);
            Trace.WriteLine(pageSize);

            //伪造一个登录信息
            IAuthenticationContract authenticationContract = ResolveMediator.Resolve <IAuthenticationContract>();
            LoginInfo fakeLoginInfo = authenticationContract.Login(CommonConstants.AdminLoginId, CommonConstants.InitialPassword);

            //实例化服务接口
            IServerContract serverContract = ResolveMediator.Resolve <IServerContract>();

            //调用服务获取消息头
            string header = serverContract.GetHeader();

            //如果消息头内容即是上述伪造的公钥,即说明整个认证过程没问题
            if (fakeLoginInfo.PublicKey.ToString() == header)
            {
                Console.WriteLine("认证通过!");
            }

            return("Hello World");
        }
        public IEnumerable <Order> GetOrders(string keywords, int pageIndex, int pageSize)
        {
            Trace.WriteLine(keywords);
            Trace.WriteLine(pageIndex);
            Trace.WriteLine(pageSize);

            //伪造一个登录信息
            IAuthenticationContract authenticationContract = ResolveMediator.Resolve <IAuthenticationContract>();
            LoginInfo fakeLoginInfo = authenticationContract.Login(CommonConstants.AdminLoginId, CommonConstants.InitialPassword);

            //实例化服务接口
            IServerContract serverContract = ResolveMediator.Resolve <IServerContract>();

            //调用服务获取消息头
            string header = serverContract.GetHeader();

            //如果消息头内容即是上述伪造的公钥,即说明整个认证过程没问题
            if (fakeLoginInfo.PublicKey.ToString() == header)
            {
                Console.WriteLine("认证通过!");
            }

            IList <Order> orders = new List <Order>
            {
                new Order
                {
                    Number  = "001",
                    Name    = "单据1",
                    Details = new List <OrderDetail>
                    {
                        new OrderDetail
                        {
                            Number      = "明细1",
                            Description = "明细1"
                        },
                        new OrderDetail
                        {
                            Number      = "明细2",
                            Description = "明细2"
                        }
                    }
                },
                new Order
                {
                    Number  = "002",
                    Name    = "单据2",
                    Details = new List <OrderDetail>
                    {
                        new OrderDetail
                        {
                            Number      = "明细1",
                            Description = "明细1"
                        },
                        new OrderDetail
                        {
                            Number      = "明细2",
                            Description = "明细2"
                        },
                    }
                }
            };

            return(orders);
        }