예제 #1
0
        public void TextSubstitutionHelperHandlesEmptyEntries()
        {
            var subs = new SettingsManager();
            subs.Add("Foo", "Bar");
            subs.Add("Frodo", null);

            var input = "Baggins";
            var output = TextSubstitutionHelper.Substitute(subs, input);

            Assert.AreEqual(input, output);
        }
예제 #2
0
파일: User.cs 프로젝트: IntegerMan/Alfred
        /// <summary>
        ///     Initializes a new instance of the <see cref="User" /> class.
        /// </summary>
        /// <exception cref="ArgumentOutOfRangeException"> The name cannot be empty. </exception>
        /// <param name="name"> The identifier. </param>
        /// <param name="isSystemUser">
        ///     <see langword="true"/> if this instance is system user, <see langword="false"/> if not.
        /// </param>
        internal User([NotNull] string name, bool isSystemUser)
        {
            //- Validation
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentOutOfRangeException(nameof(name), Resources.UserCtorNullId);
            }

            Name = name;
            UniqueId = Guid.NewGuid();
            IsSystemUser = isSystemUser;

            // Set up the variables collection
            UserVariables = new SettingsManager();
            UserVariables.Add("topic", "*");
        }
예제 #3
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="ChatEngineLibrarian" /> class.
        /// </summary>
        /// <exception cref="ArgumentNullException"><paramref name="chatEngine" /> is <see langword="null" />.</exception>
        internal ChatEngineLibrarian([NotNull] ChatEngine chatEngine)
        {
            //-Validate
            if (chatEngine == null)
            {
                throw new ArgumentNullException(nameof(chatEngine));
            }

            _chatEngine = chatEngine;

            // Initialize settings dictionaries
            GlobalSettings = new SettingsManager();
            GenderSubstitutions = new SettingsManager();
            SecondPersonToFirstPersonSubstitutions = new SettingsManager();
            FirstPersonToSecondPersonSubstitutions = new SettingsManager();
            Substitutions = new SettingsManager();
        }
예제 #4
0
        public void TextSubstitutionHelperSubstitutesText()
        {
            var subs = new SettingsManager();
            subs.Add("Foo", "Bar");
            var output = TextSubstitutionHelper.Substitute(subs, "Foo");

            Assert.AreEqual("Bar", output);
        }