Here are the examples of the csharp api System.Threading.Tasks.Task.FromResult(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1190 Examples
19
Source : MethodInvokerTest.cs
with MIT License
from 1100100
with MIT License
from 1100100
public async Task<string> GetString()
{
return await Task.FromResult("test string");
}
19
Source : Startup.cs
with MIT License
from 2881099
with MIT License
from 2881099
[Custom]
public virtual async Task CreateKeyAsync(CustomDto customDto)
{
await Task.FromResult("");
Console.WriteLine($"CustomRepository.CreateAsync({customDto.Key}) value");
}
19
Source : CodeGenerate.cs
with MIT License
from 2881099
with MIT License
from 2881099
public async Task<string> Setup(TaskBuild taskBuild, string code, List<DbTableInfo> dbTables, DbTableInfo dbTableInfo)
{
StringBuilder plus = new StringBuilder();
try
{
var config = new TemplateServiceConfiguration();
config.EncodedStringFactory = new RawStringFactory();
Engine.Razor = RazorEngineService.Create(config);
var razorId = Guid.NewGuid().ToString("N");
Engine.Razor.Compile(code, razorId);
var sw = new StringWriter();
var model = new RazorModel(taskBuild, dbTables, dbTableInfo);
Engine.Razor.Run(razorId, sw, null, model);
plus.AppendLine("//------------------------------------------------------------------------------");
plus.AppendLine("// <auto-generated>");
plus.AppendLine("// 此代码由工具生成。");
plus.AppendLine("// 运行时版本:" + Environment.Version.ToString());
plus.AppendLine("// Website: http://www.freesql.net");
plus.AppendLine("// 对此文件的更改可能会导致不正确的行为,并且如果");
plus.AppendLine("// 重新生成代码,这些更改将会丢失。");
plus.AppendLine("// </auto-generated>");
plus.AppendLine("//------------------------------------------------------------------------------");
plus.Append(sw.ToString());
plus.AppendLine();
return await Task.FromResult(plus.ToString());
}
catch
{
return await Task.FromResult(plus.ToString());
}
}
19
Source : TrainTrainSystemShould.cs
with MIT License
from 42skillz
with MIT License
from 42skillz
private static IBookingReferenceService BuildBookingReferenceService(string bookingReference)
{
var bookingReferenceService = Subsreplacedute.For<IBookingReferenceService>();
bookingReferenceService.GetBookingReference().Returns(Task.FromResult(bookingReference));
return bookingReferenceService;
}
19
Source : TrainTrainSystemShould.cs
with MIT License
from 42skillz
with MIT License
from 42skillz
private static ITrainDataService BuildTrainDataService(string trainId, string trainTopology)
{
var trainDataService = Subsreplacedute.For<ITrainDataService>();
trainDataService.GetTrain(trainId)
.Returns(Task.FromResult(trainTopology));
return trainDataService;
}
19
Source : ConstantRemotePathProvider.cs
with MIT License
from Accelerider
with MIT License
from Accelerider
public virtual Task<string> GetAsync()
{
if (RemotePaths.Values.All(item => item < 0))
throw new RemotePathExhaustedException(this);
return Task.FromResult(
RemotePaths.Aggregate((acc, item) => acc.Value < item.Value ? item : acc).Key);
}
19
Source : StepHost.cs
with MIT License
from actions
with MIT License
from actions
public Task<string> DetermineNodeRuntimeVersion(IExecutionContext executionContext)
{
return Task.FromResult<string>("node12");
}
19
Source : ServerDataProvider.cs
with MIT License
from actions
with MIT License
from actions
public Task<String> LocationForAccessMappingAsync(
ServiceDefinition serviceDefinition,
AccessMapping accessMapping,
CancellationToken cancellationToken = default(CancellationToken))
{
ArgumentUtility.CheckForNull(serviceDefinition, "serviceDefinition");
ArgumentUtility.CheckForNull(accessMapping, "accessMapping");
// If this is FullyQualified then look through our location mappings
if (serviceDefinition.RelativeToSetting == RelativeToSetting.FullyQualified)
{
LocationMapping locationMapping = serviceDefinition.GetLocationMapping(accessMapping);
if (locationMapping != null)
{
return Task.FromResult<String>(locationMapping.Location);
}
// We weren't able to find the location for the access mapping. Return null.
return Task.FromResult<String>(null);
}
else
{
// Make sure the AccessMapping has a valid AccessPoint.
if (String.IsNullOrEmpty(accessMapping.AccessPoint))
{
throw new InvalidAccessPointException(WebApiResources.InvalidAccessMappingLocationServiceUrl());
}
String webApplicationRelativeDirectory = m_locationDataCacheManager.WebApplicationRelativeDirectory;
if (accessMapping.VirtualDirectory != null)
{
webApplicationRelativeDirectory = accessMapping.VirtualDirectory;
}
Uri uri = new Uri(accessMapping.AccessPoint);
String properRoot = String.Empty;
switch (serviceDefinition.RelativeToSetting)
{
case RelativeToSetting.Context:
properRoot = PathUtility.Combine(uri.AbsoluteUri, webApplicationRelativeDirectory);
break;
case RelativeToSetting.WebApplication:
properRoot = accessMapping.AccessPoint;
break;
default:
Debug.replacedert(true, "Found an unknown RelativeToSetting");
break;
}
return Task.FromResult<String>(PathUtility.Combine(properRoot, serviceDefinition.RelativePath));
}
}
19
Source : ServerDataProvider.cs
with MIT License
from actions
with MIT License
from actions
public Task<String> LocationForAccessMappingAsync(
ServiceDefinition serviceDefinition,
AccessMapping accessMapping,
CancellationToken cancellationToken = default(CancellationToken))
{
ArgumentUtility.CheckForNull(serviceDefinition, "serviceDefinition");
ArgumentUtility.CheckForNull(accessMapping, "accessMapping");
// If this is FullyQualified then look through our location mappings
if (serviceDefinition.RelativeToSetting == RelativeToSetting.FullyQualified)
{
LocationMapping locationMapping = serviceDefinition.GetLocationMapping(accessMapping);
if (locationMapping != null)
{
return Task.FromResult<String>(locationMapping.Location);
}
// We weren't able to find the location for the access mapping. Return null.
return Task.FromResult<String>(null);
}
else
{
// Make sure the AccessMapping has a valid AccessPoint.
if (String.IsNullOrEmpty(accessMapping.AccessPoint))
{
throw new InvalidAccessPointException(WebApiResources.InvalidAccessMappingLocationServiceUrl());
}
String webApplicationRelativeDirectory = m_locationDataCacheManager.WebApplicationRelativeDirectory;
if (accessMapping.VirtualDirectory != null)
{
webApplicationRelativeDirectory = accessMapping.VirtualDirectory;
}
Uri uri = new Uri(accessMapping.AccessPoint);
String properRoot = String.Empty;
switch (serviceDefinition.RelativeToSetting)
{
case RelativeToSetting.Context:
properRoot = PathUtility.Combine(uri.AbsoluteUri, webApplicationRelativeDirectory);
break;
case RelativeToSetting.WebApplication:
properRoot = accessMapping.AccessPoint;
break;
default:
Debug.replacedert(true, "Found an unknown RelativeToSetting");
break;
}
return Task.FromResult<String>(PathUtility.Combine(properRoot, serviceDefinition.RelativePath));
}
}
19
Source : FileVideoSourceHandler.cs
with MIT License
from adamfisher
with MIT License
from adamfisher
public Task<string> LoadVideoAsync(VideoSource source, CancellationToken cancellationToken = default(CancellationToken))
{
string path = null;
var fileVideoSource = source as FileVideoSource;
if (!string.IsNullOrEmpty(fileVideoSource?.File) && File.Exists(fileVideoSource.File))
{
path = fileVideoSource.File;
}
return Task.FromResult(path);
}
19
Source : UriVideoSourceHandler.cs
with MIT License
from adamfisher
with MIT License
from adamfisher
public async Task<string> LoadVideoAsync(VideoSource source, CancellationToken cancellationToken = default(CancellationToken))
{
string path = null;
var uriVideoSource = source as UriVideoSource;
if (uriVideoSource?.Uri != null)
{
path = uriVideoSource.Uri.AbsoluteUri;
}
return await Task.FromResult(path);
}
19
Source : UriVideoSourceHandler.cs
with MIT License
from adamfisher
with MIT License
from adamfisher
public Task<string> LoadVideoAsync(VideoSource source, CancellationToken cancellationToken = default(CancellationToken))
{
string path = null;
var uriVideoSource = source as UriVideoSource;
if (uriVideoSource?.Uri != null)
{
path = uriVideoSource.Uri.AbsoluteUri;
}
return Task.FromResult(path);
}
19
Source : FileVideoSourceHandler.cs
with MIT License
from adamfisher
with MIT License
from adamfisher
public Task<string> LoadVideoAsync(VideoSource source, CancellationToken cancellationToken = default(CancellationToken))
{
string path = null;
var fileVideoSource = source as FileVideoSource;
if (!string.IsNullOrEmpty(fileVideoSource?.File))
{
path = fileVideoSource.File;
}
return Task.FromResult(path);
}
19
Source : RazorEngineTemplateBase.cs
with MIT License
from adoconnection
with MIT License
from adoconnection
public virtual Task<string> ResultAsync()
{
return Task.FromResult<string>(this.stringBuilder.ToString());
}
19
Source : BaseTest.cs
with MIT License
from Adyen
with MIT License
from Adyen
protected Client CreateMockTestClientNullRequiredFieldsRequest(string fileName)
{
var mockPath = GetMockFilePath(fileName);
var response = MockFileToString(mockPath);
//Create a mock interface
var clientInterfaceMock = new Mock<IClient>();
var confMock = MockPaymentData.CreateConfingMock();
clientInterfaceMock.Setup(x => x.Request(It.IsAny<string>(), It.IsAny<string>(), confMock)).Returns(response);
clientInterfaceMock.Setup(x => x.Request(It.IsAny<string>(), It.IsAny<string>(), confMock, It.IsAny<bool>(), It.IsAny<RequestOptions>())).Returns(response);
clientInterfaceMock.Setup(x => x.RequestAsync(It.IsAny<string>(), It.IsAny<string>(), confMock, It.IsAny<bool>(), It.IsAny<RequestOptions>())).Returns(Task.FromResult(response));
var clientMock = new Client(It.IsAny<Config>())
{
HttpClient = clientInterfaceMock.Object,
Config = confMock
};
return clientMock;
}
19
Source : AuthInterceptorTests.cs
with MIT License
from AElfProject
with MIT License
from AElfProject
[Theory]
[InlineData("Ping")]
[InlineData("DoHandshake")]
public async Task UnaryServerHandler_NoAuth_Test(string methodName)
{
var helper = new MockServiceBuilder();
var unaryHandler = new UnaryServerMethod<string, string>((request, context) => Task.FromResult("ok"));
var method = new Method<string, string>(
MethodType.Unary,
nameof(PeerService),
methodName,
Marshallers.StringMarshaller,
Marshallers.StringMarshaller);
var serverServiceDefinition = ServerServiceDefinition.CreateBuilder()
.AddMethod(method, (request, context) => unaryHandler(request, context)).Build()
.Intercept(_authInterceptor);
helper.ServiceDefinition = serverServiceDefinition;
_server = helper.GetServer();
_server.Start();
_channel = helper.GetChannel();
var result = await Calls.AsyncUnaryCall(new CallInvocationDetails<string, string>(_channel, method, default),
"");
result.ShouldBe("ok");
}
19
Source : AuthInterceptorTests.cs
with MIT License
from AElfProject
with MIT License
from AElfProject
[Fact]
public async Task UnaryServerHandler_Auth_Failed()
{
var helper = new MockServiceBuilder();
helper.UnaryHandler = new UnaryServerMethod<string, string>((request, context) => Task.FromResult("ok"));
helper.ServiceDefinition = helper.ServiceDefinition.Intercept(_authInterceptor);
_server = helper.GetServer();
_server.Start();
_channel = helper.GetChannel();
await ShouldBeCancelRpcExceptionAsync(async () =>
await Calls.AsyncUnaryCall(helper.CreateUnaryCall(), ""));
var method = new Method<string, string>(MethodType.Unary, MockServiceBuilder.ServiceName, "Unary",
Marshallers.StringMarshaller, Marshallers.StringMarshaller);
var peer = _peerPool.GetPeersByHost("127.0.0.1").First();
((GrpcPeer) peer).InboundSessionId = new byte[] {1, 2, 3};
var callInvoker = helper.GetChannel().Intercept(metadata =>
{
metadata = new Metadata
{
{ GrpcConstants.PubkeyMetadataKey, peer.Info.Pubkey}
};
return metadata;
});
await ShouldBeCancelRpcExceptionAsync(async () =>
await callInvoker.AsyncUnaryCall(method, "localhost", new CallOptions(), ""));
callInvoker = helper.GetChannel().Intercept(metadata =>
{
metadata = new Metadata
{
{ GrpcConstants.PubkeyMetadataKey, peer.Info.Pubkey},
{ GrpcConstants.SessionIdMetadataKey, new byte[] {4, 5, 6 }}
};
return metadata;
});
await ShouldBeCancelRpcExceptionAsync(async () =>
await callInvoker.AsyncUnaryCall(method, "localhost", new CallOptions(), ""));
((GrpcPeer) peer).InboundSessionId = null;
await ShouldBeCancelRpcExceptionAsync(async () =>
await callInvoker.AsyncUnaryCall(method, "localhost", new CallOptions(), ""));
}
19
Source : AuthInterceptorTests.cs
with MIT License
from AElfProject
with MIT License
from AElfProject
[Fact]
public async Task UnaryServerHandler_Auth_Success()
{
var peer = _peerPool.GetPeersByHost("127.0.0.1").First();
((GrpcPeer) peer).InboundSessionId = new byte[] {1, 2, 3};
var helper = new MockServiceBuilder();
helper.UnaryHandler = new UnaryServerMethod<string, string>((request, context) =>
{
context.GetPeerInfo().ShouldBe(peer.ToString());
return Task.FromResult("ok");
});
helper.ServiceDefinition = helper.ServiceDefinition.Intercept(_authInterceptor);
_server = helper.GetServer();
_server.Start();
_channel = helper.GetChannel();
var method = new Method<string, string>(MethodType.Unary, MockServiceBuilder.ServiceName, "Unary",
Marshallers.StringMarshaller, Marshallers.StringMarshaller);
var callInvoker = helper.GetChannel().Intercept(metadata =>
{
metadata = new Metadata
{
{ GrpcConstants.PubkeyMetadataKey, peer.Info.Pubkey},
{ GrpcConstants.SessionIdMetadataKey, new byte[] {1, 2, 3}}
};
return metadata;
});
var result = await callInvoker.AsyncUnaryCall(method, "localhost", new CallOptions(), "");
result.ShouldBe("ok");
}
19
Source : AuthInterceptorTests.cs
with MIT License
from AElfProject
with MIT License
from AElfProject
[Fact]
public async Task ClientStreamingServerHandler_Auth_Failed()
{
var helper = new MockServiceBuilder();
helper.ClientStreamingHandler = new ClientStreamingServerMethod<string, string>((request, context) => Task.FromResult("ok"));
helper.ServiceDefinition = helper.ServiceDefinition.Intercept(_authInterceptor);
_server = helper.GetServer();
_server.Start();
_channel = helper.GetChannel();
await ShouldBeCancelRpcExceptionAsync(async () =>
await Calls.AsyncClientStreamingCall(helper.CreateClientStreamingCall()).ResponseAsync);
var method = new Method<string, string>(MethodType.ClientStreaming, MockServiceBuilder.ServiceName, "ClientStreaming",
Marshallers.StringMarshaller, Marshallers.StringMarshaller);
var peer = _peerPool.GetPeersByHost("127.0.0.1").First();
((GrpcPeer) peer).InboundSessionId = new byte[] {1, 2, 3};
var callInvoker = helper.GetChannel().Intercept(metadata =>
{
metadata = new Metadata
{
{ GrpcConstants.PubkeyMetadataKey, peer.Info.Pubkey},
{ GrpcConstants.SessionIdMetadataKey, new byte[] {4, 5, 6}}
};
return metadata;
});
await ShouldBeCancelRpcExceptionAsync(async () =>
await callInvoker.AsyncClientStreamingCall(method, "localhost", new CallOptions()).ResponseAsync);
}
19
Source : AuthInterceptorTests.cs
with MIT License
from AElfProject
with MIT License
from AElfProject
[Fact]
public async Task ClientStreamingServerHandler_Auth_Success()
{
var peer = _peerPool.GetPeersByHost("127.0.0.1").First();
((GrpcPeer) peer).InboundSessionId = new byte[] {1, 2, 3};
var helper = new MockServiceBuilder();
helper.ClientStreamingHandler = new ClientStreamingServerMethod<string, string>((request, context) =>
{
context.GetPeerInfo().ShouldBe(peer.ToString());
return Task.FromResult("ok");
});
helper.ServiceDefinition = helper.ServiceDefinition.Intercept(_authInterceptor);
_server = helper.GetServer();
_server.Start();
_channel = helper.GetChannel();
var method = new Method<string, string>(MethodType.ClientStreaming, MockServiceBuilder.ServiceName,
"ClientStreaming",
Marshallers.StringMarshaller, Marshallers.StringMarshaller);
var callInvoker = helper.GetChannel().Intercept(metadata =>
{
metadata = new Metadata
{
{GrpcConstants.PubkeyMetadataKey, peer.Info.Pubkey},
{GrpcConstants.SessionIdMetadataKey, new byte[] {1, 2, 3}}
};
return metadata;
});
var result = await callInvoker.AsyncClientStreamingCall(method, "localhost", new CallOptions()).ResponseAsync;
result.ShouldBe("ok");
}
19
Source : RetryInterceptorTest.cs
with MIT License
from AElfProject
with MIT License
from AElfProject
[Fact]
public async Task RetryDoesNotExceedSuccess()
{
var helper = new MockServiceBuilder("localhost");
int callCount = 0;
helper.UnaryHandler = new UnaryServerMethod<string, string>((request, context) =>
{
callCount++;
if (callCount == 1)
context.Status = new Status(StatusCode.Cancelled, "");
return Task.FromResult("ok");
});
_server = helper.GetServer();
_server.Start();
_channel = helper.GetChannel();
var callInvoker = helper.GetChannel().Intercept(new RetryInterceptor());
var metadata = new Metadata {{ GrpcConstants.RetryCountMetadataKey, "5"}};
await callInvoker.AsyncUnaryCall(new Method<string, string>(MethodType.Unary,
MockServiceBuilder.ServiceName, "Unary", Marshallers.StringMarshaller, Marshallers.StringMarshaller),
"localhost", new CallOptions().WithHeaders(metadata), "");
replacedert.Equal(2, callCount);
}
19
Source : RetryInterceptorTest.cs
with MIT License
from AElfProject
with MIT License
from AElfProject
[Fact]
public async Task RetryHeaderDecidesRetryCount()
{
var helper = new MockServiceBuilder("localhost");
int callCount = 0;
helper.UnaryHandler = new UnaryServerMethod<string, string>((request, context) =>
{
callCount++;
context.Status = new Status(StatusCode.Cancelled, "");
return Task.FromResult("ok");
});
_server = helper.GetServer();
_server.Start();
_channel = helper.GetChannel();
var callInvoker = helper.GetChannel().Intercept(new RetryInterceptor());
var metadata = new Metadata {{ GrpcConstants.RetryCountMetadataKey, "0"}};
await replacedert.ThrowsAsync<AggregateException>(async () => await callInvoker.AsyncUnaryCall(new Method<string, string>(MethodType.Unary,
MockServiceBuilder.ServiceName, "Unary", Marshallers.StringMarshaller, Marshallers.StringMarshaller),
"localhost", new CallOptions().WithHeaders(metadata), ""));
replacedert.Equal(1, callCount);
callCount = 0;
var oneRetryMetadata = new Metadata {{ GrpcConstants.RetryCountMetadataKey, "1"}};
await replacedert.ThrowsAsync<AggregateException>(async () => await callInvoker.AsyncUnaryCall(new Method<string, string>(MethodType.Unary,
MockServiceBuilder.ServiceName, "Unary", Marshallers.StringMarshaller, Marshallers.StringMarshaller),
"localhost", new CallOptions().WithHeaders(oneRetryMetadata), ""));
replacedert.Equal(2, callCount);
callCount = 0;
await replacedert.ThrowsAsync<AggregateException>(async () => await callInvoker.AsyncUnaryCall(new Method<string, string>(MethodType.Unary,
MockServiceBuilder.ServiceName, "Unary", Marshallers.StringMarshaller, Marshallers.StringMarshaller),
"localhost", new CallOptions(), ""));
replacedert.Equal(2, callCount);
}
19
Source : RetryInterceptorTest.cs
with MIT License
from AElfProject
with MIT License
from AElfProject
[Fact]
public async Task Retry_Timeout_Test()
{
var helper = new MockServiceBuilder("localhost");
int callCount = 0;
helper.UnaryHandler = new UnaryServerMethod<string, string>((request, context) =>
{
callCount++;
Task.Delay(1000).Wait();
return Task.FromResult("ok");
});
_server = helper.GetServer();
_server.Start();
_channel = helper.GetChannel();
var callInvoker = helper.GetChannel().Intercept(new RetryInterceptor());
var metadata = new Metadata {{ GrpcConstants.RetryCountMetadataKey, "1"}};
var exception = await replacedert.ThrowsAsync<AggregateException>(async () => await callInvoker.AsyncUnaryCall(
new Method<string, string>(MethodType.Unary,
MockServiceBuilder.ServiceName, "Unary", Marshallers.StringMarshaller,
Marshallers.StringMarshaller),
"localhost", new CallOptions().WithHeaders(metadata), ""));
var rpcException = exception.InnerExceptions[0] as RpcException;
rpcException.ShouldNotBeNull();
rpcException.StatusCode.ShouldBe(StatusCode.DeadlineExceeded);
replacedert.Equal(2, callCount);
}
19
Source : DbRepositorySimplifiedTest.cs
with Apache License 2.0
from agoda-com
with Apache License 2.0
from agoda-com
[Test]
public async Task ExecuteReaderAsync_Hit_Cache_Success()
{
SetupAsync();
object cachedValue = "cachedValue";
_cache.Setup(x => x.TryGetValue(It.IsAny<string>(), out cachedValue))
.Returns(true);
var result = await _db.ExecuteReaderAsync<string>("mobile_ro", "db.v1.sp_foo", 1,
2,new IDbDataParameter[]
{
new SqlParameter("@param1", "value1"),
new SqlParameter("@param2", "value2")
}, reader => Task.FromResult(cachedValue.ToString()), TimeSpan.MaxValue);
replacedert.AreEqual(cachedValue, result);
_cache.Verify(
x => x.TryGetValue(_expectedCacheKey, out cachedValue),
Times.Once);
_dbResources.Verify(x => x.ChooseDb("mobile_ro").SelectRandomly(), Times.Never);
replacedert.AreEqual(0, _onQueryCompleteEvents.Count);
}
19
Source : DbRepositoryTest.cs
with Apache License 2.0
from agoda-com
with Apache License 2.0
from agoda-com
public Task<string> ReadAsync(SqlMapper.GridReader reader)
=> Task.FromResult("multiple_result");
19
Source : RetryActionTest.cs
with Apache License 2.0
from agoda-com
with Apache License 2.0
from agoda-com
[Test]
public void ExecuteAction_Deny_Async_Result()
{
var errMsg = "Async action should be executed with ExecuteAsync.";
var mgr = new RetryAction<string>(() => "foo", UpdateWeight);
replacedert.Throws<ArgumentException>(
() => mgr.ExecuteAction<Task>((_1, _2) => Task.FromResult("Task"), (_1, _2) => true),
errMsg);
replacedert.Throws<ArgumentException>(
() => mgr.ExecuteAction<Task<string>>((_1, _2) => Task.FromResult("Task<T>"), (_1, _2) => true),
errMsg);
}
19
Source : RoleStore.cs
with Apache License 2.0
from Aguafrommars
with Apache License 2.0
from Aguafrommars
public virtual Task<string> GetRoleIdAsync(TRole role, CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
ThrowIfDisposed();
replacedertNotNull(role, nameof(role));
return Task.FromResult(ConvertIdToString(role.Id));
}
19
Source : EmptyDeviceAccessor.cs
with MIT License
from aguang-xyz
with MIT License
from aguang-xyz
public Task<string> GetSrcAsync()
{
return Task.FromResult(string.Empty);
}
19
Source : KeyRotationBuilderExtensionsTest.cs
with Apache License 2.0
from Aguafrommars
with Apache License 2.0
from Aguafrommars
[Fact]
public void ProtectKeysWithAzureKeyVault_should_throw_ArgumentNulException_on_builder_null()
{
replacedert.Throws<ArgumentNullException>(() => KeyRotationBuilderExtensions.ProtectKeysWithAzureKeyVault(null, null, null));
replacedert.Throws<ArgumentNullException>(() => KeyRotationBuilderExtensions.ProtectKeysWithAzureKeyVault(new KeyRotationBuilder(), null, null));
replacedert.Throws<ArgumentNullException>(() => KeyRotationBuilderExtensions.ProtectKeysWithAzureKeyVault(new KeyRotationBuilder(), new KeyVaultClient((a, r, s) => Task.FromResult("test")), null));
replacedert.Throws<ArgumentNullException>(() => KeyRotationBuilderExtensions.ProtectKeysWithAzureKeyVault(null, null, null, certificate: null));
replacedert.Throws<ArgumentNullException>(() => KeyRotationBuilderExtensions.ProtectKeysWithAzureKeyVault(null, null, "test", certificate: null));
replacedert.Throws<ArgumentNullException>(() => KeyRotationBuilderExtensions.ProtectKeysWithAzureKeyVault(null, null, null, clientSecret: null));
replacedert.Throws<ArgumentNullException>(() => KeyRotationBuilderExtensions.ProtectKeysWithAzureKeyVault(null, null, "test", clientSecret: null));
}
19
Source : TestSuite.cs
with MIT License
from ahydrax
with MIT License
from ahydrax
public Task<string> Done() => Task.FromResult("ALL DONE");
19
Source : TokenService.cs
with MIT License
from albyho
with MIT License
from albyho
public Task<string> GenerateRefreshTokenAsync(int userId)
{
var randomNumber = new byte[32];
using (var rng = RandomNumberGenerator.Create())
{
rng.GetBytes(randomNumber);
var refreshToken = Convert.ToBase64String(randomNumber);
var cacheKey = CacheKeyFormat.FormatWith(userId);
_cache.SetStringAsync(cacheKey, refreshToken, new DistributedCacheEntryOptions
{
AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(_tokenValidationSettings.ExpiresSeconds + _tokenValidationSettings.ClockSkewSeconds + _tokenValidationSettings.RefreshTokenExpiresSeconds)
}).ContinueWithOnFaultedHandleLog(_logger);
return Task.FromResult(refreshToken);
}
}
19
Source : SqlQueryable.cs
with MIT License
from AlenToma
with MIT License
from AlenToma
public async Task<string> JsonAsync(JSONParameters param = null)
{
return await Task.FromResult<string>(Execute().ToJson(param));
}
19
Source : SqlQueryable.cs
with MIT License
from AlenToma
with MIT License
from AlenToma
public async Task<string> XmlAsync()
{
return await Task.FromResult<string>(Execute().ToXml());
}
19
Source : NoopRoleStore.cs
with MIT License
from alexandre-spieser
with MIT License
from alexandre-spieser
public Task<string> GetRoleNameAsync(TestRole role, CancellationToken cancellationToken = default(CancellationToken))
{
return Task.FromResult<string>(null);
}
19
Source : NoopRoleStore.cs
with MIT License
from alexandre-spieser
with MIT License
from alexandre-spieser
public Task<string> GetRoleIdAsync(TestRole role, CancellationToken cancellationToken = default(CancellationToken))
{
return Task.FromResult<string>(null);
}
19
Source : NoopRoleStore.cs
with MIT License
from alexandre-spieser
with MIT License
from alexandre-spieser
public Task<string> GetNormalizedRoleNameAsync(TestRole role, CancellationToken cancellationToken = default(CancellationToken))
{
return Task.FromResult<string>(null);
}
19
Source : NoopUserStore.cs
with MIT License
from alexandre-spieser
with MIT License
from alexandre-spieser
public Task<string> GetNormalizedUserNameAsync(TestUser user, CancellationToken cancellationToken = default(CancellationToken))
{
return Task.FromResult<string>(null);
}
19
Source : MongoRoleStore.cs
with MIT License
from alexandre-spieser
with MIT License
from alexandre-spieser
public virtual Task<string> GetRoleIdAsync(TRole role, CancellationToken cancellationToken = default(CancellationToken))
{
cancellationToken.ThrowIfCancellationRequested();
ThrowIfDisposed();
if (role == null)
{
throw new ArgumentNullException(nameof(role));
}
return Task.FromResult(ConvertIdToString(role.Id));
}
19
Source : HostInfoController.cs
with MIT License
from alexyakunin
with MIT License
from alexyakunin
[HttpGet]
public Task<string> GetHostName(CancellationToken cancellationToken = default)
=> Task.FromResult(Environment.MachineName);
19
Source : ManageControllerTests.cs
with MIT License
from alimon808
with MIT License
from alimon808
public override Task<string> GenerateChangePhoneNumberTokenAsync(ApplicationUser user, string phoneNumber)
{
return Task.FromResult("change-phone-number-token");
}
19
Source : TokenControllerTests.cs
with MIT License
from alimon808
with MIT License
from alimon808
public override Task<string> GeneratePreplacedwordResetTokenAsync(ApplicationUser user)
{
return Task.FromResult("reset-preplacedword-token");
}
19
Source : TokenControllerTests.cs
with MIT License
from alimon808
with MIT License
from alimon808
public override Task<string> GenerateTwoFactorTokenAsync(ApplicationUser user, string tokenProvider)
{
return Task.FromResult("two-factor-token");
}
19
Source : TokenControllerTests.cs
with MIT License
from alimon808
with MIT License
from alimon808
public override Task<string> GetEmailAsync(ApplicationUser user)
{
return Task.FromResult("[email protected]");
}
19
Source : TokenControllerTests.cs
with MIT License
from alimon808
with MIT License
from alimon808
public override Task<string> GetPhoneNumberAsync(ApplicationUser user)
{
return Task.FromResult("224-555-0123");
}
19
Source : AccountControllerTests.cs
with MIT License
from alimon808
with MIT License
from alimon808
public override Task<string> GenerateEmailConfirmationTokenAsync(ApplicationUser user)
{
return Task.FromResult("token string");
}
19
Source : MemoryCache.cs
with MIT License
from alonsoalon
with MIT License
from alonsoalon
public Task<string> GetAsync(string key)
{
return Task.FromResult(Get(key));
}
19
Source : BasePathStrategy.cs
with MIT License
from alonsoalon
with MIT License
from alonsoalon
public async Task<string> GetIdentifierAsync(object context)
{
if (!(context is HttpContext))
throw new MulreplacedenantException(null,
new ArgumentException($"\"{nameof(context)}\" 必须是HttpContext类型 ", nameof(context)));
var path = (context as HttpContext).Request.Path;
var pathSegments =
path.Value.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
if (pathSegments.Length == 0)
return null;
string identifier = pathSegments[0];
return await Task.FromResult(identifier);
}
19
Source : DelegateStrategy.cs
with MIT License
from alonsoalon
with MIT License
from alonsoalon
public async Task<string> GetIdentifierAsync(object context)
{
var identifier = await doStrategy(context);
return await Task.FromResult(identifier);
}
19
Source : HostStrategy.cs
with MIT License
from alonsoalon
with MIT License
from alonsoalon
public async Task<string> GetIdentifierAsync(object context)
{
if (!(context is HttpContext))
throw new MulreplacedenantException(null,
new ArgumentException($"\"{nameof(context)}\" type must be of type HttpContext", nameof(context)));
var host = (context as HttpContext).Request.Host;
if (host.HasValue == false)
return null;
string identifier = null;
var match = Regex.Match(host.Host, regex,
RegexOptions.ExplicitCapture,
TimeSpan.FromMilliseconds(100));
if (match.Success)
{
identifier = match.Groups["identifier"].Value;
}
return await Task.FromResult(identifier);
}
19
Source : RouteStrategy.cs
with MIT License
from alonsoalon
with MIT License
from alonsoalon
public async Task<string> GetIdentifierAsync(object context)
{
if (!(context is HttpContext))
throw new MulreplacedenantException(null,
new ArgumentException($"\"{nameof(context)}\" 必须是HttpContext类型 ", nameof(context)));
var httpContext = context as HttpContext;
object identifier = null;
httpContext.Request.RouteValues.TryGetValue(tenantParam, out identifier);
return await Task.FromResult(identifier as string);
}
See More Examples