-
Notifications
You must be signed in to change notification settings - Fork 728
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code lenses to switch between bicep and JSON module source
- Loading branch information
1 parent
5c0d0fe
commit 35a9964
Showing
26 changed files
with
724 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
using System.Linq; | ||
using System.Reactive.Subjects; | ||
using Bicep.Core.UnitTests.Registry; | ||
using FluentAssertions; | ||
using FluentAssertions.Primitives; | ||
using OmniSharp.Extensions.LanguageServer.Protocol.Models; | ||
|
||
namespace Bicep.Core.UnitTests.Assertions; | ||
|
||
public static class CodeLensAssertionsExtensions | ||
{ | ||
public static CodeLensAssertions Should(this CodeLens codeLens) | ||
{ | ||
return new CodeLensAssertions(codeLens); | ||
} | ||
} | ||
|
||
public class CodeLensAssertions : ObjectAssertions<CodeLens, CodeLensAssertions> | ||
{ | ||
public CodeLensAssertions(CodeLens subject) | ||
: base(subject) | ||
{ | ||
} | ||
|
||
protected override string Identifier => nameof(CodeLens); | ||
|
||
public AndConstraint<CodeLensAssertions> HaveCommandTitle(string title, string because = "", params object[] becauseArgs) | ||
{ | ||
Subject.Command.Should().NotBeNull("Code lens command should not be null"); | ||
Subject.Command!.Title.Should().Be(title, because, becauseArgs); | ||
|
||
return new(this); | ||
} | ||
|
||
public AndConstraint<CodeLensAssertions> HaveCommandName(string commandName, string because = "", params object[] becauseArgs) | ||
{ | ||
Subject.Command.Should().NotBeNull("Code lens command should not be null"); | ||
Subject.Command!.Name.Should().Be(commandName, because, becauseArgs); | ||
|
||
return new(this); | ||
} | ||
|
||
public AndConstraint<CodeLensAssertions> HaveCommandArguments(params string[] commandArguments) | ||
{ | ||
Subject.Command.Should().NotBeNull("Code lens command should not be null"); | ||
Subject.Command!.Arguments.Should().NotBeNull("Command args should not be null"); | ||
var actualCommandArguments = Subject.CommandArguments(); | ||
actualCommandArguments.Should().BeEquivalentTo(commandArguments); | ||
|
||
return new(this); | ||
} | ||
|
||
public AndConstraint<CodeLensAssertions> HaveNoCommandArguments() | ||
{ | ||
Subject.CommandArguments().Should().BeEmpty("Command should have no arguments"); | ||
|
||
return new(this); | ||
} | ||
|
||
public AndConstraint<CodeLensAssertions> HaveRange(Range range, string because = "", params object[] becauseArgs) | ||
{ | ||
Subject.Range.Should().Be(range, because, becauseArgs); | ||
|
||
return new(this); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using System.Linq; | ||
using OmniSharp.Extensions.LanguageServer.Protocol.Models; | ||
|
||
namespace Bicep.Core.UnitTests.Assertions; | ||
|
||
public static class CodeLensExtensions | ||
{ | ||
public static string[]? CommandArguments(this CodeLens codeLens) | ||
{ | ||
return codeLens.Command?.Arguments?.Children().Select(token => token.ToString()).ToArray(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.