You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running unit tests to verify logger is called as expected, Moq.ILogger threw this exception:
Moq.VerifyLogUnexpectedException : Moq.ILogger found an unexpected exception.
----> System.ArgumentNullException : Value cannot be null. (Parameter 'body')
publicasyncTaskExampleAsync(IEnumerable<Models.HallOfFame>hallOfFameInductees,CancellationTokencancellationToken=default){varcurrentHallOfFamers=(awaitRetrieveBO.ExecuteAsync(cancellationToken)).ToList();varalreadyInducted=(fromcurrentincurrentHallOfFamersfrominducteeinhallOfFameInducteeswherecurrent.BowlerId==inductee.BowlerIdwhereAlreadyInducted(inductee,current)selectinductee).ToList();if(alreadyInducted.Count>0){Logger.LogError("Bowler(s) {alreadyInducted} already inducted to hall of fame",alreadyInducted);ErrorDetails.Add(newModels.ErrorDetail("Invalid Addition: Bowler already inducted"));return;}DataLayer.Execute(hallOfFameInductees);awaitDataAccess.CommitAsync(LocalTransaction,cancellationToken);}privatestaticboolAlreadyInducted(Models.HallOfFameinductee,Models.HallOfFamecurrent)=>current.Category==Models.HallOfFameTypes.Combined||current.Category==inductee.Category;
Unit Test (hallOfFameInductees and hallOfFamers generated via Bogus, Fluent calls override properties set via Bogus):
[Test]publicasyncTaskExampleAsync_RetrieveBOExecuteSuccessful_NewEntryAlreadyInSameCategory_LoggerLogError_CalledCorrectly(){varhallOfFameInductees=new[]{newBuilders.Models.HallOfFame().WithBowlerId(1).WithYear(2000).WithCategory(NEBA.Models.HallOfFameTypes.Performance).Generate()};varhallOfFamers=new[]{newBuilders.Models.HallOfFame().WithBowlerId(1).WithYear(1999).WithCategory(NEBA.Models.HallOfFameTypes.Performance).Generate()};_retrieveBO.Setup(retrieveBO =>retrieveBO.ExecuteAsync(It.IsAny<CancellationToken>())).ReturnsAsync(hallOfFamers);await_businessLogic.ExampleAsync(hallOfFameInductees);_logger.VerifyLog(logger =>logger.LogError("Bowler(s) {alreadyInducted} already inducted to hall of fame",hallOfFameInductees),Times.Once);}
When running unit tests to verify logger is called as expected, Moq.ILogger threw this exception:
Stack Trace:
Code:
Unit Test (hallOfFameInductees and hallOfFamers generated via Bogus, Fluent calls override properties set via Bogus):
Models:
The text was updated successfully, but these errors were encountered: