public void RunProcessTest(int itemCount, bool validAuthCookie) { //Assin A.CallTo(() => fakeRecycleBinRepository.DeleteVacanciesPermanently(A <int> ._)).Returns(true); if (validAuthCookie) { A.CallTo(() => fakeWebAppContext.CheckAuthenticationByAuthCookie()).DoesNothing(); } else { A.CallTo(() => fakeWebAppContext.CheckAuthenticationByAuthCookie()) .Throws(new UnauthorizedAccessException()); } try { //Instantiate & Act var recycleBinProcesser = new RecycleBinProcesser(fakeRecycleBinRepository, fakeWebAppContext); //Act recycleBinProcesser.RunProcess(itemCount); } catch (UnauthorizedAccessException) { } //Assert A.CallTo(() => fakeWebAppContext.CheckAuthenticationByAuthCookie()).MustHaveHappened(); if (validAuthCookie) { A.CallTo(() => fakeRecycleBinRepository.DeleteVacanciesPermanently(A <int> .That.Matches(x => x.Equals(itemCount)))).MustHaveHappened(); } else { A.CallTo(() => fakeRecycleBinRepository.DeleteVacanciesPermanently(A <int> ._)).MustNotHaveHappened(); } }
public bool RunProcess(int itemCount) { webAppContext.CheckAuthenticationByAuthCookie(); return(recycleBinRepository.DeleteVacanciesPermanently(itemCount)); }