Beispiel #1
0
        public void GetMetadata_returns_metadata_which_does_not_match_a_criterion_with_no_parameters()
        {
            // Arrange
            var criterion = Criterion.FromElementAndPredicateFunctionWithConstantValues("sprint", "isanyof");
            var sut       = IsInSprintConversionStrategy.GetMetadata();

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

            // Assert
            Assert.That(result, Is.False);
        }
Beispiel #2
0
        public void GetMetadata_returns_metadata_which_does_not_match_a_criterion_for_the_predicate_function_hasallof()
        {
            // Arrange
            var criterion = Criterion.FromElementAndPredicateFunctionWithConstantValues("sprint", "hasallof", "one", "two");
            var sut       = IsInSprintConversionStrategy.GetMetadata();

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

            // Assert
            Assert.That(result, Is.False);
        }
Beispiel #3
0
        public void GetMetadata_returns_metadata_which_matches_a_criterion_for_sprint_isanyof_some_parameters()
        {
            // Arrange
            var criterion = Criterion.FromElementAndPredicateFunctionWithConstantValues("sprint", "isanyof", "one", "two");
            var sut       = IsInSprintConversionStrategy.GetMetadata();

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

            // Assert
            Assert.That(result, Is.True);
        }
Beispiel #4
0
        public void GetMetadata_returns_metadata_which_matches_a_criterion_for_sprint_equals_a_constant()
        {
            // Arrange
            var criterion = Criterion.FromElementPredicateAndConstantValue("sprint", "=", "one");
            var sut       = IsInSprintConversionStrategy.GetMetadata();

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

            // Assert
            Assert.That(result, Is.True);
        }
Beispiel #5
0
        public void ConvertToSpecification_from_const_returns_instance_of_spec([Frozen] IResolvesValue resolver,
                                                                               IsInSprintConversionStrategy sut,
                                                                               string inputValue,
                                                                               string resolvedValue)
        {
            // Arrange
            Mock.Get(resolver)
            .Setup(x => x.Resolve <string>(It.IsAny <Value>()))
            .Returns(resolvedValue);
            var criterion = Criterion.FromElementPredicateAndConstantValue("sprint", "=", inputValue);

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

            // Assert
            Assert.That(result, Is.Not.Null);
            Assert.That(result, Is.InstanceOf <HasSprint>());
        }
Beispiel #6
0
        public void ConvertToSpecification_from_const_resolves_value_using_resolver([Frozen] IResolvesValue resolver,
                                                                                    IsInSprintConversionStrategy sut,
                                                                                    string inputValue,
                                                                                    string resolvedValue)
        {
            // Arrange
            Mock.Get(resolver)
            .Setup(x => x.Resolve <string>(It.IsAny <Value>()))
            .Returns(resolvedValue);
            var criterion     = Criterion.FromElementPredicateAndConstantValue("sprint", "=", inputValue);
            var expectedParam = ConstantValue.FromConstant(inputValue);

            // Act
            sut.ConvertToSpecification(criterion);

            // Assert
            Mock.Get(resolver).Verify(x => x.Resolve <string>(expectedParam), Times.Once);
        }
Beispiel #7
0
        public void ConvertToSpecification_from_func_returns_instance_of_spec([Frozen] IResolvesValue resolver,
                                                                              IsInSprintConversionStrategy sut,
                                                                              string[] paramValues,
                                                                              string[] resolvedValues)
        {
            // Arrange
            Mock.Get(resolver)
            .Setup(x => x.ResolveAll <string>(It.IsAny <IList <Value> >()))
            .Returns(resolvedValues);
            var criterion = Criterion.FromElementAndPredicateFunctionWithConstantValues("sprint", "isanyof", paramValues);

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

            // Assert
            Assert.That(result, Is.Not.Null);
            Assert.That(result, Is.InstanceOf <HasSprint>());
        }
Beispiel #8
0
        public void ConvertToSpecification_from_func_resolves_all_values_using_resolver([Frozen] IResolvesValue resolver,
                                                                                        IsInSprintConversionStrategy sut,
                                                                                        string[] resolvedValues)
        {
            // Arrange
            Mock.Get(resolver)
            .Setup(x => x.ResolveAll <string>(It.IsAny <IList <Value> >()))
            .Returns(resolvedValues);
            var criterion      = Criterion.FromElementAndPredicateFunctionWithConstantValues("sprint", "isanyof", "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);
        }
Beispiel #9
0
        public void ConvertToSpecification_from_const_initialises_sprint_names_with_resolved_values([Frozen] IResolvesValue resolver,
                                                                                                    IsInSprintConversionStrategy sut,
                                                                                                    string inputValue,
                                                                                                    string resolvedValue)
        {
            // Arrange
            Mock.Get(resolver)
            .Setup(x => x.Resolve <string>(It.IsAny <Value>()))
            .Returns(resolvedValue);
            var criterion = Criterion.FromElementPredicateAndConstantValue("sprint", "=", inputValue);

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

            // Assert
            Assert.That((result as HasSprint)?.SprintNames, Is.EqualTo(new [] { resolvedValue }));
        }
Beispiel #10
0
        public void ConvertToSpecification_from_func_initialises_sprint_names_with_resolved_values([Frozen] IResolvesValue resolver,
                                                                                                   IsInSprintConversionStrategy sut,
                                                                                                   string[] paramValues,
                                                                                                   string[] resolvedValues)
        {
            // Arrange
            Mock.Get(resolver)
            .Setup(x => x.ResolveAll <string>(It.IsAny <IList <Value> >()))
            .Returns(resolvedValues);
            var criterion = Criterion.FromElementAndPredicateFunctionWithConstantValues("sprint", "isanyof", paramValues);

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

            // Assert
            Assert.That((result as HasSprint)?.SprintNames, Is.EqualTo(resolvedValues));
        }