Closed brianjlacy closed 5 years ago
Merging #275 into master will increase coverage by
0.07%
. The diff coverage is100%
.
@@ Coverage Diff @@
## master #275 +/- ##
==========================================
+ Coverage 50.26% 50.34% +0.07%
==========================================
Files 125 125
Lines 3159 3164 +5
==========================================
+ Hits 1588 1593 +5
Misses 1571 1571
Impacted Files | Coverage Δ | |
---|---|---|
.../Engine/Utilities/Settings/UserSettings.Desktop.cs | 100% <100%> (ø) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 1d5f4b8...588947b. Read the comment docs.
Awesome! So cool to see someone else than me contributing code. I have a busy weekend as I'm attending a kendo tryout both days and I'm pretty beat up after. But I'll give it a review sometime in the early upcoming week
Here's what you need to do to write a unit test
Make a IDirectoryWrapper
service, look at IFileWrapper.cs
to get an idea of what you're supposed to do
Make a provider of the previous service, look at FileWrapper.cs
for reference
Add the new service so that the dependency inejctor finds it, take a look at at the constructor in Game.cs
. This looks messy right now but I'm going to clean it up and make it better in the future.
In UserSettings
, take in the service by the constructor, do it the same I did when I added the IFileWrapper
service
Replace the line invoking the Directory.CreateFolder
with the wrapper function you created.
Now you're ready to write the actual test!
UserSettingsTest.cs
you'll need to add the new argument to the new UserSettings
, you'll notice I wrote a stub for FileWrapper
, but we don't need to that here, we can just use the NSubstitute
framework to create a fake. http://nsubstitute.github.io/You need
private IDirectoryWrapper directory;
and
directory = Substitute.For<IDirectoryWrapper>();
SaveMakesDirectory
for instance. What you'll want to do is to check if the wrapped function you made was invoked after invoking Save()
, you can do this with NSubstitute
http://nsubstitute.github.io/help/received-calls/You should also add your name to the https://github.com/LateStartStudio/Hero6/blob/master/docs/COPYRIGHT.md
Prevents crash when settings directory does not already exist.