<commit_before>﻿using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;

namespace NHibernate.Test.NHSpecificTest.NH1192
{
	[TestFixture]
	public class Fixture:BugTestCase
	{
		protected override void OnSetUp()
		{
			using(var session=this.OpenSession())
			using(var tran=session.BeginTransaction())
			{
				session.Save(new ObjectA {FontType = Status.Bold|Status.Italic, Name = "Object1"});
				session.Save(new ObjectA { FontType = Status.Italic, Name = "Object2" });
				session.Save(new ObjectA { FontType = Status.Underlined, Name = "Object2" });
				tran.Commit();
			}
		}
		protected override void OnTearDown()
		{
			using (var session = this.OpenSession())
			using (var tran = session.BeginTransaction())
			{
				session.Delete("from ObjectA");
				tran.Commit();
			}
		}

		[Test]
		public void BitwiseAndWorksCorrectly()
		{
			using (var session = this.OpenSession())
			using (var tran = session.BeginTransaction())
			{
				var query = session.CreateQuery("from ObjectA o where (o.FontType & 1) > 0");
				var result = query.List();
				Assert.That(result,Has.Count.EqualTo(1));
				query = session.CreateQuery("from ObjectA o where (o.FontType & 2) > 0");
				result = query.List();
				Assert.That(result, Has.Count.EqualTo(2));

				query = session.CreateQuery("from ObjectA o where (o.FontType & 4) > 0");
				result = query.List();
				Assert.That(result, Has.Count.EqualTo(1));
			}
		}

		[Test]
		public void BitwiseOrWorksCorrectly()
		{
			using (var session = this.OpenSession())
			using (var tran = session.BeginTransaction())
			{
				var query = session.CreateQuery("from ObjectA o where (o.FontType | 2)  = (1|2) ");
				var result = query.List();
				Assert.That(result, Has.Count.EqualTo(1));
			}
		}
	}
}<commit_msg>NH-1192 - Ignore tests for Oracle as it does not support &, |, ^ as bitwise operators.<commit_after>﻿using NHibernate.Dialect;
using NUnit.Framework;

namespace NHibernate.Test.NHSpecificTest.NH1192
{
	[TestFixture]
	public class Fixture : BugTestCase
	{
		protected override bool AppliesTo(Dialect.Dialect dialect)
		{
			return !(dialect is Oracle8iDialect);
		}

		protected override void OnSetUp()
		{
			using (var session = OpenSession())
			using (var transaction = session.BeginTransaction())
			{
				session.Save(new ObjectA { FontType = Status.Bold | Status.Italic, Name = "Object1" });
				session.Save(new ObjectA { FontType = Status.Italic, Name = "Object2" });
				session.Save(new ObjectA { FontType = Status.Underlined, Name = "Object2" });
				transaction.Commit();
			}
		}

		protected override void OnTearDown()
		{
			using (var session = OpenSession())
			using (var transaction = session.BeginTransaction())
			{
				session.Delete("from ObjectA");
				transaction.Commit();
			}
		}

		[Test]
		public void BitwiseAndWorksCorrectly()
		{
			using (var session = OpenSession())
			using (session.BeginTransaction())
			{
				var query = session.CreateQuery("from ObjectA o where (o.FontType & 1) > 0");
				var result = query.List();
				
				Assert.That(result, Has.Count.EqualTo(1));
				query = session.CreateQuery("from ObjectA o where (o.FontType & 2) > 0");
				result = query.List();
				Assert.That(result, Has.Count.EqualTo(2));

				query = session.CreateQuery("from ObjectA o where (o.FontType & 4) > 0");
				result = query.List();
				Assert.That(result, Has.Count.EqualTo(1));
			}
		}

		[Test]
		public void BitwiseOrWorksCorrectly()
		{
			using (var session = OpenSession())
			using (session.BeginTransaction())
			{
				var query = session.CreateQuery("from ObjectA o where (o.FontType | 2)  = (1|2) ");
				var result = query.List();
				Assert.That(result, Has.Count.EqualTo(1));
			}
		}
	}
}
{'fraction_non_alphanumeric': 0.13967828418230563, 'fraction_numerical': 0.012064343163538873, 'mean_word_length': 3.5334143377885785, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '4327887', 'n_tokens_mistral': 1462, 'n_tokens_neox': 1210, 'n_words': 282}