<commit_before>﻿using System;
using System.Linq;
using System.Collections.Generic;
using NUnit.Framework;
using NUnit.Framework.Constraints;
using LinqEditor.Core.Templates;
using Moq;
using LinqEditor.Core.CodeAnalysis.Editor;
using LinqEditor.Core.CodeAnalysis.Models;
using T = System.Tuple;

namespace LinqEditor.Core.CodeAnalysis.Tests
{
    [TestFixture]
    public class CompletionTests
    {
        private static ITemplateService _templateService;

        [TestFixtureSetUp]
        public static void Class_Initialie(TestContext ctx)
        {
            var ns = "ns";
            var programSource = @"
using System;
using System.Linq;
using System.Collections.Generic;

namespace Generated
{
    public class Proram
    {
        public void Query() 
        {
" + Completion.Marker + @"
        }
    }
}
";
            var m = new Mock<ITemplateService>();
            m.Setup(s => s.GenerateQuery(It.IsAny<Guid>(), out ns, It.IsAny<string>(), It.IsAny<string>())).Returns(programSource);
            _templateService = m.Object;
        }

        [Test]
        public void Can_Initialize_Completion()
        {
            var completion = new Completion(_templateService);
            completion.Initialize();
        }

        [Test]
        public void Can_Suggest_Completions_For_MemberAccessExpression_Of_Generic_Int_List()
        {
            var completion = new Completion(_templateService) as ICompletion;
            completion.Initialize();
            var x = new List<int>();
            var str = "var x = new List<int>();x.";
            completion.UpdateFragment(str);
            var s = completion.MemberAccessExpressionCompletions(str.Length-1).Suggestions.ToArray();
            var vsEntries = new Tuple<string,SuggestionType>[]
            {
                // list created from VS2012
                T.Create("Add", SuggestionType.Method),
                T.Create("AddRange", SuggestionType.Method),
                T.Create("Aggregate", SuggestionType.ExtensionMethod),
                T.Create("All", SuggestionType.ExtensionMethod),
                T.Create("Any", SuggestionType.ExtensionMethod),<commit_msg>fix nunit test attribute<commit_after>﻿using System;
using System.Linq;
using System.Collections.Generic;
using NUnit.Framework;
using NUnit.Framework.Constraints;
using LinqEditor.Core.Templates;
using Moq;
using LinqEditor.Core.CodeAnalysis.Editor;
using LinqEditor.Core.CodeAnalysis.Models;
using T = System.Tuple;

namespace LinqEditor.Core.CodeAnalysis.Tests
{
    [TestFixture]
    public class CompletionTests
    {
        private static ITemplateService _templateService;

        [TestFixtureSetUp]
        public void Initialize()
        {
            var ns = "ns";
            var programSource = @"
using System;
using System.Linq;
using System.Collections.Generic;

namespace Generated
{
    public class Proram
    {
        public void Query() 
        {
" + Completion.Marker + @"
        }
    }
}
";
            var m = new Mock<ITemplateService>();
            m.Setup(s => s.GenerateQuery(It.IsAny<Guid>(), out ns, It.IsAny<string>(), It.IsAny<string>())).Returns(programSource);
            _templateService = m.Object;
        }

        [Test]
        public void Can_Initialize_Completion()
        {
            var completion = new Completion(_templateService);
            completion.Initialize();
        }

        [Test]
        public void Can_Suggest_Completions_For_MemberAccessExpression_Of_Integer_Inside_Lambda()
        {
            var completion = new Completion(_templateService) as ICompletion;
            completion.Initialize();
            var x = new List<int>();
            var str = "var x = new List<int>();x.Where(y => y.";
            completion.UpdateFragment(str);
            var s = completion.MemberAccessExpressionCompletions(str.Length - 1).Suggestions.ToArray();
            var vsEntries = new Tuple<string, SuggestionType>[] 
            {
                T.Create("Add", SuggestionType.Method),
            };

            for (var i = 0; i < vsEntries.Length; i++)
            {
                Assert.IsTrue(s[i].Value == vsEntries[i].Item1 && s[i].Kind == vsEntries[i].Item2);
            }
        }

        [Test]
        public void Can_Suggest_Completions_For_MemberAccessExpression_Of_Integer_List()
        {
            var completion = new Completion(_templateService) as ICompletion;
            completion.Initialize();
            var x = new List<int>();
            var str = "var x = new List<int>();x.";
            completion.UpdateFragment(str);
            var s = completion.MemberAccessExpressionCompletions(str.Length-1).Suggestions.ToArray();
            var vsEntries = new Tuple<string,SuggestionType>[]
            {
                // list created from VS2012
                T.Create("Add", SuggestionType.Method),
                T.Create("AddRange", SuggestionType.Method),
                T.Create("Aggregate", SuggestionType.ExtensionMethod),
                T.Create("All", SuggestionType.ExtensionMethod),
                T.Create("Any", SuggestionType.ExtensionMethod),
{'fraction_non_alphanumeric': 0.10516066212268745, 'fraction_numerical': 0.002726387536514119, 'mean_word_length': 2.305019305019305, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 23, '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': '3014015', 'n_tokens_mistral': 1415, 'n_tokens_neox': 1379, 'n_words': 287}