コード例 #1
0
  public void Generate()
  {
    //Arrange
    var movie = new Movie { Id = 1, Release_Year = 1988, Title = "Title" };

    //Act
    string statement = new CreateInsert().Generate(movie, null);

    //Assert
    statement.Should().Be(@"INSERT INTO Movies (Title, Id, Release_Year) VALUES ('Title', 1, 1988);");
  }
コード例 #2
0
  public void Generate_ShouldNotPluralizeEntityName()
  {
    //Arrange
    var movie = new Movie { Id = 1, Release_Year = 1988, Title = "Title" };
    var insertProperties = new InsertProperties
    {
      ShouldPluralizeEntityName = false
    };

    //Act
    string statement = new CreateInsert().Generate(movie, insertProperties);

    //Assert
    statement.Should().Be($"INSERT INTO {nameof(Movie)} (Title, Id, Release_Year) VALUES ('Title', 1, 1988);");
  }
コード例 #3
0
  public void Generate_OverrideEntityName()
  {
    //Arrange
    var movie = new Movie { Id = 1, Release_Year = 1988, Title = "Title" };
    var insertProperties = new InsertProperties
    {
      EntityName = "TestName"
    };

    //Act
    string statement = new CreateInsert().Generate(movie, insertProperties);

    //Assert
    statement.Should().Be($"INSERT INTO {insertProperties.EntityName}s (Title, Id, Release_Year) VALUES ('Title', 1, 1988);");
  }
コード例 #4
0
  public void Generate_ImmutableRecordType()
  {
    //Arrange
    var book = new Book("Title", "Author");

    var insertProperties = new InsertProperties
    {
      ShouldPluralizeEntityName = false
    };

    //Act
    string statement = new CreateInsert().Generate(book, insertProperties);

    //Assert
    statement.Should().Be($"INSERT INTO {nameof(Book)} (Title, Author) VALUES ('Title', 'Author');");
  }