Exemple #1
0
        public void GetSystemUnderTest_ScalarXmlIsQuery_IScalarResolver()
        {
            var sutXmlStubFactory   = new Mock <Systems.ScalarXml>();
            var queryXmlStubFactory = new Mock <QueryScalarXml>();

            queryXmlStubFactory.SetupGet(q => q.InlineQuery).Returns("select 0.78");
            queryXmlStubFactory.Setup(i => i.Settings).Returns(SettingsXml.Empty);
            sutXmlStubFactory.Setup(s => s.BaseItem).Returns(queryXmlStubFactory.Object);
            var sutXml = sutXmlStubFactory.Object;

            sutXml.Query = queryXmlStubFactory.Object;

            var ctrXmlStubFactory = new Mock <ScoreXml>();

            ctrXmlStubFactory.SetupGet(i => i.Threshold).Returns(0.75m);
            var ctrXml = ctrXmlStubFactory.Object;

            var builder = new ScalarScoreBuilder();

            builder.Setup(sutXml, ctrXml, null, null, new ServiceLocator());
            builder.Build();
            var sut = builder.GetSystemUnderTest();

            Assert.That(sut, Is.Not.Null);
            Assert.That(sut, Is.InstanceOf <IScalarResolver <decimal> >());
            Assert.That(sut, Is.InstanceOf <QueryScalarResolver <decimal> >());
        }
Exemple #2
0
        public void GetConstraint_BuildWithScalar_CorrectConstraint()
        {
            var sutXmlStubFactory   = new Mock <Systems.ScalarXml>();
            var queryXmlStubFactory = new Mock <QueryScalarXml>();

            queryXmlStubFactory.SetupGet(q => q.InlineQuery).Returns("select 0.78");
            queryXmlStubFactory.Setup(i => i.Settings).Returns(SettingsXml.Empty);
            sutXmlStubFactory.Setup(s => s.BaseItem).Returns(queryXmlStubFactory.Object);
            var sutXml = sutXmlStubFactory.Object;

            sutXml.Query = queryXmlStubFactory.Object;

            var ctrXml = new ScoreXml()
            {
                Threshold = 0.75m
            };

            var builder = new ScalarScoreBuilder();

            builder.Setup(sutXml, ctrXml, null, null, new ServiceLocator());
            builder.Build();
            var ctr = builder.GetConstraint();

            Assert.That(ctr, Is.InstanceOf <ScoreConstraint>());
        }