Tiny types in C#–part 1
This is a series
- http://msprogrammer.serviciipeweb.ro/2018/03/12/tiny-types-in-cpart-1/
- http://msprogrammer.serviciipeweb.ro/2018/03/19/tiny-types-part-2adding-iequatable/
-
http://msprogrammer.serviciipeweb.ro/2018/03/26/tinytypesadding-equality-operatorpart-3/
-
http://msprogrammer.serviciipeweb.ro/2018/04/02/tiny-typesdocumentationpart-4/
I have read about tiny types in Javascript – at https://darrenhobbs.com/2007/04/11/tiny-types/ and at https://janmolak.com/tiny-types-in-typescript-4680177f026e . It was an interesting idea – especially in this world of REST API .
I decided to make the same on C# – so here it is: https://github.com/ignatandrei/tinyTypes and at https://www.nuget.org/packages/TinyTypesObjects .
For the moment , the tests are minimal – just to get working :
using Microsoft.VisualStudio.TestTools.UnitTesting; using TinyTypesObjects; namespace TinyTypesTest { [TestClass] public class TestTinyType { [TestMethod] public void TestConvert() { string s = "http://msprogrammer.serviciipeweb.ro"; TinyType<string> tt = s; Assert.AreEqual(s, (string)tt); } [TestMethod] public void TestBehaviour() { #region arrange + act Author a1 = new Author("andrei", "ignat"); Author a2 = new Author( new FirstName("andrei"),new LastName( "ignat")); Author a3 = new Author(firstName:"andrei",lastName: "ignat"); #endregion #region assert Assert.AreEqual(a2.FullName(), a3.FullName()); Assert.AreEqual(a2.FullName(), a3.FullName()); #endregion } } }
Next time , I will do IComparable / Iequatable /Equals and others
Leave a Reply