Skip to content

Instantly share code, notes, and snippets.

View masaab's full-sized avatar
💭
Working on sharing knowledge

masaab mushtaq masaab

💭
Working on sharing knowledge
View GitHub Profile
@masaab
masaab / Restaurant.cs
Last active April 19, 2020 05:57
Creating bread in restaurant
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace ConsoleApp3
{
class Program
{
private const int _numberofBreads = 10;
@masaab
masaab / Restaurant.cs
Last active April 19, 2020 05:58
serving bread the yemeni way
public async IAsyncEnumerable<int> GetBreadYemeniWayAsync(int numberOfBreads)
{
for (int i = 1; i <= numberOfBreads; i++)
{
Console.WriteLine($"Baking Yemeni Bread:{i}");
await Task.Delay(1000);
yield return i;
}
}
@masaab
masaab / Restaurant.cs
Last active April 19, 2020 05:58
Serving Bread the indian way
public async Task<IEnumerable<int>> GetBreadIndianWayAsync(int numberOfBreads)
{
List<int> breadList = new List<int>();
for (int i = 1; i <= numberOfBreads; i++)
{
Console.WriteLine($"Baking Indian Bread: {i}");
await Task.Delay(1000);
breadList.Add(i);
}
return breadList;
@masaab
masaab / GetIAsyncEnumerableItems.cs
Created April 15, 2020 05:27
return mocked item for IAyncEnumerable using AutoFixture
public async IAsyncEnumerable<ScheduledJob> GetXNumberofScheduledJobs(int totalNumberofScheduledJob)
{
AutoFixture = new Fixture();
IEnumerator<ScheduledJob> enumerator = AutoFixture.CreateMany<ScheduledJob>(5).GetEnumerator();
while (enumerator.MoveNext())
{
yield return enumerator.Current;
}
}