Example #1
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 }));
        }
Example #2
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));
        }
Example #3
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>());
        }
Example #4
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);
        }
Example #5
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>());
        }
Example #6
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);
        }