public static SqlModelDescription <GroupUser> GroupUser() { return(SqlModelDescription <GroupUser> .Auto("core", "groupUsers") .WithPrimaryKey(p => p.GroupId) .WithPrimaryKey(p => p.UserId)); }
public void Auto_Registers_Inherited_Property() { var description = SqlModelDescription <Cat> .Auto("schema", "cats"); description.Property(c => c.Id).Should().NotBeNull(); description.Property(c => c.Name).Should().NotBeNull(); }
public void RegisterModelScription_Can_Register_Single_ModelDescription() { var validContext = GetValidContext(); validContext.RegisterModelDescription(SqlModelDescription <TypeA> .Auto("schema", "typeA")); validContext.GetModelDescription <TypeA>().Should().NotBeNull(); }
public void RegisterModelScription_Can_Not_Register_Duplicate_ModelDescription() { var validContext = GetValidContext(); validContext.RegisterModelDescription(SqlModelDescription <TypeA> .Auto("schema", "typeA")); Assert.Throws <TypeAlreadyRegisteredException>( () => validContext.RegisterModelDescription(SqlModelDescription <TypeA> .Auto("schema", "typeA"))); }
public void SelectCommand_Can_Build_Command_With_Where_Clause() { string schema = "core"; string tableName = "typeCs"; var validContext = GetValidContext(); validContext.RegisterModelDescription(SqlModelDescription <TypeC> .Auto(schema, tableName)); string command = validContext.SelectCommand <TypeC>("Id = @Id"); command.Should().Be($"SELECT * FROM [{schema}].[{tableName}] WHERE Id = @Id;"); }
public void InsertCommand_Can_Build_Command() { string tableName = "typeCs"; string schema = "core"; var validContext = GetValidContext(); validContext.RegisterModelDescription(SqlModelDescription <TypeC> .Auto(schema, tableName)); string command = validContext.InsertCommand <TypeC>(); command.Should().Be($"INSERT INTO [{schema}].[{tableName}] ([integer], [name]) OUTPUT inserted.id VALUES (@Integer, @Name);"); }
public void UpdateCommand_Can_Build_Command() { string schema = "core"; string table = "typeCs"; string whereClause = "id = @Id"; var validContext = GetValidContext(); validContext.RegisterModelDescription(SqlModelDescription <TypeC> .Auto(schema, table)); var command = validContext.UpdateCommand <TypeC>(whereClause); command.Should().Be($"UPDATE [{schema}].[{table}] SET [integer] = @Integer, [name] = @Name WHERE {whereClause};"); }
public void GetModelDescription_Can_Find_ModelDescription() { var validContext = GetValidContext(); var descriptionTypeA = SqlModelDescription <TypeA> .Auto("core", "typeAs"); var descriptionTypeB = SqlModelDescription <TypeB> .Auto("core", "typeBs"); validContext.RegisterModelDescription(descriptionTypeA); validContext.RegisterModelDescription(descriptionTypeB); validContext.GetModelDescription <TypeA>().ShouldBeEquivalentTo(descriptionTypeA); validContext.GetModelDescription <TypeB>().ShouldBeEquivalentTo(descriptionTypeB); }
public void DeleteCommand_Can_Build_Command() { string schema = "core"; string table = "typeCs"; string whereClause = "id = @Id"; var validContext = GetValidContext(); validContext.RegisterModelDescription(SqlModelDescription <TypeC> .Auto(schema, table)); var command = validContext.DeleteCommand <TypeC>(whereClause); command.Should().BeEquivalentTo($"DELETE FROM [{schema}].[{table}] WHERE {whereClause};"); }
public static SqlModelDescription <BankAccount> BankAccount() { return(SqlModelDescription <BankAccount> .Auto("core", "bankAccounts")); }
public static SqlModelDescription <Transaction> Transaction() { return(SqlModelDescription <Transaction> .Auto("core", "transactions")); }
public static SqlModelDescription <User> User() { return(SqlModelDescription <User> .Auto("core", "users") .WithReadOnly(u => u.UserName)); }
public void Auto_Ignores_ReadOnly_Properties() { var description = SqlModelDescription <Cat> .Auto("schema", "cats"); description.Property(p => p.IsGrumpy).Should().BeNull(); }
public static SqlModelDescription <Group> Group() { return(SqlModelDescription <Group> .Auto("core", "groups")); }
public static SqlModelDescription <Category> Category() { return(SqlModelDescription <Category> .Auto("core", "categories")); }
public void GetProperty_Finds_Property() { var description = SqlModelDescription <Cat> .Auto("core", "cats"); description.Property(p => p.Name).Should().NotBeNull(); }
public void Auto_Registers_Simple_Property() { var description = SqlModelDescription <Cat> .Auto("core", "cats"); description.Property(c => c.Title).Should().NotBeNull(); }