public void DefaultRazorDiagnostic_Equals()
        {
            // Arrange
            var descriptor = new RazorDiagnosticDescriptor("RZ0000", () => "this is an {0}", RazorDiagnosticSeverity.Error);
            var span       = new SourceSpan("test.cs", 15, 1, 8, 5);

            var diagnostic1 = new DefaultRazorDiagnostic(descriptor, span, new object[0]);
            var diagnostic2 = new DefaultRazorDiagnostic(descriptor, span, new object[0]);

            // Act
            var result = diagnostic1.Equals(diagnostic2);

            // Assert
            Assert.True(result);
        }
        public void DefaultRazorDiagnostic_HashCodesNotEqual_DifferentId()
        {
            // Arrange
            var descriptor1 = new RazorDiagnosticDescriptor("RZ0001", () => "this is an {0}", RazorDiagnosticSeverity.Error);
            var descriptor2 = new RazorDiagnosticDescriptor("RZ0002", () => "this is an {0}", RazorDiagnosticSeverity.Error);
            var span        = new SourceSpan("test.cs", 15, 1, 8, 5);

            var diagnostic1 = new DefaultRazorDiagnostic(descriptor1, span, new object[0]);
            var diagnostic2 = new DefaultRazorDiagnostic(descriptor2, span, new object[0]);

            // Act
            var result = diagnostic1.GetHashCode() == diagnostic2.GetHashCode();

            // Assert
            Assert.False(result);
        }
        public void DefaultRazorDiagnostic_NotEquals_DifferentLocation()
        {
            // Arrange
            var descriptor = new RazorDiagnosticDescriptor("RZ0000", () => "this is an {0}", RazorDiagnosticSeverity.Error);
            var span1      = new SourceSpan("test.cs", 15, 1, 8, 5);
            var span2      = new SourceSpan("test.cs", 15, 1, 8, 3);

            var diagnostic1 = new DefaultRazorDiagnostic(descriptor, span1, new object[0]);
            var diagnostic2 = new DefaultRazorDiagnostic(descriptor, span2, new object[0]);

            // Act
            var result = diagnostic1.Equals(diagnostic2);

            // Assert
            Assert.False(result);
        }
Exemplo n.º 4
0
        public void Create_WithDescriptor_AndArgs_CreatesDefaultRazorDiagnostic()
        {
            // Arrange
            var descriptor = new RazorDiagnosticDescriptor("RZ0001", () => "a", RazorDiagnosticSeverity.Error);
            var span       = new SourceSpan("test.cs", 15, 1, 8, 5);

            // Act
            var diagnostic = RazorDiagnostic.Create(descriptor, span, "Hello", "World");

            // Assert
            var defaultDiagnostic = Assert.IsType <DefaultRazorDiagnostic>(diagnostic);

            Assert.Equal("RZ0001", defaultDiagnostic.Id);
            Assert.Equal(RazorDiagnosticSeverity.Error, defaultDiagnostic.Severity);
            Assert.Equal(span, diagnostic.Span);
        }
 internal DefaultRazorDiagnostic(RazorDiagnosticDescriptor descriptor, SourceSpan span, object[] args)
 {
     Descriptor = descriptor;
     Span       = span;
     Args       = args;
 }