﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using EchoBot;
using System.Collections.Generic;

namespace EchoBotTest
{
  [TestClass]
    public class UtilityTests
    {
        private List<string> sampleGuildMembers;

        [TestInitialize]
        public void BeforeEach()
        {
            sampleGuildMembers = new List<string> { "reece", "patrick", "dan" };
        }

        [TestMethod]
        public void validateMessageComponentNullTest()
        {
            Utility.validateMessageComponent(null, null);
        }

        [TestMethod]
        public void validateMessageComponentFalseTest()
        {
            bool shouldBeFalse =Utility.validateMessageComponent("sdfg", sampleGuildMembers);
            Assert.AreEqual(false, shouldBeFalse);
        }

        [TestMethod]
        public void validateMessageComponentTrueTest()
        {
            bool shouldBeFalse = Utility.validateMessageComponent("dan", sampleGuildMembers);
            Assert.AreEqual(true, shouldBeFalse);
        }

        [TestMethod]
        public void getValidStringsNullTest()
        {
            string shouldBeFalse = Utility.getValidStrings(null);
            Assert.AreEqual("Null collection!", shouldBeFalse);
        }

        [TestMethod]
        public void getValidStringsTest()
        {
            string stringoutput = Utility.getValidStrings(sampleGuildMembers);
            Assert.IsTrue(stringoutput.Contains("reece"));
            Assert.IsTrue(stringoutput.Contains("patrick"));
            Assert.IsTrue(stringoutput.Contains("dan"));
        }

        [TestMethod]
        public void listKudosNullTest()
        {
            string stringoutput = Utility.listKudos(null);
            Assert.AreSame("Null kudosData!", stringoutput);
        }

        [TestMethod]
        public void listKudosTest()
        {
            Dictionary<string, float> sampleData = new Dictionary<string, float>();
            sampleData.Add("reece", 5.0f);
            sampleData.Add("patrick", 15.0f);
            sampleData.Add("dan", 25.0f);

            string stringoutput = Utility.listKudos(sampleData);

            Assert.IsTrue(stringoutput.Contains("reece 5"));
            Assert.IsTrue(stringoutput.Contains("patrick 15"));
            Assert.IsTrue(stringoutput.Contains("dan 25"));
        }

    }
}
