Exemplo n.º 1
0
 public void TestGetData()
 {
     using (RealWorldProxy client = new RealWorldProxy(realWorldEndpoint))
     {
         client.Instance.ClientCredentials.UserName.UserName = "******";
         client.Instance.ClientCredentials.UserName.Password = "******";
         Assert.True(client.Instance.GetData(1234).Contains("1234"));
     }
 }
Exemplo n.º 2
0
 public void TestGetData()
 {
     using (RealWorldProxy client = new RealWorldProxy(realWorldEndpoint))
     {
         client.Instance.ClientCredentials.UserName.UserName = "******";
         client.Instance.ClientCredentials.UserName.Password = "******";
         Assert.True(client.Instance.GetData(1234).Contains("1234"));
     }
 }
Exemplo n.º 3
0
        static Task <string> GetHardData(int d)
        {
            RealWorldProxy client = new RealWorldProxy(realWorldEndpoint);

            try
            {
                client.Instance.ClientCredentials.UserName.UserName = "******";
                client.Instance.ClientCredentials.UserName.Password = "******";
                return(client.Instance.GetHardDataAsync(d));
            }
            finally
            {
                client.Dispose();
            }
        }
Exemplo n.º 4
0
 public void TestGetData666ExpectedError()
 {
     using (RealWorldProxy client = new RealWorldProxy(realWorldEndpoint))
     {
         client.Instance.ClientCredentials.UserName.UserName = "******";
         client.Instance.ClientCredentials.UserName.Password = "******";
         var ex = Assert.Throws<FaultException<Evil666Error>>(() =>
         {
             Assert.True(client.Instance.GetData(666).Contains("1234"));
             Assert.True(false, "Expect fault");
         });
         ex.Detail.Message.Contains("666");
     }
     //ErrorHandlerBehaviorAttribute in the service side also catch the exception.
 }
Exemplo n.º 5
0
 public void TestGetData666ExpectedError()
 {
     using (RealWorldProxy client = new RealWorldProxy(realWorldEndpoint))
     {
         client.Instance.ClientCredentials.UserName.UserName = "******";
         client.Instance.ClientCredentials.UserName.Password = "******";
         var ex = Assert.Throws <FaultException <Evil666Error> >(() =>
         {
             Assert.True(client.Instance.GetData(666).Contains("1234"));
             Assert.True(false, "Expect fault");
         });
         ex.Detail.Message.Contains("666");
     }
     //ErrorHandlerBehaviorAttribute in the service side also catch the exception.
 }
Exemplo n.º 6
0
        static Task<string> GetHardData(int d)
        {
            RealWorldProxy client = new RealWorldProxy(realWorldEndpoint);

            try
            {
                client.Instance.ClientCredentials.UserName.UserName = "******";
                client.Instance.ClientCredentials.UserName.Password = "******";
                return client.Instance.GetHardDataAsync(d);

            }
            finally
            {
                client.Dispose();
            }
        }
Exemplo n.º 7
0
        public void TestGetDataUsingDataContract()
        {
            using (RealWorldProxy client = new RealWorldProxy(realWorldEndpoint))
            {
                client.Instance.ClientCredentials.UserName.UserName = "******";
                client.Instance.ClientCredentials.UserName.Password = "******";
                CompositeType data = new CompositeType()
                {
                    BoolValue = true,
                    StringValue = "Good",
                };

                CompositeType result = client.Instance.GetDataUsingDataContract(data);
                Assert.Equal("GoodSuffix", result.StringValue);
            }

            using (RealWorldProxy client = new RealWorldProxy(realWorldEndpoint))
            {
                client.Instance.ClientCredentials.UserName.UserName = "******";
                client.Instance.ClientCredentials.UserName.Password = "******";

                CompositeType data = new CompositeType()
                {
                    BoolValue = false,
                    StringValue = "Good",
                };
                CompositeType result = client.Instance.GetDataUsingDataContract(data);
                Assert.Equal("Good", result.StringValue);
            }

            using (RealWorldProxy client = new RealWorldProxy(realWorldEndpoint))
            {
                client.Instance.ClientCredentials.UserName.UserName = "******";
                client.Instance.ClientCredentials.UserName.Password = "******";
                try
                {
                    CompositeType result = client.Instance.GetDataUsingDataContract(null);
                    Assert.True(false, "Hey, I expect FaultException.");
                }
                catch (System.ServiceModel.FaultException)
                {
                    Assert.True(true, "Very good, excepted.");
                }
            }
        }
Exemplo n.º 8
0
        public void TestGetDataUsingDataContract()
        {
            using (RealWorldProxy client = new RealWorldProxy(realWorldEndpoint))
            {
                client.Instance.ClientCredentials.UserName.UserName = "******";
                client.Instance.ClientCredentials.UserName.Password = "******";
                CompositeType data = new CompositeType()
                {
                    BoolValue   = true,
                    StringValue = "Good",
                };

                CompositeType result = client.Instance.GetDataUsingDataContract(data);
                Assert.Equal("GoodSuffix", result.StringValue);
            }

            using (RealWorldProxy client = new RealWorldProxy(realWorldEndpoint))
            {
                client.Instance.ClientCredentials.UserName.UserName = "******";
                client.Instance.ClientCredentials.UserName.Password = "******";

                CompositeType data = new CompositeType()
                {
                    BoolValue   = false,
                    StringValue = "Good",
                };
                CompositeType result = client.Instance.GetDataUsingDataContract(data);
                Assert.Equal("Good", result.StringValue);
            }

            using (RealWorldProxy client = new RealWorldProxy(realWorldEndpoint))
            {
                client.Instance.ClientCredentials.UserName.UserName = "******";
                client.Instance.ClientCredentials.UserName.Password = "******";
                try
                {
                    CompositeType result = client.Instance.GetDataUsingDataContract(null);
                    Assert.True(false, "Hey, I expect FaultException.");
                }
                catch (System.ServiceModel.FaultException)
                {
                    Assert.True(true, "Very good, excepted.");
                }
            }
        }
Exemplo n.º 9
0
        public void TestGetDataUsingDataContractThrowsMessageSecurityException()
        {
            using (RealWorldProxy client = new RealWorldProxy(realWorldEndpoint))
            {
                client.Instance.ClientCredentials.UserName.UserName = "******";
                client.Instance.ClientCredentials.UserName.Password = "******";

                CompositeType data = new CompositeType()
                {
                    BoolValue   = true,
                    StringValue = "Good",
                };

                var ex = Assert.Throws <System.ServiceModel.Security.MessageSecurityException>(() =>
                {
                    CompositeType result = client.Instance.GetDataUsingDataContract(data);
                });

                Assert.True(ex.InnerException is System.ServiceModel.FaultException);
            }
        }
Exemplo n.º 10
0
        public void TestGetDataUsingDataContractThrowsMessageSecurityException()
        {
            using (RealWorldProxy client = new RealWorldProxy(realWorldEndpoint))
            {
                client.Instance.ClientCredentials.UserName.UserName = "******";
                client.Instance.ClientCredentials.UserName.Password = "******";

                    CompositeType data = new CompositeType()
                    {
                        BoolValue = true,
                        StringValue = "Good",
                    };

                var ex = Assert.Throws<System.ServiceModel.Security.MessageSecurityException>(() =>
                {
                    CompositeType result = client.Instance.GetDataUsingDataContract(data);
                });

                Assert.True(ex.InnerException is System.ServiceModel.FaultException);
            }
        }