Skip to content

Instantly share code, notes, and snippets.

View rajanadar's full-sized avatar

Raja Nadar rajanadar

View GitHub Profile
@rajanadar
rajanadar / GenericDbSetMockingMethods.cs
Last active May 27, 2020 13:56
Generic Method to translate Queryable data list into mocked DbSet Entity for Entity Framework DbContext Testing
// Author: Raja
// Generic Method to translate Queryable data list into mocked DbSet Entity for Entity Framework DbContext Testing
private static DbSet<TEntity> GetMockedDbSetFromQueryable<TEntity>(IQueryable<TEntity> data) where TEntity : class
{
var mockSet = new Mock<DbSet<TEntity>>();
mockSet.As<IQueryable<TEntity>>().Setup(m => m.Provider).Returns(data.Provider);
mockSet.As<IQueryable<TEntity>>().Setup(m => m.Expression).Returns(data.Expression);
mockSet.As<IQueryable<TEntity>>().Setup(m => m.ElementType).Returns(data.ElementType);
@rajanadar
rajanadar / CloudFoundrySignatureProviderForVault
Created November 24, 2020 13:48
Helper class to generate on-demand CloudFoundry signature in .NET Applications
using System;
using System.IO;
using System.Text;
using Org.BouncyCastle.Asn1;
using Org.BouncyCastle.Asn1.Pkcs;
using Org.BouncyCastle.Crypto.Digests;
using Org.BouncyCastle.Crypto.Engines;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.Crypto.Signers;
using Org.BouncyCastle.Utilities.IO.Pem;