public void GivenASearchValue_WhenIsValidCompositeComponentIsCalled_ThenFalseShouldBeReturned()
        {
            var components = new ISearchValue[]
            {
                new StringSearchValue("abc"),
            };

            var value = new CompositeSearchValue(new[] { components });

            Assert.False(value.IsValidAsCompositeComponent);
        }
        public void GivenASearchValue_WhenToStringIsCalled_ThenCorrectStringShouldBeReturned()
        {
            var components = new ISearchValue[][]
            {
                new ISearchValue[]
                {
                    new TokenSearchValue("system1", "code1", "text1"),
                    new TokenSearchValue("system2", "code2", "text2"),
                },
                new ISearchValue[]
                {
                    new NumberSearchValue(123),
                    new NumberSearchValue(789),
                },
            };

            var value = new CompositeSearchValue(components);

            Assert.Equal("(system1|code1), (system2|code2) $ (123), (789)", value.ToString());
        }
예제 #3
0
        public void GivenACompositeSearchValue_WhenGenerated_ThenCorrectJObjectShouldBeCreated()
        {
            const string  system1  = "s1";
            const string  code1    = "s2";
            const string  text1    = "t1";
            const string  system2  = "s2";
            const string  code2    = "c2";
            const string  text2    = "T2";
            const decimal quantity = 123.5m;
            const string  system3  = "s3";
            const string  code3    = "c3";

            var value = new CompositeSearchValue(
                new[]
            {
                new ISearchValue[] { new TokenSearchValue(system1, code1, text1) },
                new ISearchValue[] { new TokenSearchValue(system2, code2, text2) },
                new ISearchValue[] { new QuantitySearchValue(system3, code3, quantity) },
            });

            var expectedValues = new[]
            {
                CreateTuple("s_0", system1),
                CreateTuple("c_0", code1),
                CreateTuple("s_1", system2),
                CreateTuple("c_1", code2),
                CreateTuple("s_2", system3),
                CreateTuple("c_2", code3),
                CreateTuple("q_2", quantity),
                CreateTuple("lq_2", quantity),
                CreateTuple("hq_2", quantity),
            };

            TestAndValidateOutput(
                "composite",
                value,
                expectedValues);
        }
예제 #4
0
        void ISearchValueVisitor.Visit(CompositeSearchValue composite)
        {
            foreach (IEnumerable <ISearchValue> componentValues in composite.Components.CartesianProduct())
            {
                int index = 0;

                CreateEntry();

                try
                {
                    foreach (ISearchValue componentValue in componentValues)
                    {
                        // Set the component index and process individual component of the composite value.
                        Index = index++;

                        componentValue.AcceptVisitor(this);
                    }
                }
                finally
                {
                    Index = null;
                }
            }
        }
 void ISearchValueVisitor.Visit(CompositeSearchValue composite)
 {
     // Composite search values will be broken down into individual components,
     // and therefore this method should not be called.
     throw new InvalidOperationException("The composite search value should have been broken down into components and handled individually.");
 }
 public void Visit(CompositeSearchValue composite)
 {
 }