Пример #1
0
        public void SmokeTest()
        {
            var start = new ErrorPosition(2, 2);
            var end   = new ErrorPosition(2, 3);
            var range = new ErrorRange(start, end);
            var error = new CompilationError(ErrorSeverity.Warning, "message", range);

            Assert.Equal("message", error.Message);
            Assert.Equal(ErrorSeverity.Warning, error.Severity);
            Assert.Equal(new ErrorPosition(2, 2), error.Location.Start);
            Assert.Equal(new ErrorPosition(2, 3), error.Location.End);

            Assert.Throws <ArgumentException>(() => new CompilationError(ErrorSeverity.Error, "message", new ErrorRange(end, start)));
        }
Пример #2
0
        public void TestEquals()
        {
            var range1 = new ErrorRange(new ErrorPosition(1, 1), new ErrorPosition(1, 3));
            var range2 = new ErrorRange(new ErrorPosition(1, 1), new ErrorPosition(1, 3));
            var range3 = new ErrorRange(new ErrorPosition(1, 1), new ErrorPosition(1, 4));
            var range4 = new ErrorRange(new ErrorPosition(1, 2), new ErrorPosition(1, 3));

            Assert.Equal(range1, range2);
            Assert.NotEqual(range1, range3);
            Assert.NotEqual(range1, range4);

            // ReSharper disable once EqualExpressionComparison
            Assert.True(range1.Equals(range1));
            Assert.False(range1.Equals(null));
            Assert.False(range1.Equals(new object()));
        }