<commit_before>﻿using System;
using System.Linq;
using System.Linq.Expressions;
using NHibernate.DomainModel.Northwind.Entities;
using NUnit.Framework;

namespace NHibernate.Test.Linq
{
	[TestFixture]
	public class MathTests : LinqTestCase
	{
		private IQueryable<OrderLine> _orderLines;

		protected override void OnSetUp()
		{
			base.OnSetUp();
			_orderLines = db.OrderLines.Take(10).ToList().AsQueryable();
		}

		[Test]
		public void SignAllPositiveTest()
		{
			var signs = (from o in db.OrderLines
						 select Math.Sign(o.UnitPrice)).ToList();

			Assert.True(signs.All(x => x == 1));
		}

		[Test]
		public void SignAllNegativeTest()
		{
			var signs = (from o in db.OrderLines
						 select Math.Sign(-1*o.UnitPrice)).ToList();

			Assert.True(signs.All(x => x == -1));
		}

		[Test]
		public void SinTest()
		{
			Test(o => Math.Sin((double) o.UnitPrice));
		}

		[Test]
		public void CosTest()
		{
			Test(o => Math.Cos((double) o.UnitPrice));
		}
		
		[Test]
		public void TanTest()
		{
			Test(o => Math.Tan((double) o.UnitPrice));
		}

		[Test]
		public void SinhTest()
		{
			Test(o => Math.Sinh((double)o.UnitPrice));
		}

		[Test]
		public void CoshTest()
		{
			Test(o => Math.Cosh((double)o.UnitPrice));
		}

		[Test]
		public void TanhTest()
		{
			Test(o => Math.Tanh((double)o.UnitPrice));
		}

		[Test]
		public void AsinTest()
		{
			Test(o => Math.Asin((double) o.UnitPrice));
		}

		[Test]
		public void AcosTest()
		{
			Test(o => Math.Acos((double) o.UnitPrice));
		}
		
		[Test]
		public void AtanTest()
		{
			Test(o => Math.Atan((double) o.UnitPrice));
		}

		[Test]
		public void Atan2Test()
		{
			Test(o => Math.Atan2((double) o.UnitPrice, 0.5d));
		}

		private void Test<T>(Expression<Func<OrderLine, T>> selector)
		{
			var expected = _orderLines
				.Select(selector)
				.ToList();

			var actual = db.OrderLines.Select(selector)
				.Take(10)
				.ToList();

			Assert.AreEqual(actual, expected);
		}
	}
}
<commit_msg>Ignore linq math function tests are not supported by dialect<commit_after>﻿using System;
using System.Linq;
using System.Linq.Expressions;
using NHibernate.DomainModel.Northwind.Entities;
using NUnit.Framework;

namespace NHibernate.Test.Linq
{
	[TestFixture]
	public class MathTests : LinqTestCase
	{
		private IQueryable<OrderLine> _orderLines;
		
		private void IgnoreIfNotSupported(string function)
		{
			if (!Dialect.Functions.ContainsKey(function))
				Assert.Ignore("Dialect {0} does not support '{1}' function", Dialect.GetType(), function);
		}

		protected override void OnSetUp()
		{
			base.OnSetUp();
			_orderLines = db.OrderLines.Take(10).ToList().AsQueryable();
		}

		[Test]
		public void SignAllPositiveTest()
		{
			IgnoreIfNotSupported("sign");
			var signs = (from o in db.OrderLines
						 select Math.Sign(o.UnitPrice)).ToList();

			Assert.True(signs.All(x => x == 1));
		}

		[Test]
		public void SignAllNegativeTest()
		{
			IgnoreIfNotSupported("sign");
			var signs = (from o in db.OrderLines
						 select Math.Sign(-1*o.UnitPrice)).ToList();

			Assert.True(signs.All(x => x == -1));
		}

		[Test]
		public void SinTest()
		{
			IgnoreIfNotSupported("sin");
			Test(o => Math.Sin((double)o.UnitPrice));
		}

		[Test]
		public void CosTest()
		{
			IgnoreIfNotSupported("cos");
			Test(o => Math.Cos((double)o.UnitPrice));
		}

		[Test]
		public void TanTest()
		{
			IgnoreIfNotSupported("tan");
			Test(o => Math.Tan((double)o.Discount));
		}

		[Test]
		public void SinhTest()
		{
			IgnoreIfNotSupported("sinh");
			Test(o => Math.Sinh((double)o.Discount));
		}

		[Test]
		public void CoshTest()
		{
			IgnoreIfNotSupported("cosh");
			Test(o => Math.Cosh((double)o.Discount));
		}

		[Test]
		public void TanhTest()
		{
			IgnoreIfNotSupported("tanh");
			Test(o => Math.Tanh((double)o.Discount));
		}

		[Test]
		public void AsinTest()
		{
			IgnoreIfNotSupported("asin");
			Test(o => Math.Asin((double)o.Discount));
		}

		[Test]
		public void AcosTest()
		{
			IgnoreIfNotSupported("acos");
			Test(o => Math.Acos((double)o.Discount));
		}

		[Test]
		public void AtanTest()
		{
			IgnoreIfNotSupported("atan");
			Test(o => Math.Atan((double)o.UnitPrice));
		}

		[Test]
		public void Atan2Test()
		{
			IgnoreIfNotSupported("atan2");
			Test(o => Math.Atan2((double)o.Discount, 0.5d));
		}

		private void Test<T>(Expression<Func<OrderLine, T>> selector)
		{
			var expected = _orderLines
				.Select(selector)
				.ToList();

			var actual = db.OrderLines.Select(selector)
				.Take(10)
				.ToList();

			Assert.AreEqual(actual, expected);
		}
	}
}

{'fraction_non_alphanumeric': 0.1505735140771637, 'fraction_numerical': 0.005213764337851929, 'mean_word_length': 2.770440251572327, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3208394', 'n_tokens_mistral': 2036, 'n_tokens_neox': 1679, 'n_words': 313}