Badge, tests–live and mock–part 4
(This is the result of 1 hour per day auto-challenge as a full cycle developer)
Reading https://github.com/sdras/awesome-actions I discovered that I can easy add a badge that is building correctly.
Not working ( shows “ no status” ). Thinking about spaces –but no. Maybe a bug ? Resolving later…
Now it time to add some tests…
Moving first the Exchange Rates objects to a separate dll. Add a class for obtaining NBR exchange rates.
Modified the csproj to treat all warnings as errors . Figuring that I have forgot at the definition of the exchange rates the bank
Added live tests that finds the exchange rates on the internet.
Now we want not do the test with the internet open- but just looking now to how it is the parsing of the data from the . So we wnt to mock the HttpClient in .NET Core. Looking at the class, it has no interface ( bad, shame….) . So we cannot mock ? Searching internet
Found https://github.com/richardszalay/mockhttp . So I copied from the internet the NBR XML, put into a file, mock the message handler , modified the constructor of the NBR – and …. error in parsing XML! Turns that there was an “\r\n” as the first line … and XML cannot do a trim …
For reorganizing the project to support tests: working at 7 files: https://github.com/ignatandrei/InfoValutar/commit/2112817f929de6941e8c3fbbe113f1083521d855
For adding live tests: working at 3 files
For mocking : working at 4 files
InfovalutarAnd one hour passes...
(This is the result of 1 hour per day auto-challenge as a full cycle developer for an exchange rates application)
( You can see the sources at https://github.com/ignatandrei/InfoValutar/ )