public void AsTest() { var obj = new GenericData { Name = "fireasy" }; Assert.IsNotNull(obj.As <IName>()); Assert.IsNull(obj.As <IDisposable>()); }
public void AsTestWithAction() { var name1 = string.Empty; var name2 = string.Empty; var obj = new GenericData { Name = "fireasy" }; obj.As <IName>(s => name1 = s.Name, () => name1 = "none"); obj.As <IName1>(s => name2 = s.Name, () => name2 = "none"); Assert.AreEqual("fireasy", name1); Assert.AreEqual("none", name2); }