示例#1
0
 public void Create_WhenCreatingFieldWithAttribute_ShouldGenerateCorrectCode()
 {
     Assert.AreEqual("[Test]intmyField;", FieldGenerator.Create(new Field("myField", typeof(int), attributes: new List <Attribute>()
     {
         new Attribute("Test")
     })).ToString());
 }
示例#2
0
 public void Create_WhenCreatingFieldWithModifiers_ShouldGenerateCorrectCode()
 {
     Assert.AreEqual("publicintmyField;", FieldGenerator.Create(new Field("myField", typeof(int), new List <Modifiers>()
     {
         Modifiers.Public
     })).ToString());
 }
示例#3
0
        /// <summary>
        /// Set class fields.
        /// </summary>
        /// <param name="fields">A set of wanted fields.</param>
        /// <returns>The current class builder</returns>
        public ClassBuilder WithFields(params Field[] fields)
        {
            _fields.Clear();
            foreach (var field in fields)
            {
                _fields.Add(FieldGenerator.Create(field));
            }

            return(this);
        }
示例#4
0
 public void Create_WhenCreatingFieldWithMultipleGenericType_ShouldGenerateCorrectCode()
 {
     Assert.AreEqual("List<List<string>>myField;", FieldGenerator.Create(new Field("myField", typeof(List <List <string> >))).ToString());
 }
示例#5
0
 public void Create_WhenCreatingFieldWithInitializer_ShouldGenerateCorrectCode()
 {
     Assert.AreEqual("ILogger_logger=LoggerService.Logger();", FieldGenerator.Create(new Field("_logger", CustomType.Create("ILogger"), initializeWith: ReferenceGenerator.Create(new VariableReference("LoggerService", new MethodReference("Logger"))))).ToString());
 }
示例#6
0
 public void Create_WhenCreatingField_ShouldGenerateCorrectCode()
 {
     Assert.AreEqual("intmyField;", FieldGenerator.Create(new Field("myField", typeof(int))).ToString());
 }