public void TestDecorateClass() { var codeType = new CodeTypeDeclaration("TestClass"); var decorator = new EasyConstructServiceDecorator(); var service = CreateBuzzService(); decorator.DecorateClass(service, codeType); Assert.AreEqual(3, codeType.Members.Count); // We expect two members to be added. // Test the empty constructor. Assert.IsInstanceOf(typeof(CodeConstructor), codeType.Members[0]); var constructor = (CodeConstructor)codeType.Members[0]; Assert.AreEqual(0, constructor.Parameters.Count); Assert.AreEqual(0, constructor.Statements.Count); // Test the constructor taking the authenticator. Assert.IsInstanceOf(typeof(CodeConstructor), codeType.Members[1]); var constructor2 = (CodeConstructor)codeType.Members[1]; Assert.AreEqual(1, constructor2.Parameters.Count); Assert.AreEqual(0, constructor2.Statements.Count); // Test the generated constant. Assert.IsInstanceOf(typeof(CodeMemberField), codeType.Members[2]); Assert.AreEqual(EasyConstructServiceDecorator.DiscoveryConstantName, codeType.Members[2].Name); }
public void TestDecorateClass() { var codeType = new CodeTypeDeclaration("TestClass"); var decorator = new EasyConstructServiceDecorator(); var service = CreateBuzzService(); decorator.DecorateClass(service, codeType); Assert.AreEqual(1, codeType.Members.Count); // We expect one constructor to be generated. // Test the empty constructor. Assert.IsInstanceOf(typeof(CodeConstructor), codeType.Members[0]); var constructor = (CodeConstructor)codeType.Members[0]; Assert.AreEqual(0, constructor.Parameters.Count); Assert.AreEqual(0, constructor.Statements.Count); }