Skip to content

Instantly share code, notes, and snippets.

View MarcoNicolodi's full-sized avatar

Marco Nicolodi MarcoNicolodi

View GitHub Profile
@MarcoNicolodi
MarcoNicolodi / default.blade.php
Created August 28, 2017 02:34
Laravel 5 Foundation 6 Pagination
@if($paginator->hasPages())
<ul class="pagination" role="navigation" aria-label="Pagination">
{{-- Previous Page Link --}}
@if ($paginator->onFirstPage())
<li class="pagination-previous disabled">Previous <span class="show-for-sr">page</span></li>
@else
<li class="pagination-previous"><a href="{{ $paginator->previousPageUrl() }}">Previous <span class="show-for-sr">page</span></a></li>
@endif
{{-- Pagination Elements --}}
@MarcoNicolodi
MarcoNicolodi / javascriptreact.json
Last active April 17, 2018 17:00
React code snippets
"Enzyme boilerplate" : {
"prefix": "enzyme boilerplate",
"body": [
"import React from 'react';",
"import { shallow } from 'enzyme';",
"import ${1: component} from '${2: module}';",
"",
"describe('${3:describe}', () => {",
" it('should ${4:test}', () => {",
" });",
@MarcoNicolodi
MarcoNicolodi / DocumentService.cs
Created August 7, 2018 18:15
Método gigante no DocumentService
public async Task<Document> Update(int id, UpdateDocumentMutation mutation)
{
var document = _context.Documents
.Include(d => d.Category)
.Include(d => d.SuggestedCode)
.Include(d => d.Revisions)
.ThenInclude(r => r.Files)
.Include(d => d.Revisions)
.ThenInclude(r => r.Stages)
.ThenInclude(s => s.Stage)
using System;
using System.Linq;
namespace ChainOfResponsability {
//pseudo classes
public class Eficacia
{
public int Eficaz { get; internal set; }
}
@MarcoNicolodi
MarcoNicolodi / DocumentWriteServiceInstantiation.cs
Last active January 13, 2019 20:29
Flaky unit test suite
var service = new DocumentWriteService(null, null, null, business, null, null, context, eventBus, _logger);
@MarcoNicolodi
MarcoNicolodi / RepeatingTestFixture.cs
Created January 13, 2019 14:30
Flaky unit test suite
var elaboration = new Stage() { Type = StageType.Elaboration, Name = "Elaboration" };
var approval = new Stage() { Type = StageType.Approval, Name = "Approval" };
var consensus = new Stage() { Type = StageType.Approval, Name = "Consensus" };
context.Stages.Add(elaboration);
context.Stages.Add(approval);
context.Stages.Add(consensus);
var oldCategory = new Category()
{
@MarcoNicolodi
MarcoNicolodi / ObjectMother.cs
Created January 13, 2019 20:23
Flaky unit test suite
var document = DocumentMother.DocumentWithOnePublishedAndOnePendingRevisionInApproval(elaborator: UserMother.SteveJobs(), approvers: approvers);
@MarcoNicolodi
MarcoNicolodi / Builder.cs
Created January 13, 2019 20:38
Flaky unit test suite
var service = new DocumentWriteServiceBuilder()
.WithBusiness(business)
.WithContext(context)
.WithEventBus(eventBus)
.Build();
@MarcoNicolodi
MarcoNicolodi / XUnitDefaultAssertion.cs
Created January 13, 2019 20:44
Flaky unit test suite
Assert.Equal(revision.Changes, documentMutation.Changes);
Assert.True(elaborationResult.Approved);
Assert.Equal(2, revision.Stages.Count);
Assert.Equal(lastStage.StageId, approval.Id);
Assert.Equal(2, lastStage.Order);
Assert.Equal(117, stageResult.ResponsibleId);
@MarcoNicolodi
MarcoNicolodi / FluentAssertions.cs
Created January 13, 2019 20:46
Flaky unit test suite
revision.Changes.Should().Be(requestPayload.Changes, "because this is what changed in the revision");
elaborationResult.Approved.Should().BeTrue("because we just completed the elaboration stage");
revision.Stages.Count.Should().Be(2, "because the next stage has been created");
createdStage.Order.Should().Be(2, "because it happens after the elaboration");
createdStage.StageId.Should().Be(StageMother.ApprovalStageid, "because the next stage is the approval stage");
createdStageResult.ResponsibleId.Should().Be(DocumentMother.ApprovalResponsibleId, "because its the responsible for the approval stage of this document");