public void SetUp() { _mockSettingsRepo = new Mock <IUserSettingsRepository>(); _mockValidator = new Mock <IValidator <UpdateUserNotificationSettingsCommand> >(); _sut = new UpdateUserNotificationSettingsHandler(_mockSettingsRepo.Object, _mockValidator.Object, Mock.Of <IProviderCommitmentsLogger>()); _command = new UpdateUserNotificationSettingsCommand { UserRef = UserRef, ReceiveNotifications = true }; }
public void ThenUserRefMustBeSupplied() { //Arrange var command = new UpdateUserNotificationSettingsCommand { Settings = new List <UserNotificationSetting>() }; //Act var result = _validator.Validate(command); //Assert Assert.IsFalse(result.IsValid()); Assert.IsTrue(result.ValidationDictionary.ContainsKey(nameof(command.UserRef))); }
public async Task ThenTheCommandIsValidated() { //Arrange var command = new UpdateUserNotificationSettingsCommand { UserRef = "REF", Settings = new List <UserNotificationSetting>() }; //Act await _handler.Handle(command); //Assert _validator.Verify(x => x.Validate(It.IsAny <UpdateUserNotificationSettingsCommand>()), Times.Once); }
public async Task ThenTheRepositoryIsCalledToUpdateSettings() { //Arrange var command = new UpdateUserNotificationSettingsCommand { UserRef = "REF", Settings = new List <UserNotificationSetting>() }; //Act await _handler.Handle(command); //Assert _repository.Verify(x => x.UpdateUserAccountSettings( It.Is <string>(s => s == "REF"), It.IsAny <List <UserNotificationSetting> >() ), Times.Once); }