I'm still trying to get my head around the joke. Right now, I'm trying to test my What I do not get ... If I usually get this user to have my db / repository, it magically receives an identity, which sets it, in my example object There is no rocket science content here. What I do not understand, how do I duplicate it? should I care? I thought I should or .. It is that I do not care about it .. Because I am just making sure that the repository system has been called .. Not so much that it brings back the right data. This is my proxy unit test code. I (unit test, integration test is not why .. fake stores) ... and the user service looks like this .. Any suggestions? if the repository is responsible If the service is responsible for identifying magic, , then it makes sense to check that the ID has been set. save method on my
UserService . As such, I am mocking my IRAP positrior who uses my
UserService class.
[TestMethod] HavingUnuAairWithWidthDiet ResetSmdNumAuthOfferUserIDDayDay () {// Arrange Var const string password salt = "V4BXAhmHq8IMvR7K20TgoQ ==" var user = new user {DisplayName = "test", email = "foo@foo.com", PasswordSalt = passwordSalt, password = "Foobar" .ToSha2Hash (passwordSalt)}; Var Mock User Repository = New Fake & lt; IRAPSorporation & lt; Users & gt; & Gt; (); MockUserRepository.Setup (x = & gt; x.Save (this. Any & lt; user & gt; ())). Verification (); // Configure this repo in our dependency injection ObjectFactory.Inject (typef (IRAPSosgotry & Lt; User & gt;), Mock Usage Repository Object); // Act (Using new transaction scope ()) {UserService.Save (user); UnitOfWork.Commit (); // & lt; - Not sure about this .. Currently it is still / / an EntityFramework reference // I need to change this .. Something ?? // Insert Assert.IsNotNull (user); Assign ISTRU (UserUUSID> gt; 0); }}
Public class UserService: IUserService {Public UserService (IRPZetter & lt; user & gt; Users Repository, ILoggingService loggingService) {//. Snip .. Public Zero Save (user user) {..}}}
& gt; 1) How should I test a [UserService.]? Save method? Should I care about the result? And & gt; 2) If I care about # 1 then how do I duplicate the result, so I can check
Identity-Magic So it does not make sense to duplicate this functionality in a test and then confirms that this functionality has been tested. You want to test UserService and do not duplicate IRAPZERRY- The fake duplicate store is just for cropping with intelligence that the service is not crashing and receives all the requirements for the test case. In this case, I do not think that service requires
identity-magic .
Comments
Post a Comment