public async Task TryGetSourceAgnosticPluginAsync_WhenSuccessfullyCreated_OperationClaimsAreCached() { var operationClaims = new[] { OperationClaim.Authentication }; using (var test = new PluginManagerTest(PluginFilePath, PluginFileState.Valid, operationClaims)) { Assert.False(File.Exists(test.PluginCacheEntry.CacheFileName)); var discoveryResult = new PluginDiscoveryResult( new PluginFile( PluginFilePath, new Lazy <PluginFileState>(() => PluginFileState.Valid))); Tuple <bool, PluginCreationResult> result = await test.PluginManager.TryGetSourceAgnosticPluginAsync( discoveryResult, OperationClaim.Authentication, CancellationToken.None); bool wasSomethingCreated = result.Item1; PluginCreationResult creationResult = result.Item2; Assert.True(wasSomethingCreated); Assert.NotNull(creationResult); Assert.True(File.Exists(test.PluginCacheEntry.CacheFileName)); Assert.Null(creationResult.Message); Assert.Null(creationResult.Exception); Assert.Same(test.Plugin, creationResult.Plugin); Assert.NotNull(creationResult.PluginMulticlientUtilities); Assert.Equal(operationClaims, creationResult.Claims); } }
public async Task TryGetSourceAgnosticPluginAsync_WhenCacheFileIndicatesIndicatesNoSupportedOperationClaims_PluginIsNotCreated() { var operationClaims = Array.Empty <OperationClaim>(); using (var test = new PluginManagerTest(PluginFilePath, PluginFileState.Valid, operationClaims)) { test.PluginCacheEntry.OperationClaims = operationClaims; await test.PluginCacheEntry.UpdateCacheFileAsync(); Assert.True(File.Exists(test.PluginCacheEntry.CacheFileName)); var discoveryResult = new PluginDiscoveryResult( new PluginFile( PluginFilePath, new Lazy <PluginFileState>(() => PluginFileState.Valid))); Tuple <bool, PluginCreationResult> result = await test.PluginManager.TryGetSourceAgnosticPluginAsync( discoveryResult, OperationClaim.Authentication, CancellationToken.None); bool wasSomethingCreated = result.Item1; PluginCreationResult creationResult = result.Item2; Assert.False(wasSomethingCreated); Assert.Null(creationResult); Assert.True(File.Exists(test.PluginCacheEntry.CacheFileName)); } }
public async Task PluginManager_CreatePlugin_PrefersFrameworkSpecificEnvironmentVariable(string pluginPath) { var operationClaims = new[] { OperationClaim.Authentication }; var mockReader = new Mock <IEnvironmentVariableReader>(MockBehavior.Strict); mockReader.Setup(x => x.GetEnvironmentVariable( It.Is <string>(value => value == EnvironmentVariableConstants.PluginPaths))) .Returns("badPluginPath"); #if IS_DESKTOP mockReader.Setup(x => x.GetEnvironmentVariable( It.Is <string>(value => value == EnvironmentVariableConstants.DesktopPluginPaths))) .Returns(pluginPath); #else mockReader.Setup(x => x.GetEnvironmentVariable( It.Is <string>(value => value == EnvironmentVariableConstants.CorePluginPaths))) .Returns(pluginPath); #endif mockReader.Setup(x => x.GetEnvironmentVariable( It.Is <string>(value => value == EnvironmentVariableConstants.RequestTimeout))) .Returns("RequestTimeout"); mockReader.Setup(x => x.GetEnvironmentVariable( It.Is <string>(value => value == EnvironmentVariableConstants.IdleTimeout))) .Returns("IdleTimeout"); mockReader.Setup(x => x.GetEnvironmentVariable( It.Is <string>(value => value == EnvironmentVariableConstants.HandshakeTimeout))) .Returns("HandshakeTimeout"); using (var test = new PluginManagerTest(pluginPath, PluginFileState.Valid, operationClaims, mockReader)) { var discoveryResult = new PluginDiscoveryResult( new PluginFile( PluginFilePath, new Lazy <PluginFileState>(() => PluginFileState.Valid))); Tuple <bool, PluginCreationResult> result = await test.PluginManager.TryGetSourceAgnosticPluginAsync( discoveryResult, OperationClaim.Authentication, CancellationToken.None); bool wasSomethingCreated = result.Item1; PluginCreationResult creationResult = result.Item2; Assert.True(wasSomethingCreated); Assert.NotNull(creationResult); Assert.Null(creationResult.Message); Assert.Null(creationResult.Exception); Assert.Same(test.Plugin, creationResult.Plugin); Assert.NotNull(creationResult.PluginMulticlientUtilities); Assert.Equal(operationClaims, creationResult.Claims); } }