Here are the examples of the csharp api System.Threading.Tasks.Task.FromResult(System.Collections.Generic.IEnumerable) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
646 Examples
19
Source : ModuleIdentityLifecycleManagerTest.cs
with MIT License
from Azure
with MIT License
from Azure
[Fact]
[Unit]
public async Task TestGetModulesIdenreplacedy_WithRemovedModules_ShouldRemove()
{
// Arrange
const string Module1 = "module1";
var idenreplacedy1 = new Idenreplacedy(Module1, Guid.NewGuid().ToString(), "IotEdge");
const string Module2 = "module2";
var idenreplacedy2 = new Idenreplacedy(Module2, Guid.NewGuid().ToString(), "Me");
const string Module3 = "module3";
var idenreplacedy3 = new Idenreplacedy(Module3, Guid.NewGuid().ToString(), Constants.ModuleIdenreplacedyEdgeManagedByValue);
var idenreplacedyManager = Mock.Of<IIdenreplacedyManager>(
m =>
m.GetIdenreplacedies() == Task.FromResult(new List<Idenreplacedy>() { idenreplacedy2, idenreplacedy3 }.AsEnumerable()) &&
m.CreateIdenreplacedyAsync(Module1, It.IsAny<string>()) == Task.FromResult(idenreplacedy1) &&
m.DeleteIdenreplacedyAsync(Module3) == Task.FromResult(idenreplacedy3));
var moduleIdenreplacedyLifecycleManager = new ModuleIdenreplacedyLifecycleManager(idenreplacedyManager, ModuleIdenreplacedyProviderServiceBuilder, EdgeletUri);
var envVar = new Dictionary<string, EnvVal>();
var desiredModule = new TestModule(Module1, "v1", "test", ModuleStatus.Running, new TestConfig("image"), RestartPolicy.OnUnhealthy, ImagePullPolicy.OnCreate, Constants.DefaultStartupOrder, DefaultConfigurationInfo, envVar);
var currentModule1 = new TestModule(Module2, "v1", "test", ModuleStatus.Running, new TestConfig("image"), RestartPolicy.OnUnhealthy, ImagePullPolicy.OnCreate, Constants.DefaultStartupOrder, DefaultConfigurationInfo, envVar);
var currentModule2 = new TestModule(Module3, "v1", "test", ModuleStatus.Running, new TestConfig("image"), RestartPolicy.OnUnhealthy, ImagePullPolicy.OnCreate, Constants.DefaultStartupOrder, DefaultConfigurationInfo, envVar);
ModuleSet desired = ModuleSet.Create(new IModule[] { desiredModule });
ModuleSet current = ModuleSet.Create(new IModule[] { currentModule1, currentModule2 });
// Act
IImmutableDictionary<string, IModuleIdenreplacedy> moduleIdenreplacedies = await moduleIdenreplacedyLifecycleManager.GetModuleIdenreplacediesAsync(desired, current);
// replacedert
replacedert.NotNull(moduleIdenreplacedies);
replacedert.True(moduleIdenreplacedies.TryGetValue(Module1, out IModuleIdenreplacedy module1Idenreplacedy));
replacedert.Equal(Module1, module1Idenreplacedy.ModuleId);
replacedert.IsType<IdenreplacedyProviderServiceCredentials>(module1Idenreplacedy.Credentials);
replacedert.Equal(EdgeletUri.ToString(), ((IdenreplacedyProviderServiceCredentials)module1Idenreplacedy.Credentials).ProviderUri);
replacedert.Equal(Option.None<string>(), ((IdenreplacedyProviderServiceCredentials)module1Idenreplacedy.Credentials).Version);
Mock.Get(idenreplacedyManager).Verify(im => im.DeleteIdenreplacedyAsync(Module3));
}
19
Source : ModuleIdentityLifecycleManagerTest.cs
with MIT License
from Azure
with MIT License
from Azure
[Fact]
[Unit]
public async Task TestGetModulesIdenreplacedy_WithUnchanged_ShouldReturnAllWhenRequested()
{
// Arrange
const string Module1 = "module1";
var idenreplacedy1 = new Idenreplacedy(Module1, Guid.NewGuid().ToString(), "IotEdge");
const string Module2 = "module2";
var idenreplacedy2 = new Idenreplacedy(Module2, Guid.NewGuid().ToString(), "Me");
const string Module3 = "module3";
var idenreplacedy3 = new Idenreplacedy(Module3, Guid.NewGuid().ToString(), Constants.ModuleIdenreplacedyEdgeManagedByValue);
var idenreplacedyManager = Mock.Of<IIdenreplacedyManager>(
m =>
m.GetIdenreplacedies() == Task.FromResult(new List<Idenreplacedy>() { idenreplacedy2, idenreplacedy3 }.AsEnumerable()) &&
m.CreateIdenreplacedyAsync(Module1, It.IsAny<string>()) == Task.FromResult(idenreplacedy1) &&
m.DeleteIdenreplacedyAsync(Module3) == Task.FromResult(idenreplacedy3));
var moduleIdenreplacedyLifecycleManager = new ModuleIdenreplacedyLifecycleManager(idenreplacedyManager, ModuleIdenreplacedyProviderServiceBuilder, EdgeletUri);
var envVar = new Dictionary<string, EnvVal>();
var desiredModule = new TestModule(Module1, "v1", "test", ModuleStatus.Running, new TestConfig("image"), RestartPolicy.OnUnhealthy, ImagePullPolicy.OnCreate, Constants.DefaultStartupOrder, DefaultConfigurationInfo, envVar);
var currentModule1 = new TestModule(Module2, "v1", "test", ModuleStatus.Running, new TestConfig("image"), RestartPolicy.OnUnhealthy, ImagePullPolicy.OnCreate, Constants.DefaultStartupOrder, DefaultConfigurationInfo, envVar);
var currentModule2 = new TestModule(Module3, "v1", "test", ModuleStatus.Running, new TestConfig("image"), RestartPolicy.OnUnhealthy, ImagePullPolicy.OnCreate, Constants.DefaultStartupOrder, DefaultConfigurationInfo, envVar);
ModuleSet desired = ModuleSet.Create(new IModule[] { currentModule1, desiredModule });
ModuleSet current = ModuleSet.Create(new IModule[] { currentModule1, currentModule2 });
// Act
IImmutableDictionary<string, IModuleIdenreplacedy> moduleIdenreplacedies = await moduleIdenreplacedyLifecycleManager.GetModuleIdenreplacediesAsync(desired, current);
// replacedert
replacedert.NotNull(moduleIdenreplacedies);
replacedert.True(moduleIdenreplacedies.TryGetValue(Module1, out IModuleIdenreplacedy module1Idenreplacedy));
replacedert.True(moduleIdenreplacedies.TryGetValue(Module2, out IModuleIdenreplacedy module2Idenreplacedy));
replacedert.Equal(Module1, module1Idenreplacedy.ModuleId);
replacedert.Equal(Module2, module2Idenreplacedy.ModuleId);
replacedert.IsType<IdenreplacedyProviderServiceCredentials>(module1Idenreplacedy.Credentials);
replacedert.Equal(EdgeletUri.ToString(), ((IdenreplacedyProviderServiceCredentials)module1Idenreplacedy.Credentials).ProviderUri);
replacedert.Equal(Option.None<string>(), ((IdenreplacedyProviderServiceCredentials)module1Idenreplacedy.Credentials).Version);
Mock.Get(idenreplacedyManager).Verify(im => im.DeleteIdenreplacedyAsync(Module3));
}
19
Source : ModuleIdentityLifecycleManagerTest.cs
with MIT License
from Azure
with MIT License
from Azure
[Fact]
[Unit]
public async Task TestGetModulesIdenreplacedy_WithNewModules_ShouldCreateIdenreplacedies()
{
// Arrange
const string Name = "module1";
var idenreplacedy = new Idenreplacedy(
Name,
Guid.NewGuid().ToString(),
Constants.ModuleIdenreplacedyEdgeManagedByValue);
var idenreplacedyManager = Mock.Of<IIdenreplacedyManager>(
m =>
m.GetIdenreplacedies() == Task.FromResult(Enumerable.Empty<Idenreplacedy>()) &&
m.CreateIdenreplacedyAsync(Name, Constants.ModuleIdenreplacedyEdgeManagedByValue) == Task.FromResult(idenreplacedy));
var moduleIdenreplacedyLifecycleManager = new ModuleIdenreplacedyLifecycleManager(idenreplacedyManager, ModuleIdenreplacedyProviderServiceBuilder, EdgeletUri);
var module = new TestModule(Name, "v1", "test", ModuleStatus.Running, new TestConfig("image"), RestartPolicy.OnUnhealthy, ImagePullPolicy.OnCreate, Constants.DefaultStartupOrder, DefaultConfigurationInfo, new Dictionary<string, EnvVal>());
// Act
IImmutableDictionary<string, IModuleIdenreplacedy> modulesIdenreplacedies = await moduleIdenreplacedyLifecycleManager.GetModuleIdenreplacediesAsync(
ModuleSet.Create(new IModule[] { module }),
ModuleSet.Empty);
// replacedert
replacedert.True(modulesIdenreplacedies.Count() == 1);
replacedert.True(modulesIdenreplacedies.TryGetValue(Name, out IModuleIdenreplacedy moduleIdenreplacedy));
replacedert.Equal(moduleIdenreplacedy.ModuleId, Name);
replacedert.IsType<IdenreplacedyProviderServiceCredentials>(moduleIdenreplacedy.Credentials);
replacedert.Equal(EdgeletUri.ToString(), ((IdenreplacedyProviderServiceCredentials)moduleIdenreplacedy.Credentials).ProviderUri);
replacedert.Equal(Option.None<string>(), ((IdenreplacedyProviderServiceCredentials)moduleIdenreplacedy.Credentials).Version);
Mock.Get(idenreplacedyManager).Verify();
}
19
Source : ModuleIdentityLifecycleManagerTest.cs
with MIT License
from Azure
with MIT License
from Azure
[Fact]
[Unit]
public async Task TestGetModulesIdenreplacedy_WithRemovedModules_ShouldRemove()
{
const string Name = "test-filters";
// Use Json to create module because managedBy property can't has private set on Module object
// [SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine", Justification="Synthetic symmetric keys used in tests")]
const string ModuleJson = "{\"moduleId\":\"test-filters\",\"deviceId\":\"device1\",\"authentication\":{\"symmetricKey\":{\"primaryKey\":\"cHJpbWFyeVN5bW1ldHJpY0tleQ == \",\"secondaryKey\":\"c2Vjb25kYXJ5U3ltbWV0cmljS2V5\"},\"x509Thumbprint\":{\"primaryThumbprint\":null,\"secondaryThumbprint\":null},\"type\":\"sas\"},\"managedBy\":\"iotEdge\"}";
var serviceModuleIdenreplacedy = JsonConvert.DeserializeObject<Module>(ModuleJson);
var currentModule = new TestModule(Name, "v1", "test", ModuleStatus.Running, new TestConfig("image"), RestartPolicy.OnUnhealthy, ImagePullPolicy.OnCreate, Constants.DefaultStartupOrder, DefaultConfigurationInfo, EnvVars);
var serviceClient = new Mock<IServiceClient>();
string hostname = "hostname";
string deviceId = "deviceId";
string gatewayHostName = "localhost";
var serviceIdenreplacedies = new List<Module>();
serviceIdenreplacedies.Add(serviceModuleIdenreplacedy);
serviceClient.Setup(sc => sc.GetModules()).Returns(Task.FromResult(serviceIdenreplacedies.AsEnumerable()));
// If we change to IList Mock doesn't recognize and making it a non Lambda would add a lot of complexity on this code.
// ReSharper disable PossibleMultipleEnumeration
serviceClient.Setup(sc => sc.RemoveModules(It.Is<IEnumerable<string>>(m => m.Count() == 1 && m.First() == Name))).Returns(Task.FromResult(ImmutableList<Module>.Empty.AsEnumerable()));
// ReSharper restore PossibleMultipleEnumeration
await new ModuleIdenreplacedyLifecycleManager(serviceClient.Object, hostname, deviceId, gatewayHostName)
.GetModuleIdenreplacediesAsync(ModuleSet.Empty, ModuleSet.Create(new IModule[] { currentModule }));
// If we change to IList Mock doesn't recognize and making it a non Lambda would add a lot of complexity on this code.
// ReSharper disable PossibleMultipleEnumeration
serviceClient.Verify(sc => sc.RemoveModules(It.Is<IEnumerable<string>>(m => m.Count() == 1 && m.First() == Name)), Times.Once);
// ReSharper restore PossibleMultipleEnumeration
}
19
Source : RetryingServiceClientTest.cs
with MIT License
from Azure
with MIT License
from Azure
[Fact]
public async Task GetModulesRetryTest()
{
// Arrange
var underlying = new Mock<IServiceClient>();
underlying.SetupSequence(c => c.GetModules())
.Throws(new InvalidOperationException())
.Returns(Task.FromResult(Enumerable.Empty<Module>()));
var serviceClient = new RetryingServiceClient(underlying.Object);
// Act
IEnumerable<Module> modules = await serviceClient.GetModules();
// replacedert
replacedert.NotNull(modules);
}
19
Source : RetryingServiceClientTest.cs
with MIT License
from Azure
with MIT License
from Azure
[Fact]
public async Task GetModulesRetryUnauthorizedThrowsTest()
{
// Arrange
var underlying = new Mock<IServiceClient>();
underlying.SetupSequence(c => c.GetModules())
.Throws(new UnauthorizedException("Unauthorized!"))
.Returns(Task.FromResult(Enumerable.Empty<Module>()));
var serviceClient = new RetryingServiceClient(underlying.Object);
// Act / replacedert
await replacedert.ThrowsAsync<UnauthorizedException>(() => serviceClient.GetModules());
}
19
Source : ResultQuery.cs
with MIT License
from Azure
with MIT License
from Azure
public Task<IEnumerable<Twin>> GetNextAsTwinAsync()
{
this.HasMoreResults = false;
return Task.FromResult<IEnumerable<Twin>>(this.results);
}
19
Source : ResultQuery.cs
with MIT License
from Azure
with MIT License
from Azure
public Task<IEnumerable<string>> GetNextAsJsonAsync()
{
this.HasMoreResults = false;
return Task.FromResult(deviceQueryResults.AsEnumerable());
}
19
Source : DefaultDocumentTransformer.cs
with MIT License
from Azure-Samples
with MIT License
from Azure-Samples
public Task<IEnumerable<DoreplacedentMetadata>> TransformDoreplacedent(DoreplacedentMetadata sourceDoc)
{
List<DoreplacedentMetadata> docs = new List<DoreplacedentMetadata>
{
sourceDoc
};
return Task.FromResult(docs.AsEnumerable());
}
19
Source : IOTHubStore.cs
with MIT License
from Azure-Samples
with MIT License
from Azure-Samples
public override Task<IEnumerable<IOTHubData>> GereplacedemsAsync(int skip = 0, int take = 100,
bool forceRefresh = false)
{
return Task.FromResult(iotHubData.AsEnumerable());
}
19
Source : POIStore.cs
with MIT License
from Azure-Samples
with MIT License
from Azure-Samples
public override Task<IEnumerable<POI>> GereplacedemsAsync(int skip = 0, int take = 100, bool forceRefresh = false)
{
var poiList = GenRandomPOI();
return Task.FromResult(poiList.AsEnumerable());
}
19
Source : AdvancedKonachan.cs
with GNU Affero General Public License v3.0
from b11p
with GNU Affero General Public License v3.0
from b11p
private static Task<IEnumerable<long>> GetPromotedGroupsAsync() => Task.FromResult(_promotedGroups as IEnumerable<long>);
19
Source : BlockRepository.cs
with MIT License
from baking-bad
with MIT License
from baking-bad
async Task LoadOperations(Block block, Data.Models.Operations operations, MichelineFormat format, Symbols quote)
{
var endorsements = operations.HasFlag(Data.Models.Operations.Endorsements)
? Operations.GetEndorsements(block, quote)
: Task.FromResult(Enumerable.Empty<EndorsementOperation>());
var proposals = operations.HasFlag(Data.Models.Operations.Proposals)
? Operations.GetProposals(block, quote)
: Task.FromResult(Enumerable.Empty<ProposalOperation>());
var ballots = operations.HasFlag(Data.Models.Operations.Ballots)
? Operations.GetBallots(block, quote)
: Task.FromResult(Enumerable.Empty<BallotOperation>());
var activations = operations.HasFlag(Data.Models.Operations.Activations)
? Operations.GetActivations(block, quote)
: Task.FromResult(Enumerable.Empty<ActivationOperation>());
var doubleBaking = operations.HasFlag(Data.Models.Operations.DoubleBakings)
? Operations.GetDoubleBakings(block, quote)
: Task.FromResult(Enumerable.Empty<DoubleBakingOperation>());
var doubleEndorsing = operations.HasFlag(Data.Models.Operations.DoubleEndorsings)
? Operations.GetDoubleEndorsings(block, quote)
: Task.FromResult(Enumerable.Empty<DoubleEndorsingOperation>());
var nonceRevelations = operations.HasFlag(Data.Models.Operations.Revelations)
? Operations.GetNonceRevelations(block, quote)
: Task.FromResult(Enumerable.Empty<NonceRevelationOperation>());
var delegations = operations.HasFlag(Data.Models.Operations.Delegations)
? Operations.GetDelegations(block, quote)
: Task.FromResult(Enumerable.Empty<DelegationOperation>());
var originations = operations.HasFlag(Data.Models.Operations.Originations)
? Operations.GetOriginations(block, quote)
: Task.FromResult(Enumerable.Empty<OriginationOperation>());
var transactions = operations.HasFlag(Data.Models.Operations.Transactions)
? Operations.GetTransactions(block, format, quote)
: Task.FromResult(Enumerable.Empty<TransactionOperation>());
var reveals = operations.HasFlag(Data.Models.Operations.Reveals)
? Operations.GetReveals(block, quote)
: Task.FromResult(Enumerable.Empty<RevealOperation>());
var migrations = operations.HasFlag(Data.Models.Operations.Migrations)
? Operations.GetMigrations(null, null, null, new Int32Parameter { Eq = block.Level }, null, null, null, 10_000, format, quote)
: Task.FromResult(Enumerable.Empty<MigrationOperation>());
var penalties = operations.HasFlag(Data.Models.Operations.RevelationPenalty)
? Operations.GetRevelationPenalties(null, new Int32Parameter { Eq = block.Level }, null, null, null, 10_000, quote)
: Task.FromResult(Enumerable.Empty<RevelationPenaltyOperation>());
await Task.WhenAll(
endorsements,
proposals,
ballots,
activations,
doubleBaking,
doubleEndorsing,
nonceRevelations,
delegations,
originations,
transactions,
reveals,
migrations,
penalties);
block.Endorsements = endorsements.Result;
block.Proposals = proposals.Result;
block.Ballots = ballots.Result;
block.Activations = activations.Result;
block.DoubleBaking = doubleBaking.Result;
block.DoubleEndorsing = doubleEndorsing.Result;
block.NonceRevelations = nonceRevelations.Result;
block.Delegations = delegations.Result;
block.Originations = originations.Result;
block.Transactions = transactions.Result;
block.Reveals = reveals.Result;
block.Migrations = migrations.Result;
block.RevelationPenalties = penalties.Result;
}
19
Source : OperationsProcessor.cs
with MIT License
from baking-bad
with MIT License
from baking-bad
public async Task OnStateChanged()
{
var sendings = new List<Task>();
try
{
await Sema.WaitAsync();
#region check reorg
if (State.Reorganized)
{
Logger.LogDebug("Sending reorg message with state {0}", State.ValidLevel);
sendings.Add(Context.Clients
.Group(OperationsGroup)
.SendReorg(OperationsChannel, State.ValidLevel));
}
#endregion
if (State.ValidLevel == State.Current.Level)
{
Logger.LogDebug("No operations to send");
return;
}
#region load operations
Logger.LogDebug("Fetching operations from block {0} to block {1}", State.ValidLevel, State.Current.Level);
var level = new Int32Parameter
{
Gt = State.ValidLevel,
Le = State.Current.Level
};
var limit = 1_000_000; // crutch
var symbols = Symbols.None;
var endorsements = TypesSubs.TryGetValue(Operations.Endorsements, out var endorsementsSub)
? Repo.GetEndorsements(null, level, null, null, null, limit, symbols)
: Task.FromResult(Enumerable.Empty<Models.EndorsementOperation>());
var proposals = TypesSubs.TryGetValue(Operations.Proposals, out var proposalsSub)
? Repo.GetProposals(null, level, null, null, null, null, null, null, null, limit, symbols)
: Task.FromResult(Enumerable.Empty<Models.ProposalOperation>());
var ballots = TypesSubs.TryGetValue(Operations.Ballots, out var ballotsSub)
? Repo.GetBallots(null, level, null, null, null, null, null, null, limit, symbols)
: Task.FromResult(Enumerable.Empty<Models.BallotOperation>());
var activations = TypesSubs.TryGetValue(Operations.Activations, out var activationsSub)
? Repo.GetActivations(null, level, null, null, null, limit, symbols)
: Task.FromResult(Enumerable.Empty<Models.ActivationOperation>());
var doubleBaking = TypesSubs.TryGetValue(Operations.DoubleBakings, out var doubleBakingSub)
? Repo.GetDoubleBakings(null, null, null, level, null, null, null, limit, symbols)
: Task.FromResult(Enumerable.Empty<Models.DoubleBakingOperation>());
var doubleEndorsing = TypesSubs.TryGetValue(Operations.DoubleEndorsings, out var doubleEndorsingSub)
? Repo.GetDoubleEndorsings(null, null, null, level, null, null, null, limit, symbols)
: Task.FromResult(Enumerable.Empty<Models.DoubleEndorsingOperation>());
var revelations = TypesSubs.TryGetValue(Operations.Revelations, out var revelationsSub)
? Repo.GetNonceRevelations(null, null, null, level, null, null, null, limit, symbols)
: Task.FromResult(Enumerable.Empty<Models.NonceRevelationOperation>());
var delegations = TypesSubs.TryGetValue(Operations.Delegations, out var delegationsSub)
? Repo.GetDelegations(null, null, null, null, null, level, null, null, null, null, limit, symbols)
: Task.FromResult(Enumerable.Empty<Models.DelegationOperation>());
var originations = TypesSubs.TryGetValue(Operations.Originations, out var originationsSub)
? Repo.GetOriginations(null, null, null, null, null, null, null, null, level, null, null, null, null, limit, MichelineFormat.Json, symbols, true, true)
: Task.FromResult(Enumerable.Empty<Models.OriginationOperation>());
var transactions = TypesSubs.TryGetValue(Operations.Transactions, out var transactionsSub)
? Repo.GetTransactions(null, null, null, null, null, null, level, null, null, null, null, null, null, null, null, limit, MichelineFormat.Json, symbols, true, true)
: Task.FromResult(Enumerable.Empty<Models.TransactionOperation>());
var reveals = TypesSubs.TryGetValue(Operations.Reveals, out var revealsSub)
? Repo.GetReveals(null, level, null, null, null, null, limit, symbols)
: Task.FromResult(Enumerable.Empty<Models.RevealOperation>());
var migrations = TypesSubs.TryGetValue(Operations.Migrations, out var migrationsSub)
? Repo.GetMigrations(null, null, null, level, null, null, null, limit, MichelineFormat.Json, symbols, true, true)
: Task.FromResult(Enumerable.Empty<Models.MigrationOperation>());
var penalties = TypesSubs.TryGetValue(Operations.RevelationPenalty, out var penaltiesSub)
? Repo.GetRevelationPenalties(null, level, null, null, null, limit, symbols)
: Task.FromResult(Enumerable.Empty<Models.RevelationPenaltyOperation>());
var baking = TypesSubs.TryGetValue(Operations.Baking, out var bakingSub)
? Repo.GetBakings(null, level, null, null, null, limit, symbols)
: Task.FromResult(Enumerable.Empty<Models.BakingOperation>());
await Task.WhenAll(
endorsements,
proposals,
ballots,
activations,
doubleBaking,
doubleEndorsing,
revelations,
delegations,
originations,
transactions,
reveals,
migrations,
penalties,
baking);
#endregion
#region prepare to send
var toSend = new Dictionary<string, List<Operation>>();
void Add(HashSet<string> subs, Operation operation)
{
foreach (var clientId in subs)
{
if (!toSend.TryGetValue(clientId, out var list))
{
list = new();
toSend.Add(clientId, list);
}
list.Add(operation);
}
}
void AddRange(HashSet<string> subs, IEnumerable<Operation> operations)
{
foreach (var clientId in subs)
{
if (!toSend.TryGetValue(clientId, out var list))
{
list = new();
toSend.Add(clientId, list);
}
list.AddRange(operations);
}
}
if (endorsements.Result.Any())
{
if (endorsementsSub.All != null)
AddRange(endorsementsSub.All, endorsements.Result);
if (endorsementsSub.Addresses != null)
foreach (var op in endorsements.Result)
if (endorsementsSub.Addresses.TryGetValue(op.Delegate.Address, out var delegateSubs))
Add(delegateSubs, op);
}
if (ballots.Result.Any())
{
if (ballotsSub.All != null)
AddRange(ballotsSub.All, ballots.Result);
if (ballotsSub.Addresses != null)
foreach (var op in ballots.Result)
if (ballotsSub.Addresses.TryGetValue(op.Delegate.Address, out var delegateSubs))
Add(delegateSubs, op);
}
if (proposals.Result.Any())
{
if (proposalsSub.All != null)
AddRange(proposalsSub.All, proposals.Result);
if (proposalsSub.Addresses != null)
foreach (var op in proposals.Result)
if (proposalsSub.Addresses.TryGetValue(op.Delegate.Address, out var delegateSubs))
Add(delegateSubs, op);
}
if (activations.Result.Any())
{
if (activationsSub.All != null)
AddRange(activationsSub.All, activations.Result);
if (activationsSub.Addresses != null)
foreach (var op in activations.Result)
if (activationsSub.Addresses.TryGetValue(op.Account.Address, out var accountSubs))
Add(accountSubs, op);
}
if (doubleBaking.Result.Any())
{
if (doubleBakingSub.All != null)
AddRange(doubleBakingSub.All, doubleBaking.Result);
if (doubleBakingSub.Addresses != null)
foreach (var op in doubleBaking.Result)
{
if (doubleBakingSub.Addresses.TryGetValue(op.Accuser.Address, out var accuserSubs))
Add(accuserSubs, op);
if (doubleBakingSub.Addresses.TryGetValue(op.Offender.Address, out var offenderSubs))
Add(offenderSubs, op);
}
}
if (doubleEndorsing.Result.Any())
{
if (doubleEndorsingSub.All != null)
AddRange(doubleEndorsingSub.All, doubleEndorsing.Result);
if (doubleEndorsingSub.Addresses != null)
foreach (var op in doubleEndorsing.Result)
{
if (doubleEndorsingSub.Addresses.TryGetValue(op.Accuser.Address, out var accuserSubs))
Add(accuserSubs, op);
if (doubleEndorsingSub.Addresses.TryGetValue(op.Offender.Address, out var offenderSubs))
Add(offenderSubs, op);
}
}
if (revelations.Result.Any())
{
if (revelationsSub.All != null)
AddRange(revelationsSub.All, revelations.Result);
if (revelationsSub.Addresses != null)
foreach (var op in revelations.Result)
{
if (revelationsSub.Addresses.TryGetValue(op.Baker.Address, out var bakerSubs))
Add(bakerSubs, op);
if (revelationsSub.Addresses.TryGetValue(op.Sender.Address, out var senderSubs))
Add(senderSubs, op);
}
}
if (delegations.Result.Any())
{
if (delegationsSub.All != null)
AddRange(delegationsSub.All, delegations.Result);
if (delegationsSub.Addresses != null)
foreach (var op in delegations.Result)
{
if (op.Initiator != null && delegationsSub.Addresses.TryGetValue(op.Initiator.Address, out var initiatorSubs))
Add(initiatorSubs, op);
if (delegationsSub.Addresses.TryGetValue(op.Sender.Address, out var senderSubs))
Add(senderSubs, op);
if (op.PrevDelegate != null && delegationsSub.Addresses.TryGetValue(op.PrevDelegate.Address, out var prevSubs))
Add(prevSubs, op);
if (op.NewDelegate != null && delegationsSub.Addresses.TryGetValue(op.NewDelegate.Address, out var newSubs))
Add(newSubs, op);
}
}
if (originations.Result.Any())
{
if (originationsSub.All != null)
AddRange(originationsSub.All, originations.Result);
if (originationsSub.Addresses != null)
foreach (var op in originations.Result)
{
if (op.Initiator != null && originationsSub.Addresses.TryGetValue(op.Initiator.Address, out var initiatorSubs))
Add(initiatorSubs, op);
if (originationsSub.Addresses.TryGetValue(op.Sender.Address, out var senderSubs))
Add(senderSubs, op);
if (op.ContractManager != null && originationsSub.Addresses.TryGetValue(op.ContractManager.Address, out var managerSubs))
Add(managerSubs, op);
if (op.ContractDelegate != null && originationsSub.Addresses.TryGetValue(op.ContractDelegate.Address, out var delegateSubs))
Add(delegateSubs, op);
}
}
if (transactions.Result.Any())
{
if (transactionsSub.All != null)
AddRange(transactionsSub.All, transactions.Result);
if (transactionsSub.Addresses != null)
foreach (var op in transactions.Result)
{
if (op.Initiator != null && transactionsSub.Addresses.TryGetValue(op.Initiator.Address, out var initiatorSubs))
Add(initiatorSubs, op);
if (transactionsSub.Addresses.TryGetValue(op.Sender.Address, out var senderSubs))
Add(senderSubs, op);
if (op.Target != null && transactionsSub.Addresses.TryGetValue(op.Target.Address, out var targetSubs))
Add(targetSubs, op);
}
}
if (reveals.Result.Any())
{
if (revealsSub.All != null)
AddRange(revealsSub.All, reveals.Result);
if (revealsSub.Addresses != null)
foreach (var op in reveals.Result)
if (revealsSub.Addresses.TryGetValue(op.Sender.Address, out var senderSubs))
Add(senderSubs, op);
}
if (migrations.Result.Any())
{
if (migrationsSub.All != null)
AddRange(migrationsSub.All, migrations.Result);
if (migrationsSub.Addresses != null)
foreach (var op in migrations.Result)
if (migrationsSub.Addresses.TryGetValue(op.Account.Address, out var accountSubs))
Add(accountSubs, op);
}
if (penalties.Result.Any())
{
if (penaltiesSub.All != null)
AddRange(penaltiesSub.All, penalties.Result);
if (penaltiesSub.Addresses != null)
foreach (var op in penalties.Result)
if (penaltiesSub.Addresses.TryGetValue(op.Baker.Address, out var bakerSubs))
Add(bakerSubs, op);
}
if (baking.Result.Any())
{
if (bakingSub.All != null)
AddRange(bakingSub.All, baking.Result);
if (bakingSub.Addresses != null)
foreach (var op in baking.Result)
if (bakingSub.Addresses.TryGetValue(op.Baker.Address, out var bakerSubs))
Add(bakerSubs, op);
}
#endregion
#region send
foreach (var (connectionId, operations) in toSend.Where(x => x.Value.Count > 0))
{
var data = operations.Count > 1
? Distinct(operations).OrderBy(x => x.Id)
: (IEnumerable<Operation>)operations;
sendings.Add(Context.Clients
.Client(connectionId)
.SendData(OperationsChannel, data, State.Current.Level));
Logger.LogDebug("{0} operations sent to {1}", operations.Count, connectionId);
}
#endregion
}
catch (Exception ex)
{
Logger.LogError("Failed to process state change: {0}", ex.Message);
}
finally
{
Sema.Release();
#region await sendings
try
{
await Task.WhenAll(sendings);
}
catch (Exception ex)
{
// should never get here
Logger.LogError("Sendings failed: {0}", ex.Message);
}
#endregion
}
}
19
Source : DefaultQuotesProvider.cs
with MIT License
from baking-bad
with MIT License
from baking-bad
public virtual Task<IEnumerable<IDefaultQuote>> GetBtc(DateTime from, DateTime to)
=> Task.FromResult(Enumerable.Empty<IDefaultQuote>());
19
Source : DefaultQuotesProvider.cs
with MIT License
from baking-bad
with MIT License
from baking-bad
public virtual Task<IEnumerable<IDefaultQuote>> GetEur(DateTime from, DateTime to)
=> Task.FromResult(Enumerable.Empty<IDefaultQuote>());
19
Source : DefaultQuotesProvider.cs
with MIT License
from baking-bad
with MIT License
from baking-bad
public virtual Task<IEnumerable<IDefaultQuote>> GetUsd(DateTime from, DateTime to)
=> Task.FromResult(Enumerable.Empty<IDefaultQuote>());
19
Source : DefaultQuotesProvider.cs
with MIT License
from baking-bad
with MIT License
from baking-bad
public virtual Task<IEnumerable<IDefaultQuote>> GetCny(DateTime from, DateTime to)
=> Task.FromResult(Enumerable.Empty<IDefaultQuote>());
19
Source : DefaultQuotesProvider.cs
with MIT License
from baking-bad
with MIT License
from baking-bad
public virtual Task<IEnumerable<IDefaultQuote>> GetJpy(DateTime from, DateTime to)
=> Task.FromResult(Enumerable.Empty<IDefaultQuote>());
19
Source : DefaultQuotesProvider.cs
with MIT License
from baking-bad
with MIT License
from baking-bad
public virtual Task<IEnumerable<IDefaultQuote>> GetEth(DateTime from, DateTime to)
=> Task.FromResult(Enumerable.Empty<IDefaultQuote>());
19
Source : DefaultQuotesProvider.cs
with MIT License
from baking-bad
with MIT License
from baking-bad
public virtual Task<IEnumerable<IDefaultQuote>> GetKrw(DateTime from, DateTime to)
=> Task.FromResult(Enumerable.Empty<IDefaultQuote>());
19
Source : DefaultQuotesProvider.cs
with MIT License
from baking-bad
with MIT License
from baking-bad
public virtual Task<IEnumerable<IDefaultQuote>> GetGbp(DateTime from, DateTime to)
=> Task.FromResult(Enumerable.Empty<IDefaultQuote>());
19
Source : BarrelCacheProvider.cs
with MIT License
from Baseflow
with MIT License
from Baseflow
public virtual Task<IEnumerable<TContenreplacedem>> GetAll()
{
try
{
var items = _barrel.GetOrCreate<IEnumerable<TContenreplacedem>>(CacheName, new List<TContenreplacedem>());
return Task.FromResult(items);
}
catch
{ }
return Task.FromResult<IEnumerable<TContenreplacedem>>(null);
}
19
Source : UserControllerTest.cs
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
[Fact]
public async void GetUsersAsync_Success()
{
// Arrange
var helper = new TestHelper();
var controller = helper.CreateController<UserController>(Permissions.AdminUsers);
var mapper = helper.GetService<IMapper>();
var service = helper.GetService<Mock<IPimsKeycloakService>>();
var user = new Enreplacedy.User(Guid.NewGuid(), "test", "[email protected]");
var users = new[] { user };
service.Setup(m => m.GetUsersAsync(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<string>())).Returns(Task.FromResult((IEnumerable<Enreplacedy.User>)users));
// Act
var result = await controller.GetUsersAsync(1, 10);
// replacedert
var actionResult = replacedert.IsType<JsonResult>(result);
replacedert.Null(actionResult.StatusCode);
var data = replacedert.IsType<Model.UserModel[]>(actionResult.Value);
replacedert.Equal(mapper.Map<Model.UserModel[]>(users), data, new DeepPropertyCompare());
service.Verify(m => m.GetUsersAsync(1, 10, It.IsAny<string>()), Times.Once());
}
19
Source : RoleControllerTest.cs
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
[Fact]
public async void SyncRolesAsync_Success()
{
// Arrange
var user = PrincipalHelper.CreateForRole("admin-users");
var helper = new TestHelper();
var controller = helper.CreateController<RoleController>(user);
var mapper = helper.GetService<IMapper>();
var service = helper.GetService<Mock<IPimsKeycloakService>>();
var erole = new Enreplacedy.Role(Guid.NewGuid(), "test");
var eroles = new[] { erole };
service.Setup(m => m.SyncRolesAsync()).Returns(Task.FromResult((IEnumerable<Enreplacedy.Role>)eroles));
// Act
var result = await controller.SyncRolesAsync();
// replacedert
var actionResult = replacedert.IsType<JsonResult>(result);
var data = replacedert.IsType<Model.RoleModel[]>(actionResult.Value);
replacedert.Equal(mapper.Map<Model.RoleModel[]>(eroles), data, new DeepPropertyCompare());
service.Verify(m => m.SyncRolesAsync(), Times.Once());
}
19
Source : RoleControllerTest.cs
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
[Fact]
public async void GetRolesAsync_Success()
{
// Arrange
var user = PrincipalHelper.CreateForRole("admin-users");
var helper = new TestHelper();
var controller = helper.CreateController<RoleController>(user);
var mapper = helper.GetService<IMapper>();
var service = helper.GetService<Mock<IPimsKeycloakService>>();
var erole = new Enreplacedy.Role(Guid.NewGuid(), "test");
var eroles = new[] { erole };
service.Setup(m => m.GetRolesAsync(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<string>())).Returns(Task.FromResult((IEnumerable<Enreplacedy.Role>)eroles));
// Act
var result = await controller.GetRolesAsync(1, 10);
// replacedert
var actionResult = replacedert.IsType<JsonResult>(result);
var data = replacedert.IsType<Model.RoleModel[]>(actionResult.Value);
replacedert.Equal(mapper.Map<Model.RoleModel[]>(eroles), data, new DeepPropertyCompare());
service.Verify(m => m.GetRolesAsync(1, 10, It.IsAny<string>()), Times.Once());
}
19
Source : GameIndexServiceTests.cs
with MIT License
from bcssov
with MIT License
from bcssov
[Fact]
public async Task Should_load_definitions()
{
DISetup.SetupContainer();
var storageProvider = new Mock<IStorageProvider>();
var modParser = new Mock<IModParser>();
var parserManager = new Mock<IParserManager>();
var reader = new Mock<IReader>();
var modWriter = new Mock<IModWriter>();
var gameService = new Mock<IGameService>();
var mapper = new Mock<IMapper>();
var gameIndexer = new Mock<IGameIndexer>();
storageProvider.Setup(p => p.GetRootStoragePath()).Returns("c:\\test");
gameIndexer.Setup(p => p.GameVersionsSameAsync(It.IsAny<string>(), It.IsAny<IGame>(), It.IsAny<IEnumerable<string>>())).Returns((string p1, IGame p2, IEnumerable<string> p3) => Task.FromResult(true));
var gameDefs = new List<IDefinition>() { new Definition() { File = "test\\testgame.txt", Type = "test", Id = "2", ModName = "test game" } };
gameIndexer.Setup(p => p.GetDefinitionsAsync(It.IsAny<string>(), It.IsAny<IGame>(), It.IsAny<string>())).Returns((string p1, IGame p2, string p3) => Task.FromResult(gameDefs as IEnumerable<IDefinition>));
var defs = new IndexedDefinitions();
defs.InitMap(new List<IDefinition>()
{
new Definition()
{
File = "test\\test.txt",
Type = "test",
Id = "1",
ModName = "test"
}
});
var service = GetService(gameIndexer, storageProvider, modParser, parserManager, reader, mapper, modWriter, gameService);
var result = await service.LoadDefinitionsAsync(defs, new Game() { Name = "fake game" }, new List<string>() { "3.0.3" });
result.GetAll().Count().Should().Be(2);
result.GetAll().FirstOrDefault(p => p.ModName == "fake game").Should().NotBeNull();
}
19
Source : EnumerableSelectExtensionsTests.cs
with MIT License
from BEagle1984
with MIT License
from BEagle1984
[Fact]
public async Task SelectManyAsync_Function_Selected()
{
var enumerable = Enumerable.Range(1, 5);
var result =
await enumerable.SelectManyAsync(i => Task.FromResult(new[] { i, i }.AsEnumerable()));
result.Should().BeEquivalentTo(new[] { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5 });
}
19
Source : EnumerableSelectExtensionsTests.cs
with MIT License
from BEagle1984
with MIT License
from BEagle1984
[Fact]
public async Task ParallelSelectManyAsync_Function_Selected()
{
var enumerable = Enumerable.Range(1, 5);
var result =
await enumerable.ParallelSelectManyAsync(i => Task.FromResult(new[] { i, i }.AsEnumerable()));
result.Should().BeEquivalentTo(new[] { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5 });
}
19
Source : WidgetRepository.cs
with MIT License
from BenMorris
with MIT License
from BenMorris
public async Task<IEnumerable<Widget>> ListAsync()
{
// Dummy reference used to demonstrate a dependency on System.Data
var table = new System.Data.DataTable();
return await Task.FromResult<IEnumerable<Widget>>(
new List<Widget>
{
new Widget{ Id = 1, Name = "Widget 1", Invalid = false },
new Widget{ Id = 2, Name = "Widget 2", Invalid = true }
});
}
19
Source : RedisDataManager.cs
with MIT License
from berdon
with MIT License
from berdon
public Task<IEnumerable<RedisValue>> GetQueueMessagesAsync(int count)
{
var startTime = DateTimeOffset.UtcNow;
try
{
if (_droppedMessagesCount > 0)
{
_logger.Warning("Dropped {Count} messages on the floor due to overflowing cache size", _droppedMessagesCount);
_droppedMessagesCount = 0;
}
if (_queue.Count <= 0) return Task.FromResult(EmptyRedisValueEnumerable);
if (count < 0 || count == UnlimitedMessageCount)
{
count = _queue.Count;
}
var items = new List<RedisValue>();
while(items.Count < count && _queue.TryDequeue(out var item))
{
items.Add(item);
}
_logger.Debug("Retrieved {Count} messages", items.Count);
return Task.FromResult(items.AsEnumerable());
}
catch (Exception exc)
{
ReportErrorAndRethrow(exc);
throw; // Can't happen
}
finally
{
CheckAlertSlowAccess(startTime);
}
}
19
Source : UserRepository.cs
with MIT License
from billyang
with MIT License
from billyang
public Task<IEnumerable<User>> GetAllEnreplacedy(String connectionString = null)
{
using (IDbConnection conn = DataBaseConfig.GetSqlConnection(connectionString))
{
string querySql = @"SELECT Id ,
TenantId ,
Name ,
Preplacedword ,
SecurityStamp ,
FullName ,
Surname ,
PhoneNumber ,
IsPhoneNumberConfirmed ,
EmailAddress ,
IsEmailConfirmed ,
EmailConfirmationCode ,
IsActive ,
PreplacedwordResetCode ,
LastLoginTime ,
IsLockoutEnabled ,
AccessFailedCount ,
LockoutEndDateUtc
FROM dbo.auth_User;";
return Task.FromResult<IEnumerable<User>>(conn.Query<User>(querySql));
}
}
19
Source : SpecEventStore.cs
with MIT License
from binarymash
with MIT License
from binarymash
public Task<IEnumerable<IEvent>> Get(Guid aggregateId, int fromVersion, CancellationToken cancellationToken = default(CancellationToken))
{
var events = Events.Where(x => x.Id == aggregateId && x.Version > fromVersion);
return Task.FromResult(events);
}
19
Source : ImageService.cs
with MIT License
from bjorkstromm
with MIT License
from bjorkstromm
public Task<IEnumerable<ImageLocation>> GetImagesByTagAsync(string tag)
{
if (!IsEnabled)
{
return Task.FromResult(Enumerable.Empty<ImageLocation>());
}
return GetImagesByTagAsync(tag, 5);
}
19
Source : DefaultSignProvider.cs
with GNU Affero General Public License v3.0
from blockbasenetwork
with GNU Affero General Public License v3.0
from blockbasenetwork
public Task<IEnumerable<string>> GetAvailableKeys()
{
return Task.FromResult(Keys.Keys.AsEnumerable());
}
19
Source : DefaultSignProvider.cs
with GNU Affero General Public License v3.0
from blockbasenetwork
with GNU Affero General Public License v3.0
from blockbasenetwork
public Task<IEnumerable<string>> Sign(string chainId, IEnumerable<string> requiredKeys, byte[] signBytes, IEnumerable<string> abiNames = null)
{
if (requiredKeys == null)
return Task.FromResult(new List<string>().AsEnumerable());
var availableAndReqKeys = requiredKeys.Intersect(Keys.Keys);
var data = new List<byte[]>()
{
Hex.HexToBytes(chainId),
signBytes,
new byte[32]
};
var hash = Sha256Manager.GetHash(SerializationHelper.Combine(data));
return Task.FromResult(availableAndReqKeys.Select(key =>
{
var sign = Secp256K1Manager.SignCompressedCompact(hash, Keys[key]);
var check = new List<byte[]>() { sign, KeyTypeBytes };
var checksum = Ripemd160Manager.GetHash(SerializationHelper.Combine(check)).Take(4).ToArray();
var signAndChecksum = new List<byte[]>() { sign, checksum };
return "SIG_K1_" + Base58.Encode(SerializationHelper.Combine(signAndChecksum));
}));
}
19
Source : UnitTest1.cs
with MIT License
from BrightSoul
with MIT License
from BrightSoul
[TestMethod]
public async Task GET_action_of_ValuesController_should_return_previously_POSTed_value()
{
//Prepariamo il test
var testValue = "aspitalia";
//Creiamo al volo un'implementazione di IValuesRepository...
var mockValuesRepository = Subsreplacedute.For<IValuesRepository>();
//E ora la "configuriamo" impostando solo il comportamento di cui abbiamo bisogno per questo test
//In particolare, ci serve tenere un riferimento ai valori aggunti
var valueList = new List<(int Id, string Value)>();
//E facciamo l'aggiunta quando il ValuesController invoca il metodo Create sull'oggetto IValuesRepository
mockValuesRepository.When(mock => mock.Create(Arg.Any<string>())).Do(callInfo => valueList.Add((valueList.Count + 1, callInfo.Arg<string>())));
//La proprietà All del repository resreplaceduirà la lista
mockValuesRepository.GetAll().Returns(Task.FromResult((IEnumerable<(int Id, string Value)>) valueList));
//Creiamo il controller
var controller = new ValuesController(mockValuesRepository);
//Esercitiamo il nostro controller inserendo un valore...
await controller.Post(testValue);
//...e receuperando l'elenco dei valori inseriti
var results = await controller.Get();
//Verifichiamo che le aspettative siano rispettate
//L'elenco di risultati deve contenere un solo valore
replacedert.AreEqual(1, results.Count());
//E tale valore deve essere "aspitalia"
replacedert.AreEqual(testValue, results.First().Value);
//Verifichiamo che il metodo Create sia stato invocato
mockValuesRepository.Received().Create(testValue);
}
19
Source : MockJobManager.cs
with MIT License
from brminnick
with MIT License
from brminnick
public Task<IEnumerable<JobInfo>> GetJobs() => Task.FromResult(_jobDictionary.Values.AsEnumerable());
19
Source : MockNotificationManager.cs
with MIT License
from brminnick
with MIT License
from brminnick
public Task<IEnumerable<Notification>> GetPending() => Task.FromResult(_pendingNotificationsDitcionary.Values.AsEnumerable());
19
Source : DefaultServiceRouteFactory.cs
with MIT License
from brucehu123
with MIT License
from brucehu123
public Task<IEnumerable<ServiceRoute>> CreateServiceRoutesAsync(IEnumerable<ServiceRouteDescriptor> descriptors)
{
if (descriptors == null)
throw new ArgumentNullException(nameof(descriptors));
descriptors = descriptors.ToArray();
var routes = new List<ServiceRoute>(descriptors.Count());
routes.AddRange(descriptors.Select(descriptor => new ServiceRoute
{
Address = CreateAddress(descriptor.AddressDescriptors),
ServiceDescriptor = descriptor.ServiceDescriptor
}));
return Task.FromResult(routes.AsEnumerable());
}
19
Source : EnvironmentAppServiceFixture.cs
with Apache License 2.0
from brunobrandes
with Apache License 2.0
from brunobrandes
[Fact]
public void GetByProjectAsync_Shold_Be_Success()
{
_environmentRepositoryMock.Setup(x => x.GetByProjectAsync(It.IsAny<string>()))
.Returns(Task.FromResult<IEnumerable<Domain.Enreplacedies.Environment>>(new List<Domain.Enreplacedies.Environment>() { GetEnreplacedyEnvironment() }));
var environmentAppService = new EnvironmentAppService(_mapper.Object, _environmentValidator,
GetCosmosToggleDataContext(_environmentRepositoryMock.Object), _notificationContext.Object, _authAppServiceMock.Object);
Func<Task> action = async () => { await environmentAppService.GetByProjectAsync("123456"); };
action.Should().NotThrowAsync();
}
19
Source : EnvironmentAppServiceFixture.cs
with Apache License 2.0
from brunobrandes
with Apache License 2.0
from brunobrandes
[Fact]
public void GetByProjectAsync_Shold_Be_NullAndHasNotFoundNotification()
{
_environmentRepositoryMock.Setup(x => x.GetByProjectAsync(It.IsAny<string>()))
.Returns(Task.FromResult<IEnumerable<Domain.Enreplacedies.Environment>>(null));
var notificationContext = new NotificationContext { };
var environmentAppService = new EnvironmentAppService(_mapper.Object, _environmentValidator,
GetCosmosToggleDataContext(_environmentRepositoryMock.Object), notificationContext, _authAppServiceMock.Object);
Func<Task> action = async () => { await environmentAppService.GetByProjectAsync("123456"); };
action.Should().NotThrowAsync();
notificationContext.HasNotifications.Should().Be(true);
notificationContext.Notifications.Where(x => x.Code == HttpStatusCode.NotFound);
}
19
Source : FakeOidcConfigurationManager.cs
with MIT License
from bryanknox
with MIT License
from bryanknox
public async Task<IEnumerable<SecurityKey>> GetIssuerSigningKeysAsync()
{
++GetIssuerSigningKeysAsyncCalledCount;
if (ExceptionMessageForTest != null)
{
throw new TestException(ExceptionMessageForTest);
}
return await Task.FromResult(SecurityKeysForTest);
}
19
Source : StarWarsCharacterResolver.cs
with MIT License
from cajuncoding
with MIT License
from cajuncoding
[UseSorting]
[GraphQLName("starWarsCharacters")]
public Task<IEnumerable<IStarWarsCharacter>> GetStarWarsCharactersAsync()
{
var results = CreateCharacters();
return Task.FromResult(results);
}
19
Source : NetworkConnectionServiceMock.cs
with MIT License
from CalciumFramework
with MIT License
from CalciumFramework
public Task<IEnumerable<WirelessNetwork>> GetWirelessNetworksAsync()
{
return Task.FromResult((IEnumerable<WirelessNetwork>)WirelessNetworks);
}
19
Source : AllContactsViewModel.cs
with MIT License
from canbilgin
with MIT License
from canbilgin
public Task<IEnumerable<Person>> GetPlayersAsync()
{
if (!_contacts.Any())
{
_contacts = new List<Person>(PlayerFactory.Players);
}
else
{
AddPlayer();
}
//_contacts[callCount++].Position += "-Updated";
return Task.FromResult(new List<Person>(_contacts.Select(item=>item.Clone())) as IEnumerable<Person>);
}
19
Source : InMemoryEventStorageProvider.cs
with MIT License
from CanerPatir
with MIT License
from CanerPatir
public Task<IEnumerable<IEvent<TAggregateKey>>> GetEventsAsync(TAggregateKey aggregateId, int start, int count)
{
try
{
IEnumerable<IEvent<TAggregateKey>> result = null;
if (_eventStream.ContainsKey(aggregateId))
{
//this is needed for make sure it doesn't fail when we have int.maxValue for count
if (count > int.MaxValue - start)
{
count = int.MaxValue - start;
}
result = _eventStream[aggregateId].Where(
o =>
(_eventStream[aggregateId].IndexOf(o) >= start) &&
(_eventStream[aggregateId].IndexOf(o) < (start + count)))
.ToArray();
}
else
{
result = new List<IEvent<TAggregateKey>>();
}
return Task.FromResult(result);
}
catch (Exception ex)
{
throw new AggregateNotFoundException($"The aggregate with {aggregateId} was not found. Details {ex.Message}");
}
}
19
Source : InMemorySpanQuery.cs
with MIT License
from capricornus-platform
with MIT License
from capricornus-platform
public Task<IEnumerable<Trace>> GetTraces(TraceQuery traceQuery)
{
var query = _dbContext.Spans.Include(x => x.Tags).OrderByDescending(x => x.StartTimestamp).AsQueryable();
if (traceQuery.StartTimestamp != null)
{
query = query.Where(x => x.StartTimestamp >= traceQuery.StartTimestamp);
}
if (traceQuery.FinishTimestamp != null)
{
query = query.Where(x => x.FinishTimestamp <= traceQuery.FinishTimestamp);
}
var queryTags = BuildQueryTags(traceQuery).ToList();
if (queryTags.Any())
{
var traceIdsQuery = query;
foreach (var item in queryTags)
{
var tag = item;
traceIdsQuery = traceIdsQuery.Where(x => x.Tags.Any(t => t.Key == tag.Key && t.Value == tag.Value));
}
var traceIds = traceIdsQuery.Select(x => x.TraceId).Distinct().ToList();
query = query.Where(x => traceIds.Contains(x.TraceId));
}
var queryGroup = query.ToList().GroupBy(x => x.TraceId).Take(traceQuery.Limit).ToList();
return Task.FromResult<IEnumerable<Trace>>(queryGroup.Select(x => new Trace() { TraceId = x.Key, Spans = _mapper.Map<List<Span>>(x.ToList()) }).ToList());
}
19
Source : InMemorySpanQuery.cs
with MIT License
from capricornus-platform
with MIT License
from capricornus-platform
public Task<IEnumerable<TraceHistogram>> GetTraceHistogram(TraceQuery traceQuery)
{
traceQuery.Ensure();
var query = _dbContext.Spans.AsQueryable();
if (traceQuery.StartTimestamp != null)
{
query = query.Where(x => x.StartTimestamp >= traceQuery.StartTimestamp);
}
if (traceQuery.FinishTimestamp != null)
{
query = query.Where(x => x.FinishTimestamp <= traceQuery.FinishTimestamp);
}
var queryGroup = query.ToList().GroupBy(x => x.TraceId).ToList();
var histogram = queryGroup.GroupBy(x => x.Min(s => s.StartTimestamp).ToString("yyyy-MM-dd HH:mm")).Select(x => new TraceHistogram { Count = x.Count(), Time = DateTimeOffset.Parse(x.Key) });
return Task.FromResult<IEnumerable<TraceHistogram>>(histogram.ToList());
}
19
Source : CodeFixService.cs
with Apache License 2.0
from cdy816
with Apache License 2.0
from cdy816
public override Task<IEnumerable<Diagnostic>> GetDoreplacedentDiagnosticsAsync(Doreplacedent doreplacedent, CancellationToken cancellationToken)
=> Task.FromResult<IEnumerable<Diagnostic>>(_diagnostics);
See More Examples