Picking up where we left off, I want to add unit tests to my program. Now, I know, I should have been using unit tests all along. I have no excuse and hang my head in shame.
To get started, I’ve decided to add xUnit through NuGet. Easy peasy. But it won’t work. The full explanation is here. Great article. Here, in a nutshell are the steps you need to perform:
- Create an xUnit test project in the same solution as ForgetMeNot
- Make sure it runs
- Add a reference to the ForgetMeNot project
- This wil not run yet. Here is where the fun begins
- First, open up the ForgetMeNot project and change the TargetFrameworks to
<TargetFrameworks>net6.0;net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
6. Replace the output statement with
<OutputType Condition="'$(TargetFramework)' != 'net6.0'">Exe</OutputType>
7. Unload ForgetMeNot, reload it, close Visual Studio, open Visual Studio and voila! it will work
(The whys and wherefores are explained very well in the article referenced above)
NSubstitute for mocking
We are now almost ready to begin. I want to use mocking from the very beginning. Until about a weak ago, I’d have installed Moq, but I’m intrigued by NSubstitute, so I’m going to use that.
After assuring myself that the default xUnit test works, I’ll add a file called BuddyTests. In there I will add my first test: ShouldPopulateBuddies. I want to make sure that calling Init() will populate the list of buddies (actually, it could return no buddies, but right now I just want to get this test working).
[Fact]
public async Task ShouldPopulateBuddies()
{
var buddies = new List<Buddy>();
var buddy = new Buddy();
buddies.Add(buddy);
var buddyService = Substitute.For<IBuddyService>();
buddyService.GetBuddies().Returns(buddies);
var buddyListVM = new BuddyListViewModel(buddyService);
await buddyListVM.Init();
Assert.True( buddyListVM.Buddies?.Count > 0);
}
So what is going on here? First I create an empty list of Buddy objects and I create an instance of Buddy which I add to that list.
Next (and here is the cool part) I create a mock for my service with that one line
var buddyService = Substitute.For<IBuddyService>();
Remember that Substitute wants interfaces, so earlier I went to each class in my services, put the cursor on the class name and used Refactor->Extract->ExtractInterface which brought up this wonderful dialog box:

I clicked on Select Public to get the public methods and Its own file to put the new interface in a file named IBuddyService.cs. R# is even nice enough to tack the interface name onto the class declaration.
OK, enough digression. My next step is to tell the mock that when the BuddyService’s GetBuddies method is returned, it should return the list of Buddies we just created.
We are now ready to create an instance of the ViewModel and call init() on it. It will use the service we passed in (the mock) and will thus populate its list of buddies with our dummy list and the Assert will pass.
Cool, eh?
This also tells me that I need to handle the case when the list is empty. That means I need to look long and hard at Init() and possibly add another test to prove that the corner case does not cause a problem.
Wrapping Up
It turns out that simple unit tests with mocking is not all that hard to do; and nSubstitute has a lot less ceremony than Moq. I’m going to stay with it for a while and see if I run off a cliff.
Since all the source code changes are already in this blog post, I won’t update the online source until I’ve written some more tests.
Shout-out to Daniel Hindrikes for helping me get started on unit testing for MAUI
See next posting for more unit testing using Fluent asserts.






































