Пример #1
0
        public void ConvertToSpecification_initialises_label_names_with_resolved_values([Frozen] IResolvesValue resolver,
                                                                                        HasAllLabelsConversionStrategy sut,
                                                                                        string[] paramValues,
                                                                                        string[] resolvedValues)
        {
            // Arrange
            Mock.Get(resolver)
            .Setup(x => x.ResolveAll <string>(It.IsAny <IList <Value> >()))
            .Returns(resolvedValues);
            var criterion = Criterion.FromElementAndPredicateFunctionWithConstantValues("labels", "hasallof", paramValues);

            // Act
            var result = sut.ConvertToSpecification(criterion);

            // Assert
            Assert.That((result as HasAllLabels)?.LabelNames, Is.EqualTo(resolvedValues));
        }
Пример #2
0
        public void ConvertToSpecification_returns_instance_of_spec([Frozen] IResolvesValue resolver,
                                                                    HasAllLabelsConversionStrategy sut,
                                                                    string[] paramValues,
                                                                    string[] resolvedValues)
        {
            // Arrange
            Mock.Get(resolver)
            .Setup(x => x.ResolveAll <string>(It.IsAny <IList <Value> >()))
            .Returns(resolvedValues);
            var criterion = Criterion.FromElementAndPredicateFunctionWithConstantValues("labels", "hasallof", paramValues);

            // Act
            var result = sut.ConvertToSpecification(criterion);

            // Assert
            Assert.That(result, Is.Not.Null);
            Assert.That(result, Is.InstanceOf <HasAllLabels>());
        }
Пример #3
0
        public void ConvertToSpecification_resolves_all_values_using_resolver([Frozen] IResolvesValue resolver,
                                                                              HasAllLabelsConversionStrategy sut,
                                                                              string[] resolvedValues)
        {
            // Arrange
            Mock.Get(resolver)
            .Setup(x => x.ResolveAll <string>(It.IsAny <IList <Value> >()))
            .Returns(resolvedValues);
            var criterion      = Criterion.FromElementAndPredicateFunctionWithConstantValues("labels", "hasallof", "one", "two");
            var expectedParams = new [] {
                ConstantValue.FromConstant("one"),
                ConstantValue.FromConstant("two"),
            }
            .Cast <Value>()
            .ToList();

            // Act
            sut.ConvertToSpecification(criterion);

            // Assert
            Mock.Get(resolver).Verify(x => x.ResolveAll <string>(It.Is <IList <Value> >(l => new SetEqualityComparer <Value>().Equals(l, expectedParams))), Times.Once);
        }