Ejemplo n.º 1
0
        public void Insert_ShouldConstructInsertStatementFromAnotherOrmType()
        {
            // Arrange:
            const string Expected = "insert into AnotherOrmType(Name) values(@Name)";
            var anotherOrmType = new AnotherOrmType
            {
                Id = 1,
                Name = "AnotherOrmType",
                OrmType = new OrmType()
            };

            // Act:
            var statement = SqlBuilder.Insert(anotherOrmType);

            // Assert:
            statement.Sql.Should().Be.EqualTo(Expected);
        }
Ejemplo n.º 2
0
        public void Update_ShouldHaveParameterWhenStatementHaveRestrictions()
        {
            // Arrange:
            var anotherOrmType = new AnotherOrmType
            {
                Id = 1,
                Name = "AnotherOrmType",
                OrmType = new OrmType()
            };

            // Act:
            var statement = SqlBuilder.Update(anotherOrmType).Where(a => a.Id).Equal(1);
            var parameters = statement.Parameters;

            // Assert:
            parameters.Length.Should().Be.EqualTo(2);
        }
Ejemplo n.º 3
0
        public void Update_ShouldConstructUpdateStatementFromAnotherOrmType()
        {
            // Arrange:
            var anotherOrmType = new AnotherOrmType
            {
                Id = 1,
                Name = "AnotherOrmType",
                OrmType = new OrmType()
            };
            const string expected = "update AnotherOrmType set Name = @Name where Id = @IdEq";

            // Act:
            var statement = SqlBuilder.Update(anotherOrmType).Where(a => a.Id).Equal(1);

            // Assert:
            statement.Sql.Should().Be.EqualTo(expected);
        }
Ejemplo n.º 4
0
        public void Insert_ShouldHaveParametersWhenBuildStatement()
        {
            // Arrange:
            var anotherOrmType = new AnotherOrmType
            {
                Id = 1,
                Name = "AnotherOrmType",
                OrmType = new OrmType()
            };

            // Act:
            var statement = SqlBuilder.Insert(anotherOrmType);
            var parameters = statement.Parameters;

            // Assert:
            parameters.Length.Should().Be.EqualTo(1);
            parameters[0].Column.Should().Be.EqualTo("@Name");
            parameters[0].Value.Should().Be.EqualTo(anotherOrmType.Name);
        }
Ejemplo n.º 5
0
        public void Update_ShouldHaveParameterWhenStatementDontHaveRestrictions()
        {
            // Arrange:
            var anotherOrmType = new AnotherOrmType
            {
                Id = 1,
                Name = "AnotherOrmType",
                OrmType = new OrmType()
            };

            // Act:
            var statement = SqlBuilder.Update(anotherOrmType);
            var parameters = statement.Parameters;

            // Assert:
            parameters.Length.Should().Be.EqualTo(1);
            parameters[0].Column.Should().Be.EqualTo("@Name");
            parameters[0].Value.Should().Be.EqualTo(anotherOrmType.Name);
        }