canadian pharmacy review Easy North RX Easy North RX
Very shortly this web page will be famous amid all blog visitors, due to it’s fastidious articles
References:
29 palms casino hackmd.okfn.de
You are a very persuasive writer.
Hey just wanted to give you a quick heads up and let you know a few of the images aren’t loading correctly. I’m not sure why but I think its a linking issue. I’ve tried it in two different browsers and both show the same outcome.
I always used to read piece of writing in news papers but now as I am a user of internet therefore from now I am using net for posts, thanks to web.
Easy North RX Easy North RX canadianpharmacyworld
I’m really impressed with your writing skills and also with the layout on your weblog. Is this a paid theme or did you modify it yourself? Anyway keep up the nice quality writing, it is rare to see a nice blog like this one today.
Hey! I know this is kind of off topic but I was wondering if you knew where I could find a captcha plugin for my comment form? I’m using the same blog platform as yours and I’m having difficulty finding one? Thanks a lot!
I would like to thank you for the efforts you have put in penning this site. I’m hoping to view the same high-grade blog posts from you in the future as well. In fact, your creative writing abilities has motivated me to get my own site now 😉
Great items from you, man. I have bear in mind your stuff prior to and you’re just extremely wonderful. I really like what you’ve received here, really like what you’re stating and the way in which through which you are saying it. You’re making it enjoyable and you continue to care for to stay it smart. I cant wait to learn much more from you. This is really a terrific web site.
https://mexicaredirect.com/# mexican pharmacies that ship to the united states
На этом конкретном портале содержится актуальная информация.
На этом портале можно найти много практичного для своего развития.
Этот ресурс способен помочь понять в разных ситуациях.
Советуем детально изучить размещенные на этом сайте публикации.
https://protivbed.ru/full-article/doroga-kotoruyu-zhaluyutsya-prokuratura-glyanula-na-isakovo-vanyushkasy-793/
Buying drugs online is very easy.
It’s possible to shop at any hour without leaving your house.
Online pharmacies let you easily compare costs and locate the lowest deal.
Your meds are delivered directly to your address, cutting a trip and hassle.
iMedix online consultation
There’s no need to stand in long lines at a brick-and-mortar store.
When dealing with chronic conditions, auto reorders make treatment stress‑free.
To sum up, digital shopping for meds saves your hours and energy.
Ordering drugs online is very convenient.
You can shop at any hour without stepping out of home.
Internet drugstores let you easily check costs and locate the best deal.
The meds are sent straight to your address, cutting a trip and effort.
tadapox priapism risk
There’s no need to wait in endless queues at a local store.
For chronic illnesses, auto refills ensure treatment stress‑free.
In short, online shopping for meds saves your time and peace of mind.
MexiCare Direct MexiCare Direct MexiCare Direct
Hi colleagues, its great paragraph about cultureand fully defined, keep it up all the time.
You really make it seem so easy with your presentation but I find this topic to be really something which I think I would never understand. It seems too complicated and very broad for me. I am looking forward for your next post, I’ll try to get the hang of it!
References:
Masque slots siobhanxtgm193345.blog2freedom.com
интернет зеркало водка бет
References:
Roulette number peatix.com
подробнее здесь vodkabet
References:
Videoslots nl https://aliviaxkws150719.blogminds.com
References:
Geant casino saint louis https://prpack.ru/user/cameraturnip7/
References:
Chambres d’hotes https://keiranvoks968079.blogdun.com/42262174/casino-of-gold-dein-ultimativer-guide
onlinecanadianpharmacy: best canadian pharmacy to buy from – canadian pharmacy com
References:
Green valley casino https://gamesgrom.com/user/baitnapkin90/
https://mexicaredirect.shop/# mexico drug store
пояснения снять однокомнатную квартиру в москве метро
пояснения снять комнату в однокомнатной квартире москва
I enjoyed your post. Thank you. Reading your content is way better than kissing. Great post! You are obviously very knowledgeable. Have you ever heard of Meet singles? I enjoyed your post. Thank you. Your neighborhood is way better because of your work. I’m really trying to learn more about this field. I really like your article. Great read. Our neighborhood is way better because of you. I really like your article. This information is magnificent. Great read. I enjoyed reading what you had to say. Nice read. Nice read.
нажмите здесь vodkabet новый сайт
в этом разделе vodkabet
Thank you pertaining to sharing the following great subject matter on your website. I ran into it on google. I am going to check to come back after you publish additional aricles.
india online pharmacy: Flexi Meds India – no script pharmacy
https://fleximedsindia.shop/# best online pharmacy india
Great post! I’m no expert however, it seems to me like this data would be really valuable if it were given to the people who understood how to apply it. Great read. I truly appreciate this post. I hate bighammer wine. There sure seems to be some differing view points on the topic so how can you be so certain you have the right information? Great read. I’ve been really distracted, to say the least. I truly appreciate this post. This information is magnificent. I enjoyed your post. Thank you. Great post! Thanks for writing this. I am really impressed ! I am not an expert however, it looks to me like this data would be really valuable if it were in the hands of the experts who knew how to apply it. I have been looking everywhere for this! Hit me up!
Easy North RX Easy North RX canadian pharmacy sarasota
https://fleximedsindia.com/# cheapest online pharmacy india
MexiCare Direct: MexiCare Direct – MexiCare Direct
You’ve made my day! Thx again. I really like your article. Once again, you are king. This information is magnificent.
Разумный подход к азарту в i-gaming — это совокупность правил, направленных на сохранение психологического здоровья пользователей.
Эта концепция включает добровольное лимитирование времени и расходов на игру.
Участнику рекомендуется заранее выставлять финансовый лимит и строго соблюдать его даже при выигрышных обстоятельствах.
Платформы прозрачного i-gaming обязаны предоставлять функции для тестов на зависимость и пауз.
К признакам проблемы являются потребность отыграться и пренебрежение повседневными обязанностями.
Ответственная игра помогает воспринимать к казино как к развлечению, а не инструменту заработка.
Благодаря применения этих установок интерес сохраняется в безопасных рамках, не нанося личности.
https://blagort.ru/doc/508.html
https://fleximedsindia.com/# indian pharmacy paypal
buy prescription drugs from india: online shopping pharmacy india – top online pharmacy
I have read so many articles or reviews concerning the blogger lovers but this piece of writing is truly a nice piece of writing, keep it up.
Hit me up! Hit me up! You are a very persuasive writer. I enjoyed reading this. The people at high quality are con artists. Interesting content. Thanks for writing this. This information is magnificent. Do you have any more suggestions or insights? Everyone in the world should learn about this. We want a real expert on this area to fix the issue. I have been looking everywhere for this! This is an excellent, an eye-opener for sure! When I browsed this write up I become smarter. I’ve been an expert in this field since about 198 9. Interesting content. This information is magnificent.
Homepage Exploit kits and software vulnerabilities for illegal access
article Phishing tools and malicious software for stealing data
https://ivermectiniaar.com/verified-pharmacy-directory/# ivermectin price canada
does gabapentin cause respiratory depression Neurontin gabapentin approved for neuropathic pain