Skip to content

Instantly share code, notes, and snippets.

@Deneas
Deneas / ScoreboardAfter.cs
Last active June 8, 2021 20:40
Student Scoring Example
// Licensed under the MIT License
public class Scoreboard
{
public readonly List<StudentScore> Scores = new List<StudentScore>();
// inspired by AddItem method in https://github.com/dotnet-architecture/eShopOnWeb/blob/master/src/ApplicationCore/Entities/BasketAggregate/Basket.cs
public void AddScore(Student student, int score)
{
if (!Scores.Any(_ => _.Student.Equals(student)))
{
Scores.Add(new StudentScore(student, score));
@Deneas
Deneas / StudentValidationTestAfter.cs
Last active June 6, 2021 14:35
Student Validation Example
// Licensed under the MIT License
public class StudentValidationTest
{
[Fact]
public void IsAdultAndHasPaid_IsValid()
{
var student = new Student(18, true);
var isValid = StudentValidator.IsValid(student);
Assert.True(isValid);
}
@Deneas
Deneas / SingleCsFile.tt
Created November 12, 2020 22:29
Merges all .cs files of a project into a single one. Quick and dirty, but it should be enough for programming competition like on Codingame
<#@ template debug="false" hostspecific="True" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ assembly name="EnvDte" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ import namespace="System.Text.RegularExpressions" #>
<#@ import namespace="System" #>
<#@ output extension=".generated.cs" #>
namespace SingleFile {