Exemple #1
0
 static void Main(string[] args)
 {
     Uri address = new Uri("http://localhost/WcfServices/CalculatorService");
     ServiceProxyFactory<ICalculator> factory = new ServiceProxyFactory<ICalculator>(address);
     ICalculator proxy = factory.CreateChannel();
     Console.WriteLine("x + y = {2} when x = {0} and y = {1}", 1, 2, proxy.Add(1, 2));
     Console.WriteLine("x - y = {2} when x = {0} and y = {1}", 1, 2, proxy.Subtract(1, 2));
     Console.WriteLine("x * y = {2} when x = {0} and y = {1}", 1, 2, proxy.Multiply(1, 2));
     Console.WriteLine("x / y = {2} when x = {0} and y = {1}", 1, 2, proxy.Divide(1, 2));
 }
Exemple #2
0
        public void DeleteUserTest()
        {
            IUserService userService = ServiceProxyFactory.CreateChannel <IUserService>();
            var          model       = new Bussiness.User.DataContract.UserModelRequest();

            model.UserId = 9;

            BaseResponse response = userService.DeleteUser(model);

            Assert.IsTrue(response.IsSuccess);
        }
Exemple #3
0
        public void GetUserTest()
        {
            IUserService userService = ServiceProxyFactory.CreateChannel <IUserService>();
            var          model       = new Bussiness.User.DataContract.UserModelRequest();


            List <UserModelResponse> users = userService.GetAllUsers();

            Assert.IsTrue(users.Count > 1);

            UserModelResponse user = userService.GetUser(new UserModelRequest {
                UserId = 1
            });

            Assert.IsNotNull(user);
        }
Exemple #4
0
 public void UpdateUserTest()
 {
     try
     {
         IUserService userService = ServiceProxyFactory.CreateChannel <IUserService>();
         var          model       = new Bussiness.User.DataContract.UserModelRequest();
         model.UserId   = 8;
         model.UserName = "******";
         BaseResponse response = userService.UpdateUser(model);
         Assert.IsTrue(response.IsSuccess);
     }
     catch (FaultException ex)
     {
         throw ex;
     }
 }
Exemple #5
0
        public void AddUserTest()
        {
            IUserService userService = ServiceProxyFactory.CreateChannel <IUserService>();
            var          model       = new Bussiness.User.DataContract.UserModelRequest();

            model.UserName = "******";
            UserModelResponse response = userService.AddUser(model);

            Assert.IsTrue(response.IsSuccess);

            //Ctrip.SOA.Service.Test.UserService.UserServiceClient client = new Service.Test.UserService.UserServiceClient();
            //var model = new Bussiness.User.DataContract.UserModelRequest();
            //model.UserName = "******";
            //UserModelResponse response = client.AddUser(model);
            //Assert.IsTrue(response.IsSuccess);
        }