CheckedStatementHighlighterTests.cs 1.5 KB
Newer Older
C
CyrusNajmabadi 已提交
1
// Copyright (c) Microsoft.  All Rights Reserved.  Licensed under the Apache License, Version 2.0.  See License.txt in the project root for license information.
2

C
Cyrus Najmabadi 已提交
3
using System.Threading.Tasks;
4 5 6 7 8 9 10 11 12 13 14 15 16
using Microsoft.CodeAnalysis.Editor.CSharp.KeywordHighlighting.KeywordHighlighters;
using Roslyn.Test.Utilities;
using Xunit;

namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.KeywordHighlighting
{
    public class CheckedStatementHighlighterTests : AbstractCSharpKeywordHighlighterTests
    {
        internal override IHighlighter CreateHighlighter()
        {
            return new CheckedStatementHighlighter();
        }

17
        [Fact, Trait(Traits.Feature, Traits.Features.KeywordHighlighting)]
C
Cyrus Najmabadi 已提交
18
        public async Task TestExample1_1()
19
        {
C
Cyrus Najmabadi 已提交
20
            await TestAsync(
C
CyrusNajmabadi 已提交
21 22 23 24
@"class C
{
    void M()
    {
25
        short x = 0;
C
CyrusNajmabadi 已提交
26 27 28 29 30 31 32 33 34 35 36 37 38
        short y = 100;
        while (true)
        {
            {|Cursor:[|checked|]|}
            {
                x++;
            }

            unchecked
            {
                y++;
            }
        }
39
    }
C
CyrusNajmabadi 已提交
40
}");
41 42
        }

43
        [Fact, Trait(Traits.Feature, Traits.Features.KeywordHighlighting)]
C
Cyrus Najmabadi 已提交
44
        public async Task TestExample1_2()
45
        {
C
Cyrus Najmabadi 已提交
46
            await TestAsync(
C
CyrusNajmabadi 已提交
47 48 49 50
@"class C
{
    void M()
    {
51
        short x = 0;
C
CyrusNajmabadi 已提交
52 53 54 55 56 57 58 59 60 61 62 63 64
        short y = 100;
        while (true)
        {
            checked
            {
                x++;
            }

            {|Cursor:[|unchecked|]|}
            {
                y++;
            }
        }
65
    }
C
CyrusNajmabadi 已提交
66
}");
67 68 69
        }
    }
}