<commit_before>﻿using Kandanda.BusinessLayer.ServiceImplementations;
using Kandanda.Dal.DataTransferObjects;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Kandanda.BusinessLayer.Testing
{
    [TestClass]
    public class ParticipantServiceTest
    {
        private const string participantName = "<NAME>";
        private Participant initialParticipant;
        private ParticipantService service;

        [TestInitialize]
        public void Setup()
        {
            TestHelper.ResetDatabase();
            service = new ParticipantService();
            initialParticipant = service.CreateEmpty(participantName);
        }

        [TestMethod]
        public void TestCreateEmptyParticipant()
        {
            const string newParticipantName = "FC Kandanda";

            var createdParticipant = service.CreateEmpty(newParticipantName);
            var reloadedParticipant = service.GetParticipantById(createdParticipant.Id);

            Assert.AreEqual(createdParticipant.Id, reloadedParticipant.Id);
            Assert.AreEqual(newParticipantName, reloadedParticipant.Name);
        }

        [TestMethod]
        public void TestGetParticipantById()
        {
            const string newParticipantName = "FC Kandanda";

            var createdParticipant = service.CreateEmpty(newParticipantName);
            var reloadedParticipant = service.GetParticipantById(createdParticipant.Id);

            Assert.AreEqual(newParticipantName, reloadedParticipant.Name);
        }

        [TestMethod]
        public void TestDeleteParticipant()
        {
            var participants = service.GetAllParticipants();
            var participantCount = participants.Count;

            var participant = service.CreateEmpty(string.Empty);

            participants = service.GetAllParticipants();
            Assert.AreEqual(participantCount + 1, participants.Count);

            service.DeleteParticipant(participant);

            participants = service.GetAllParticipants();
            Assert.AreEqual(participantCount, participants.Count);
        }

        [TestMethod]
        public void TestGetAllParticipants()
        {
            var participants = service.GetAllParticipants();
            
            Assert.AreEqual(1, participants.Count);

            service.CreateEmpty("Empty");
            participants = service.GetAllParticipants();

            Assert.AreEqual(2, participants.Count);
        }
    }
}<commit_msg>refactored ParticipantServiceTest<commit_after>﻿using Kandanda.BusinessLayer.ServiceImplementations;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Kandanda.BusinessLayer.Testing
{
    [TestClass]
    public class ParticipantServiceTest
    {
        private const string _participantName = "<NAME>";
        private ParticipantService _service;

        [TestInitialize]
        public void Setup()
        {
            TestHelper.ResetDatabase();
            _service = new ParticipantService();
            _service.CreateEmpty(_participantName);
        }

        [TestMethod]
        public void TestCreateEmptyParticipant()
        {
            const string newParticipantName = "<NAME>";

            var createdParticipant = _service.CreateEmpty(newParticipantName);
            var reloadedParticipant = _service.GetParticipantById(createdParticipant.Id);

            Assert.AreEqual(createdParticipant.Id, reloadedParticipant.Id);
            Assert.AreEqual(newParticipantName, reloadedParticipant.Name);
        }

        [TestMethod]
        public void TestGetParticipantById()
        {
            const string newParticipantName = "<NAME>";

            var createdParticipant = _service.CreateEmpty(newParticipantName);
            var reloadedParticipant = _service.GetParticipantById(createdParticipant.Id);

            Assert.AreEqual(newParticipantName, reloadedParticipant.Name);
        }

        [TestMethod]
        public void TestDeleteParticipant()
        {
            var participants = _service.GetAllParticipants();
            var participantCount = participants.Count;

            var participant = _service.CreateEmpty(string.Empty);

            participants = _service.GetAllParticipants();
            Assert.AreEqual(participantCount + 1, participants.Count);

            _service.DeleteParticipant(participant);

            participants = _service.GetAllParticipants();
            Assert.AreEqual(participantCount, participants.Count);
        }

        [TestMethod]
        public void TestGetAllParticipants()
        {
            var participants = _service.GetAllParticipants();
            
            Assert.AreEqual(1, participants.Count);

            _service.CreateEmpty("Empty");
            participants = _service.GetAllParticipants();

            Assert.AreEqual(2, participants.Count);
        }
    }
}
{'fraction_non_alphanumeric': 0.07833059210526316, 'fraction_numerical': 0.0012335526315789473, 'mean_word_length': 2.4824624194702936, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2496433', 'n_tokens_mistral': 1241, 'n_tokens_neox': 1132, 'n_words': 205}