public void ThrowWhenParametersAreInvalid() { var config = new TypeMatcherConfiguration(); Action match = () => this.TypeMatcher.Match(config, this.Fixture.ClassDefinition); match.Should().Throw <Exception>().WithMessage("FullNameIn type expect an array of names."); }
protected override bool IsMatch(TypeMatcherConfiguration configuration, ObjectDefinitionBase objectDefinition) { if (configuration.Parameters.Length == 0) throw new Exception("NameIn type expect an array of names."); return configuration.Parameters.Contains(objectDefinition.Name); }
public void ShouldNotMatchIfStringIsSuffixOfClassNamespace() { var config = new TypeMatcherConfiguration { Parameters = new[] { "Testing.EndsWith" } }; this.TypeMatcher.Match(config, this.Fixture.ClassDefinition).Should().BeFalse("NamespaceEndsWithTypeMatcher must return False if param is not suffix of TestClass namespace"); }
public void ShouldMatchIfStringIsPrefixOfFullName() { var config = new TypeMatcherConfiguration { Parameters = new[] { this.Fixture.ClassDefinition.FullName.Substring(0, this.Fixture.ClassDefinition.FullName.Length / 2) } }; this.TypeMatcher.Match(config, this.Fixture.ClassDefinition).Should().BeTrue("FullNameStartsWithTypeMatcher must return True if param is prefix of TestClass full name"); }
public void ShouldNotMatchIfStringIsContainedInsideName() { var config = new TypeMatcherConfiguration { Parameters = new[] { "Testing.Contains" } }; this.TypeMatcher.Match(config, this.Fixture.ClassDefinition).Should().BeFalse("NameContainsTypeMatcher must return True if param is a substring of TestClass name"); }
public void ShouldNotMatchIfClassNameIsNotInParameterList() { var config = new TypeMatcherConfiguration { Parameters = new[] { "FakeName1", "FakeName2" } }; this.TypeMatcher.Match(config, this.Fixture.ClassDefinition).Should().BeFalse("Must return True only when objectDefinition's name is in params"); }
public void MatchNonExistantParam() { var config = new TypeMatcherConfiguration { Parameters = new[] { "Testing.Contains" } }; this.TypeMatcher.Match(config, this.Fixture.ClassDefinition).Should().BeFalse("ContainsAttributeTypeMatcher must return True if param contains an attribute of TestClass"); }
public void ShouldMatchIfStringIsSuffixOfClassNamespace() { var config = new TypeMatcherConfiguration { Parameters = new[] { this.Fixture.ClassDefinition.Namespace.Substring(this.Fixture.ClassDefinition.Namespace.Length / 2) } }; this.TypeMatcher.Match(config, this.Fixture.ClassDefinition).Should().BeTrue("NamespaceEndsWithTypeMatcher must return True if param is suffix of TestClass namespace"); }
public void ShouldMatchIfStringEqualsToClassNamespace() { var config = new TypeMatcherConfiguration { Parameters = new[] { this.Fixture.ClassDefinition.Namespace } }; this.TypeMatcher.Match(config, this.Fixture.ClassDefinition).Should().BeTrue("Must return False only when objectDefinition's namespace is not in params"); }
public void MatchExistantParam() { var config = new TypeMatcherConfiguration { Parameters = new[] { this.Fixture.ClassDefinition.Attributes[0].Name } }; this.TypeMatcher.Match(config, this.Fixture.ClassDefinition).Should().BeTrue("ContainsAttributeTypeMatcher must return False if param does not contains an attribute of TestClass"); }
public void ShouldMatchIfClassFullnameIsInParameterList() { var config = new TypeMatcherConfiguration { Parameters = new[] { this.Fixture.ClassDefinition.FullName, "FakeName2" } }; this.TypeMatcher.Match(config, this.Fixture.ClassDefinition).Should().BeTrue("Must return False only when objectDefinition's full name is not in params"); }
public void ShouldNotMatchIfStringEqualsToClassNamespace() { var config = new TypeMatcherConfiguration { Parameters = new[] { "FakeName1" } }; this.TypeMatcher.Match(config, this.Fixture.ClassDefinition).Should().BeFalse("Must return True only when objectDefinition's namespace is the only params"); }
public void ShouldNotMatchIfStringIsNotPrefixOfFullName() { var config = new TypeMatcherConfiguration { Parameters = new[] { "Testing.StartsWith" } }; this.TypeMatcher.Match(config, this.Fixture.ClassDefinition).Should().BeFalse("FullNameStartsWithTypeMatcher must return False if param is not prefix of TestClass full name"); }
protected override bool IsMatch(TypeMatcherConfiguration configuration, ObjectDefinitionBase objectDefinition) { if (configuration.Parameters.Length < 1) { throw new Exception("NameEndsWith type matcher needs at least 1 parameter."); } return(configuration.Parameters.Aggregate(false, (current, parameter) => current || objectDefinition.Name.EndsWith(parameter))); }
protected override bool IsMatch(TypeMatcherConfiguration configuration, ObjectDefinitionBase objectDefinition) { if (configuration.Parameters.Length != 0) { throw new Exception("Is Struct type matcher hasn't any arguments."); } return(objectDefinition.GetType() == typeof(StructDefinition)); }
public void ThrowWhenParametersAreInvalid(string[] param) { var config = new TypeMatcherConfiguration { Parameters = param }; Action match = () => this.TypeMatcher.Match(config, this.Fixture.ClassDefinition); match.Should().Throw <Exception>().WithMessage("Contains attribute type matcher has only 1 argument, the string to be found."); }
public bool Match(TypeMatcherConfiguration configuration, ObjectDefinitionBase objectDefinition) { if (configuration.Negate) { return(!this.IsMatch(configuration, objectDefinition)); } return(this.IsMatch(configuration, objectDefinition)); }
protected override bool IsMatch(TypeMatcherConfiguration configuration, ObjectDefinitionBase objectDefinition) { if (configuration.Parameters.Length != 1) { throw new Exception("Contains attribute type matcher has only 1 argument, the string to be found."); } return(objectDefinition.Attributes.Any(x => x.Name == configuration.Parameters[0])); }
public void ThrowWhenParametersAreInvalid(string[] param) { var config = new TypeMatcherConfiguration { Parameters = param }; Action match = () => this.TypeMatcher.Match(config, this.Fixture.ClassDefinition); match.Should().Throw <Exception>().WithMessage("FullNameStartsWith type matcher needs at least 1 parameter."); }
protected override bool IsMatch(TypeMatcherConfiguration configuration, ObjectDefinitionBase objectDefinition) { if (configuration.Parameters.Length != 1) { throw new Exception("FullNameEquals type matcher has only 1 argument, the string to be found."); } return(objectDefinition.FullName.Equals(configuration.Parameters[0])); }
public void ThrowWhenParametersAreInvalid() { var config = new TypeMatcherConfiguration { Parameters = new[] { "Param1", "Param2" } }; Action match = () => this.TypeMatcher.Match(config, this.ClassDefinition); match.Should().Throw <Exception>().WithMessage("Is Class type matcher hasn't any arguments."); }
public void ShouldMatchIfStringIsContainedInsideName() { var quaterLenght = this.Fixture.ClassDefinition.Name.Length / 4; var halfLenght = this.Fixture.ClassDefinition.Name.Length / 2; var config = new TypeMatcherConfiguration { Parameters = new[] { this.Fixture.ClassDefinition.Name.Substring(halfLenght - quaterLenght, halfLenght + quaterLenght) } }; this.TypeMatcher.Match(config, this.Fixture.ClassDefinition).Should().BeTrue("NameContainsTypeMatcher must return False if param is not a substring of TestClass name"); }
public void ShouldMatchIfStringIsSuperClassOfClass() { var classDefinition = this.Fixture.ClassProvider.Process(this.Fixture.ClassProvider.GetFromSource(typeof(TestClassExtends)), this.Fixture.ObjectDefinitions, typeof(TestClassExtends)) as ClassDefinition; classDefinition.Should().NotBeNull(); var config = new TypeMatcherConfiguration { Parameters = new[] { "TestClass" } }; this.TypeMatcher.Match(config, classDefinition).Should().BeTrue("InheritsFromTypeMatcher must return True if param is basetype of TestClassExtends"); }
protected abstract bool IsMatch(TypeMatcherConfiguration configuration, ObjectDefinitionBase objectDefinition);
public void ShouldMatchIfProcessedObjectIsAClassDefinition() { var config = new TypeMatcherConfiguration(); this.TypeMatcher.Match(config, this.ClassDefinition).Should().BeTrue("Must return False when objectDefinition is not ClassDefinition"); }
public void ShouldMatchIfProcessedStructIsAnArray() { var config = new TypeMatcherConfiguration(); this.TypeMatcher.Match(config, this.ArrayDefinition).Should().BeTrue("Must return False only when objectDefinition.IsArray is False"); }
public void ShouldNotMatchIfProcessedStructIsNotAnArray() { var config = new TypeMatcherConfiguration(); this.TypeMatcher.Match(config, new EnumDefinition()).Should().BeFalse("Must return True only when objectDefinition.IsArray is True"); }
public void ShouldNotMatchIfProcessedObjectIsNotAClassDefinition() { var config = new TypeMatcherConfiguration(); this.TypeMatcher.Match(config, new StructDefinition()).Should().BeFalse("Must return True only when objectDefinition is ClassDefinition"); }