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")); } }
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")); } }
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(); } }
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. }
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. }
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(); } }
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."); } } }
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."); } } }
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); } }
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); } }