Esempio n. 1
0
 public static SqlModelDescription <GroupUser> GroupUser()
 {
     return(SqlModelDescription <GroupUser>
            .Auto("core", "groupUsers")
            .WithPrimaryKey(p => p.GroupId)
            .WithPrimaryKey(p => p.UserId));
 }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
        public void RegisterModelScription_Can_Register_Single_ModelDescription()
        {
            var validContext = GetValidContext();

            validContext.RegisterModelDescription(SqlModelDescription <TypeA> .Auto("schema", "typeA"));

            validContext.GetModelDescription <TypeA>().Should().NotBeNull();
        }
Esempio n. 4
0
        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")));
        }
Esempio n. 5
0
        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;");
        }
Esempio n. 6
0
        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);");
        }
Esempio n. 7
0
        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};");
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        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};");
        }
Esempio n. 10
0
 public static SqlModelDescription <BankAccount> BankAccount()
 {
     return(SqlModelDescription <BankAccount>
            .Auto("core", "bankAccounts"));
 }
Esempio n. 11
0
 public static SqlModelDescription <Transaction> Transaction()
 {
     return(SqlModelDescription <Transaction>
            .Auto("core", "transactions"));
 }
Esempio n. 12
0
 public static SqlModelDescription <User> User()
 {
     return(SqlModelDescription <User>
            .Auto("core", "users")
            .WithReadOnly(u => u.UserName));
 }
Esempio n. 13
0
        public void Auto_Ignores_ReadOnly_Properties()
        {
            var description = SqlModelDescription <Cat> .Auto("schema", "cats");

            description.Property(p => p.IsGrumpy).Should().BeNull();
        }
Esempio n. 14
0
 public static SqlModelDescription <Group> Group()
 {
     return(SqlModelDescription <Group>
            .Auto("core", "groups"));
 }
Esempio n. 15
0
 public static SqlModelDescription <Category> Category()
 {
     return(SqlModelDescription <Category>
            .Auto("core", "categories"));
 }
Esempio n. 16
0
        public void GetProperty_Finds_Property()
        {
            var description = SqlModelDescription <Cat> .Auto("core", "cats");

            description.Property(p => p.Name).Should().NotBeNull();
        }
Esempio n. 17
0
        public void Auto_Registers_Simple_Property()
        {
            var description = SqlModelDescription <Cat> .Auto("core", "cats");

            description.Property(c => c.Title).Should().NotBeNull();
        }