Skip to content

Instantly share code, notes, and snippets.

View chsami's full-sized avatar

chsami chsami

View GitHub Profile
_fixture.Register<Animal>(() => null);
_fixture.Customizations.Add(
new TypeRelay(
typeof(Animal),
typeof(Dog)));
_fixture.Customizations.Add(
new TypeRelay(
typeof(Animal),
typeof(Cat)));
public class Person {
List<Person> Friends { get; set;}
}
//This code is needed to support recursion
_fixture.Behaviors.OfType<ThrowingRecursionBehavior>().ToList()
.ForEach(b => _fixture.Behaviors.Remove(b));
_fixture.Behaviors.Add(new OmitOnRecursionBehavior(1));
var parents = await _context.Set<Parent>()
.Include(m => (m as Child1).Property1)
Include(m => (m as Child2).Property1)
.ToListAsync();
<label for="my-lovely-checkbox">Some label text</label>
<input type="checkbox" id="my-lovely-checkbox" />
@chsami
chsami / fetch.ts
Last active February 2, 2019 11:41
export class MoviesComponent {
constructor() {}
getMovies(): void {
this.http.get('http://example.com/movies.json').toPromise().then((response) => {
console.log(response);
});
}
// delegate to your own implementation
spyOn(MoviesComponent, 'getMovies').and.callFake(() => {});
//delegate to your own implementation with an argument
spyOn(MoviesComponent, 'getMovies').withArgs('').and.callFake(() => {});
//return a specific value 'false'
spyon(MoviesComponent, 'getMovies').and.returnValue({movies: ['terminator', 'titanic', 'avatar']}});
//delegate to the actual implementation
@chsami
chsami / strip.typename.property.ts
Created January 16, 2019 20:15
strip javascript property
this.blogs.forEach((blog: any) => { delete blog.__typename; });
@chsami
chsami / AuthenticationHelper.cs
Last active January 14, 2019 21:14
Pagination Class
public class AuthenticationHelper : IAuthenticationHelper
{
static string ApplicationName = "APPLICATIONNAME";
static string RefreshToken = "YOURREFRESHTOKEN";
public DriveService Authenticate()
{
var token = new TokenResponse
{
RefreshToken = RefreshToken