Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- How to use NSubstitute to mock a lazy class
- //Assert
- Lazy<INotificationService> notificationService = Substitute.For<Lazy<INotificationService>>();
- Service target = new Service(repository, notificationService);
- //Act
- target.SendNotify("Message");
- //Arrange
- notificationService.Received().Value.sendNotification(null, null, null, null);
- var notificationService = Substitute.For<INotificationService>();
- var target = new Service(repository, new Lazy<INotificationService>(() => notificationService));
- target.SendNotify("Message");
- notificationService.ReceivedWithAnyArgs().sendNotification(null, null, null, null);
Add Comment
Please, Sign In to add comment