public void ConvertToSpecification_from_const_initialises_label_names_with_resolved_values([Frozen] IResolvesValue resolver, HasLabelConversionStrategy sut, string inputValue, string resolvedValue) { // Arrange Mock.Get(resolver) .Setup(x => x.Resolve <string>(It.IsAny <Value>())) .Returns(resolvedValue); var criterion = Criterion.FromElementPredicateAndConstantValue("label", "=", inputValue); // Act var result = sut.ConvertToSpecification(criterion); // Assert Assert.That((result as HasLabel)?.LabelNames, Is.EqualTo(new [] { resolvedValue })); }
public void ConvertToSpecification_from_func_initialises_label_names_with_resolved_values([Frozen] IResolvesValue resolver, HasLabelConversionStrategy 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", "hasanyof", paramValues); // Act var result = sut.ConvertToSpecification(criterion); // Assert Assert.That((result as HasLabel)?.LabelNames, Is.EqualTo(resolvedValues)); }
public void ConvertToSpecification_from_const_returns_instance_of_spec([Frozen] IResolvesValue resolver, HasLabelConversionStrategy sut, string inputValue, string resolvedValue) { // Arrange Mock.Get(resolver) .Setup(x => x.Resolve <string>(It.IsAny <Value>())) .Returns(resolvedValue); var criterion = Criterion.FromElementPredicateAndConstantValue("label", "=", inputValue); // Act var result = sut.ConvertToSpecification(criterion); // Assert Assert.That(result, Is.Not.Null); Assert.That(result, Is.InstanceOf <HasLabel>()); }
public void ConvertToSpecification_from_const_resolves_value_using_resolver([Frozen] IResolvesValue resolver, HasLabelConversionStrategy sut, string inputValue, string resolvedValue) { // Arrange Mock.Get(resolver) .Setup(x => x.Resolve <string>(It.IsAny <Value>())) .Returns(resolvedValue); var criterion = Criterion.FromElementPredicateAndConstantValue("label", "=", inputValue); var expectedParam = ConstantValue.FromConstant(inputValue); // Act sut.ConvertToSpecification(criterion); // Assert Mock.Get(resolver).Verify(x => x.Resolve <string>(expectedParam), Times.Once); }
public void ConvertToSpecification_from_func_returns_instance_of_spec([Frozen] IResolvesValue resolver, HasLabelConversionStrategy 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", "hasanyof", paramValues); // Act var result = sut.ConvertToSpecification(criterion); // Assert Assert.That(result, Is.Not.Null); Assert.That(result, Is.InstanceOf <HasLabel>()); }
public void ConvertToSpecification_from_func_resolves_all_values_using_resolver([Frozen] IResolvesValue resolver, HasLabelConversionStrategy sut, string[] resolvedValues) { // Arrange Mock.Get(resolver) .Setup(x => x.ResolveAll <string>(It.IsAny <IList <Value> >())) .Returns(resolvedValues); var criterion = Criterion.FromElementAndPredicateFunctionWithConstantValues("labels", "hasanyof", "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); }