public async Task LocalModuleReferenceShouldThrow() { var dispatcher = StrictMock.Of <IModuleDispatcher>(); DiagnosticBuilder.ErrorBuilderDelegate?failureBuilder = null; const string ModuleRefStr = "./hello.bicep"; var localRef = LocalModuleReference.TryParse(ModuleRefStr, out _); localRef.Should().NotBeNull(); dispatcher.Setup(m => m.TryGetModuleReference(ModuleRefStr, It.IsAny <RootConfiguration>(), out failureBuilder)).Returns(localRef); var resolver = StrictMock.Of <IFileResolver>(); var handler = new BicepRegistryCacheRequestHandler(dispatcher.Object, resolver.Object, ConfigurationManager); var @params = new BicepRegistryCacheParams("/foo/bar/main.bicep", ModuleRefStr); (await FluentActions .Awaiting(() => handler.Handle(@params, default)) .Should() .ThrowAsync <InvalidOperationException>()) .WithMessage($"The specified module reference '{ModuleRefStr}' refers to a local module which is not supported by textDocument/bicepCache requests."); }
private static LocalModuleReference Parse(string package) { var parsed = LocalModuleReference.TryParse(package, out var failureBuilder); parsed.Should().NotBeNull(); failureBuilder.Should().BeNull(); return(parsed !); }
public ModuleReference?TryParseModuleReference(string reference, out DiagnosticBuilder.ErrorBuilderDelegate?failureBuilder) => LocalModuleReference.TryParse(reference, out failureBuilder);