public virtual void CastingToAnotherTypeShouldBeTranslated()
        {
            var action = new OnInsertTriggerCondition <User>(user => (decimal)user.Role > 50m);
            var sql    = action.BuildSql(_provider);

            Assert.Equal("CAST(NEW.Role AS DECIMAL) > 50", sql);
        }
        public virtual void Entity_NotExistsInDbContext_ShouldThrowException()
        {
            var action = new OnInsertTriggerCondition <User>(user => user.Role == UserRole.Admin);
            var ex     = Assert.Throws <InvalidOperationException>(() => action.BuildSql(_provider));

            Assert.Equal("DbSet<User> should be added to the DbContext", ex.Message);
        }
        public virtual void CastingToSameTypeShouldBeIgnored()
        {
            var action = new OnInsertTriggerCondition <User>(user => user.Role > UserRole.Admin);
            var sql    = action.BuildSql(_provider);

            Assert.Equal("NEW.Role > 999", sql);
        }
Exemple #4
0
        public virtual void Provider_ShouldUseCustomConverter_WhenItProvidedForFunction()
        {
            _provider.Converters.ExpressionCallConverters.Push(new CustomStringToUpperConverter());

            var action = new OnInsertTriggerCondition <Transaction>(t => t.Description.ToUpper() == "ABC");
            var sql    = action.BuildSql(_provider);

            Assert.Equal("test = 'ABC'", sql);
        }