public CompositeType GetDataUsingDataContract(CompositeType composite) { if (composite == null) { throw new ArgumentNullException("composite"); } if (composite.BoolValue) { composite.StringValue += "Suffix"; } return composite; }
public void TestGetDataUsingDataContract() { IService1 service = new Service1(); CompositeType data = new CompositeType() { BoolValue = true, StringValue = "Good", }; CompositeType result = service.GetDataUsingDataContract(data); Assert.AreEqual("GoodSuffix", result.StringValue); data = new CompositeType() { BoolValue = false, StringValue = "Good", }; result = service.GetDataUsingDataContract(data); Assert.AreEqual("Good", result.StringValue); try { result = service.GetDataUsingDataContract(null); Assert.Fail("Hey, I expect ArgumentNullException."); } catch (ArgumentNullException) { Assert.IsTrue(true, "Very good, excepted."); } }