public void TypeResolver_OnlyReturnsValidTagHelpersForAssemblyLookup() { // Arrange var tagHelperTypeResolver = new TestTagHelperTypeResolver(TestableTagHelpers); // Act var types = tagHelperTypeResolver.Resolve("Foo", SourceLocation.Zero, new ParserErrorSink()); // Assert Assert.Equal(ValidTestableTagHelpers, types); }
public void TypeResolver_ReturnsEmptyEnumerableIfNoValidTagHelpersFound() { // Arrange var tagHelperTypeResolver = new TestTagHelperTypeResolver(InvalidTestableTagHelpers); // Act var types = tagHelperTypeResolver.Resolve("Foo", SourceLocation.Zero, new ErrorSink()); // Assert Assert.Empty(types); }
public void TypeResolver_ReturnsEmptyEnumerableIfNoValidTagHelpersFound() { // Arrange var tagHelperTypeResolver = new TestTagHelperTypeResolver(InvalidTestableTagHelpers); // Act var types = tagHelperTypeResolver.Resolve("Foo"); // Assert Assert.Empty(types); }
public void TypeResolver_OnlyReturnsValidTagHelpersForAssemblyLookup() { // Arrange var tagHelperTypeResolver = new TestTagHelperTypeResolver(TestableTagHelpers); // Act var types = tagHelperTypeResolver.Resolve("Foo"); // Assert Assert.Equal(ValidTestableTagHelpers, types); }
public void TypeResolver_ResolveThrowsIfEmptyOrNullLookupText(string name) { // Arrange var tagHelperTypeResolver = new TestTagHelperTypeResolver(InvalidTestableTagHelpers); var expectedMessage = "Tag helper directive assembly name cannot be null or empty." + Environment.NewLine + "Parameter name: name"; // Act & Assert var ex = Assert.Throws <ArgumentException>(nameof(name), () => { tagHelperTypeResolver.Resolve(name); }); Assert.Equal(expectedMessage, ex.Message); }
public void TypeResolver_CreatesErrorIfNullOrEmptyAssmblyName_DoesNotThrow(string name) { // Arrange var tagHelperTypeResolver = new TestTagHelperTypeResolver(InvalidTestableTagHelpers); var errorSink = new ErrorSink(); var documentLocation = new SourceLocation(1, 2, 3); var expectedErrorMessage = "Tag helper directive assembly name cannot be null or empty."; // Act tagHelperTypeResolver.Resolve(name, documentLocation, errorSink); // Assert var error = Assert.Single(errorSink.Errors); Assert.Equal(1, error.Length); Assert.Equal(documentLocation, error.Location); Assert.Equal(expectedErrorMessage, error.Message); }
public void DescriptorResolver_IgnoresSpaces(string lookupText) { // Arrange var tagHelperTypeResolver = new TestTagHelperTypeResolver(TestableTagHelpers) { OnGetExportedTypes = (assemblyName) => { Assert.Equal("MyAssembly", assemblyName.Name); } }; var tagHelperDescriptorResolver = new TestTagHelperDescriptorResolver(tagHelperTypeResolver); // Act var descriptors = tagHelperDescriptorResolver.Resolve(lookupText); // Assert Assert.Empty(descriptors); }
public void TypeResolver_OnlyReturnsValidTagHelpersForAssemblyLookup() { // Arrange var tagHelperTypeResolver = new TestTagHelperTypeResolver(TestableTagHelpers); // Act var types = tagHelperTypeResolver.Resolve("Foo", SourceLocation.Zero, new ErrorSink()); // Assert Assert.Collection(types, type => { Assert.Equal(typeof(Valid_PlainTagHelper), type); }, type => { Assert.Equal(typeof(Valid_InheritedTagHelper), type); }); }
public void DescriptorResolver_IgnoresSpaces(string lookupText) { // Arrange var tagHelperTypeResolver = new TestTagHelperTypeResolver(TestableTagHelpers) { OnGetLibraryDefinedTypes = (assemblyName) => { Assert.Equal("MyAssembly", assemblyName.Name); } }; var tagHelperDescriptorResolver = new TagHelperDescriptorResolver(tagHelperTypeResolver); var expectedDescriptor = new TagHelperDescriptor("Valid_Plain", typeof(Valid_PlainTagHelper).FullName, ContentBehavior.None); // Act var descriptors = tagHelperDescriptorResolver.Resolve(lookupText); // Assert var descriptor = Assert.Single(descriptors); Assert.Equal(expectedDescriptor, descriptor, CompleteTagHelperDescriptorComparer.Default); }
public void DescriptorResolver_IgnoresSpaces(string lookupText) { // Arrange var invoked = false; var tagHelperTypeResolver = new TestTagHelperTypeResolver(TestableTagHelpers) { OnGetExportedTypes = (assemblyName) => { Assert.Equal(AssemblyName, assemblyName.Name); invoked = true; } }; var tagHelperDescriptorResolver = new TestTagHelperDescriptorResolver(tagHelperTypeResolver); // Act var descriptors = tagHelperDescriptorResolver.Resolve(lookupText); // Assert Assert.True(invoked); var descriptor = Assert.Single(descriptors); Assert.Equal(AssemblyName, descriptor.AssemblyName); Assert.Equal(typeof(Valid_PlainTagHelper).FullName, descriptor.TypeName); }