This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using NSubstitute; | |
| public interface IFoo | |
| { | |
| int Bar(int k); | |
| void Foo(); | |
| void Foobar(); | |
| } | |
| class Program |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace BadListExercise | |
| { | |
| public class BadList | |
| { | |
| private class Node | |
| { | |
| public Node(int data) | |
| { | |
| Data = data; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class SEK : IKrBasedCurrency<SEK> | |
| { | |
| public static decimal Factor => 0.75M; | |
| public decimal Value { get; init; } | |
| public SEK(){} | |
| public SEK(decimal value){Value = value;} | |
| public static implicit operator SEK(DKK v) => DKK.Change<SEK>(v); | |
| public static implicit operator DKK(SEK v) => DKK.Change(v); | |
| public static DKK operator +(SEK left, DKK right) => ((DKK)left) + right; | |
| public override string ToString() => $"({this.GetType().Name}){Value}"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| DKK kr = new DKK { Value = 14 }; | |
| Console.WriteLine(kr); // (DKR)14 | |
| USD usd = kr + kr; | |
| Console.WriteLine(usd); // (USD)4 | |
| SEK sek = new SEK { Value = 14 }; | |
| Console.WriteLine(sek); // (SEK)14 | |
| Console.WriteLine((DKK)sek); // (DKK)10.5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public T Fibonacci<T>(T n) where T: IBasicOps<T> | |
| { | |
| if (n.Equals(T.Zero) || n.Equals(T.One)) | |
| return n; | |
| return Fibonacci(n - T.One) + Fibonacci(n - (T.One + T.One)); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void Foo() => Console.Write("Observer pattern"); | |
| void Bar() { Console.Write("For fun"); } | |
| ISubject fun = null; //initialize before use :( | |
| fun += Foo; | |
| fun += () => Console.Write(" with fancy syntax "); | |
| fun += Bar; | |
| fun += () => Console.WriteLine(" and profit..."); | |
| fun.Notify(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [Fact] | |
| public void Add_SumOfTwoZeros() | |
| { | |
| int a = 0, b = 0, expected = 0; | |
| var c = new Calculator(); | |
| var actual = c.Add(a,b); | |
| Assert.Equal(expected, actual); | |
| } | |
| [Fact] | |
| public void Add_SumsOfTwoNumbers() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [Fact] | |
| public void AddSumsTwoNumbersCommutatively() | |
| { | |
| int a = 1, b = 2, expected = 3; | |
| var c = new Calculator(); | |
| int acutalAB = c.Add(a, b); | |
| var actualBA = c.Add(b, a); | |
| Assert.Multiple( | |
| ()=> Assert.Equal(expected, acutalAB), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public abstract class AForwardStream : Stream | |
| { | |
| public abstract Stream SourceStream { get; } | |
| public override bool CanRead => SourceStream.CanRead; | |
| public override bool CanSeek => SourceStream.CanSeek; | |
| public override bool CanWrite => SourceStream.CanWrite; | |
| public override long Length => SourceStream.Length; | |
| public override long Position { get => SourceStream.Position; set => SourceStream.Position = value; } | |
| public override void Flush() => SourceStream.Flush(); | |
| public override int Read(byte[] buffer, int offset, int count) => SourceStream.Read(buffer, offset, count); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "framework.h" | |
| #include "TPX1MouseCursorFix.h" | |
| #define MAX_LOADSTRING 100 | |
| int APIENTRY wWinMain(_In_ HINSTANCE hInstance, | |
| _In_opt_ HINSTANCE hPrevInstance, | |
| _In_ LPWSTR lpCmdLine, | |
| _In_ int nCmdShow) | |
| { |
NewerOlder