public void CreateMessageTextTest()
        {
            var message = new FlashMessage(Toastr.INFO, "A message");

            message.Severity.Should().Be(Toastr.INFO);
            message.Title.Should().BeNull();
            message.Message.Should().Be("A message");
            message.Options.Should().BeEmpty();
        }
        public void CreateMessageTest()
        {
            var message = new FlashMessage(Toastr.INFO, "A title", "A message", new { one = 1 });

            message.Severity.Should().Be(Toastr.INFO);
            message.Title.Should().Be("A title");
            message.Message.Should().Be("A message");
            message.Options.Should().NotBeEmpty();
        }
        /// <summary>
        /// Returns the function parameters for the toastr function call based on the
        /// contents of the message.
        /// </summary>
        /// <param name="message">Flash message to display.</param>
        /// <returns>Parameters for the JavaScript function call.</returns>
        private static object GetToastrFunctionParameters(FlashMessage message)
        {
            var parameters = new List<string>();

            parameters.Add(string.Format("'{0}'", message.Message.Replace("'", "\\'")));

            if (!string.IsNullOrWhiteSpace(message.Title))
                parameters.Add(string.Format("'{0}'", message.Title.Replace("'", "\\'")));

            if (!string.IsNullOrWhiteSpace(message.Options))
            {
                if (parameters.Count <= 1)
                {
                    // Title hasn't been provided, but options have been. Add null title.
                    parameters.Add("null");
                }

                parameters.Add(message.Options);
            }

            return string.Join(", ", parameters);
        }