Skip to content

Instantly share code, notes, and snippets.

public void ConfigureServices(IServiceCollection services)
{
services.AddNester();
// 1. Set API Version
services.AddDbContext<JwtauthContext>(options =>
options.UseSqlite("Data Source=/var/app/source/shared/Jwtauth.db"));
services.AddScoped<IIndustryRepository, IndustryRepository>();
services.AddApiVersioning(options => {
public class IndustryConfiguration : IEntityTypeConfiguration<Industry>
{
public void Configure(EntityTypeBuilder<Industry> builder)
{
builder.HasKey(o => o.Id);
builder.Property(o => o.Tag)
.IsRequired()
.HasColumnType("varchar(64)");
builder.HasIndex(o => o.Tag)
// This configures the Trader Table
public class TraderConfiguration : IEntityTypeConfiguration<Trader>
{
public void Configure(EntityTypeBuilder<Trader> builder)
{
builder.Property(o => o.DateJoined)
.IsRequired()
.HasColumnType("datetime");
public class UnitTests
{
[Fact]
public async void TestSearchAsync()
{
/*
Perform a search and return results
*/
// Arrange
public class UnitTests
{
[Fact]
public void TestSearch()
{
// Arrange
var mockRuntime = new Mock<Runtime>(
QueueMode.Server | QueueMode.Client,
180, Enviorenment.Development
) {CallBase = true};
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.ConfigureLogging(logging =>
{
logging.AddNesterLog(LogLevel.Information);
})
.UseStartup<Startup>();
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> SendMessage(MessageView msgView)
{
// Send a push notification to Slack
_runtime.Chirpy.Chirp("Message [{0}] received by {1}, dispatching to workers",
msgView.Edit.Text, _runtime.ComponentId);
if (ModelState.IsValid)
{
static void Main(string[] args)
{
Runtime runtime = new Runtime(QueueMode.Server | QueueMode.Client);
ILoggerFactory loggerFactory = new LoggerFactory()
.AddDebug(LogLevel.Debug)
.AddNesterLog(LogLevel.Debug);
ILogger logger = loggerFactory.CreateLogger<Bitbucket>();
BitbucketRepository repo = new BitbucketRepository(runtime, logger);
private List<SearchResult> CollectResults(Dictionary<string, string> queryServices)
{
List<SearchResult> results = new List<SearchResult>();
int pendingResultsCount = queryServices.Count;
DateTime start = DateTime.Now;
while (pendingResultsCount > 0 && (DateTime.Now - start).TotalSeconds < 10 )
{
var returnedSingle = _runtime.ReceiveSingle<SearchResult>();
private string QueryService(string text, string service)
{
Inkton.Nest.Model.Nest searchNest = _runtime.GetNest(service);
SearchQuery query = new SearchQuery();
query.Id = _runtime.ComponentId + "." + DateTime.Now.Ticks.ToString();
query.Service = service;
query.MaxResults = 100;
query.Text = text;