public void Create_WhenCreatingFieldWithAttribute_ShouldGenerateCorrectCode() { Assert.AreEqual("[Test]intmyField;", FieldGenerator.Create(new Field("myField", typeof(int), attributes: new List <Attribute>() { new Attribute("Test") })).ToString()); }
public void Create_WhenCreatingFieldWithModifiers_ShouldGenerateCorrectCode() { Assert.AreEqual("publicintmyField;", FieldGenerator.Create(new Field("myField", typeof(int), new List <Modifiers>() { Modifiers.Public })).ToString()); }
/// <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); }
public void Create_WhenCreatingFieldWithMultipleGenericType_ShouldGenerateCorrectCode() { Assert.AreEqual("List<List<string>>myField;", FieldGenerator.Create(new Field("myField", typeof(List <List <string> >))).ToString()); }
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()); }
public void Create_WhenCreatingField_ShouldGenerateCorrectCode() { Assert.AreEqual("intmyField;", FieldGenerator.Create(new Field("myField", typeof(int))).ToString()); }