Exemplo n.º 1
0
        public void ContainsAllThrowsIfAccessed()
        {
            var set = new[] { 1, 2, 3 };
            var ex  = Assert.Throws <InvalidOperationException>(() => ElasticMethods.ContainsAll(set, set));

            Assert.Contains("ElasticMethods.ContainsAll", ex.Message);
        }
        public static void ContainsAll_ListFirst_CreatesTermsQuery()
        {
            var matchNames = new[] { "Robbie", "Kryten", "IG-88", "Marvin" };

            var where = Robots.Where(r => ElasticMethods.ContainsAll(matchNames, r.Aliases));
            var criteria = ElasticQueryTranslator.Translate(Mapping, "prefix", where.Expression).SearchRequest.Filter;

            var termsCriteria = Assert.IsType <TermsCriteria>(criteria);

            Assert.Equal("prefix.aliases", termsCriteria.Field);
            Assert.Contains("Robbie", termsCriteria.Values);
            Assert.Contains("Kryten", termsCriteria.Values);
            Assert.Contains("IG-88", termsCriteria.Values);
            Assert.Contains("Marvin", termsCriteria.Values);
            Assert.Equal(TermsExecutionMode.and, termsCriteria.ExecutionMode);
        }