예제 #1
0
        public void SetDefaultForDisableNotificationIsHandled(string actual, bool expected)
        {
            var mapper = new TelegramBotMapper(new TelegramBotClient(ApiKey), this.responseFactory);

            JsonConvert.DeserializeObject <Response <string> >(mapper.SetDefaultValue($"{nameof(mapper.DisableNotifications)}", actual));
            Assert.Equal(expected, mapper.DisableNotifications);
            var result = JsonConvert.DeserializeObject <Response <Error> >(mapper.SetDefaultValue($"{nameof(mapper.DisableNotifications)}", "unknown"));

            Assert.Equal(typeof(ArgumentException).Name, result.Content.ExceptionType);
        }
예제 #2
0
        public void SetDefaultForUnknownKeyThrowsException()
        {
            var mapper = new TelegramBotMapper(new TelegramBotClient(ApiKey), this.responseFactory);
            var result = JsonConvert.DeserializeObject <Response <Error> >(mapper.SetDefaultValue($"UnknownStuff", "test"));

            Assert.Equal(typeof(KeyNotFoundException).Name, result.Content.ExceptionType);
        }