
using Gallio.Tests;

using Gallio.Model.Filters;
using Gallio.Model;
using MbUnit.Framework;
using Rhino.Mocks;

namespace Gallio.Tests.Model.Filters
{
    [TestFixture]
    [TestsOn(typeof(IdFilter<ITestDescriptor>))]
    public class IdFilterTest : BaseTestWithMocks
    {
        [Test]
        [Row(true, "expectedValue")]
        [Row(false, "otherValue")]
        public void IsMatchCombinations(bool expectedMatch, string value)
        {
            ITestDescriptor component = Mocks.StrictMock<ITestDescriptor>();
            SetupResult.For(component.Id).Return(value);
            Mocks.ReplayAll();

            Assert.AreEqual(expectedMatch,
                new IdFilter<ITestDescriptor>(new EqualityFilter<string>("expectedValue")).IsMatch(component));
        }

        [Test]
        [Row("")]
        [Row("id1212")]
        public void ToStringTest(string id)
        {
            Filter<ITestDescriptor> filter = new IdFilter<ITestDescriptor>(new EqualityFilter<string>(id));
            Assert.AreEqual("Id(Equality('" + id + "'))", filter.ToString());
        }
    }
}