﻿namespace NSolrClient.Tests.Select.Filters
{
    using Moq;

    using NSolrClient.Selection.Filters;
    using  NSolrClient.ValueSerializers;

    using NUnit.Framework;

    [TestFixture()]
    public class AndOperatorTests
    {
        [Test]
        public void BuildTest()
        {
            Mock<IFilterBuilder> arg1 = new Mock<IFilterBuilder>();
            Mock<IFilterBuilder> arg2 = new Mock<IFilterBuilder>();
            Mock<IFilterBuilder> arg3 = new Mock<IFilterBuilder>();

            arg1.Setup(b => b.Build(It.IsAny<IValueSerializer>())).Returns("expr1");
            arg2.Setup(b => b.Build(It.IsAny<IValueSerializer>())).Returns("expr2");
            arg3.Setup(b => b.Build(It.IsAny<IValueSerializer>())).Returns("expr3");

            Assert.AreEqual("(expr1) AND (expr2)", new AndOperator(arg1.Object, arg2.Object).Build(null));
            Assert.AreEqual(
                "(expr1) AND (expr2) AND (expr3)", 
                new AndOperator(arg1.Object, arg2.Object, arg3.Object).Build(null));
        }
    }
}