private GovUkNotifyPersonalisation GetGovUkNotifyPersonalisation(Account account) { var result = new GovUkNotifyPersonalisation(); result.Personalisation.Add(nameof(Account.Name), account.Name); return(result); }
public Dictionary <string, dynamic> Convert(GovUkNotifyPersonalisation govUkNotifyPersonalisation) { if (govUkNotifyPersonalisation?.Personalisation != null) { foreach (var item in govUkNotifyPersonalisation.Personalisation?.ToArray()) { if (string.IsNullOrEmpty(item.Value)) { govUkNotifyPersonalisation.Personalisation[item.Key] = Constants.UnknownValue; } } return(govUkNotifyPersonalisation?.Personalisation .ToDictionary <KeyValuePair <string, string>, string, dynamic>( vocObj => vocObj.Key, vocObj => vocObj.Value)); } return(null); }
public void ConvertTest(string key, string sourceValue, string expectedValue) { // Arrange var input = new GovUkNotifyPersonalisation { Personalisation = new Dictionary <string, string> { { key, sourceValue } } }; var expectation = new Dictionary <string, dynamic> { { key, expectedValue } }; // Act var govUkNotifyService = new GovUkNotifyService(fakeApplicationLogger, fakeGovUkNotifyClient, fakeConfiguration, fakeAccountsService); var result = govUkNotifyService.Convert(input); // Assert result.Should().BeEquivalentTo(expectation); }