<commit_before>﻿using System.Linq;
using Judge.Application;
using Judge.Data;
using Judge.Model.Account;
using Judge.Model.CheckSolution;
using Judge.Model.Configuration;
using Judge.Model.Entities;
using Judge.Model.SubmitSolution;
using NUnit.Framework;
using Rhino.Mocks;

namespace Judge.Tests.Application.SubmitQueueServiceTests
{
    [TestFixture]
    public sealed class GetSubmitQueueTests
    {
        private SubmitQueueService _service;
        private ISubmitResultRepository _submitResultRepository;
        private ITaskNameRepository _taskRepository;
        private IUserRepository _userRepository;

        [SetUp]
        public void SetUp()
        {
            var unitOfWorkFactory = MockRepository.GenerateMock<IUnitOfWorkFactory>();
            var unitOfWork = MockRepository.GenerateMock<IUnitOfWork>();
            _submitResultRepository = MockRepository.GenerateMock<ISubmitResultRepository>();
            var languageRepository = MockRepository.GenerateMock<ILanguageRepository>();
            languageRepository.Stub(o => o.GetLanguages()).Return(new[] { new Language() });

            _taskRepository = MockRepository.GenerateMock<ITaskNameRepository>();
            _userRepository = MockRepository.GenerateMock<IUserRepository>();

            unitOfWork.Stub(o => o.GetRepository<ISubmitResultRepository>()).Return(_submitResultRepository);
            unitOfWork.Stub(o => o.GetRepository<ILanguageRepository>()).Return(languageRepository);
            unitOfWork.Stub(o => o.GetRepository<ITaskNameRepository>()).Return(_taskRepository);
            unitOfWork.Stub(o => o.GetRepository<IUserRepository>()).Return(_userRepository);

            unitOfWorkFactory.Stub(o => o.GetUnitOfWork(Arg<bool>.Is.Anything)).Return(unitOfWork);

            _service = new SubmitQueueService(unitOfWorkFactory);
        }

        [Test]
        public void HidePassedTestsForAcceptedTest()
        {
            var submit = Submit.Create();
            submit.ProblemId = 1;
            submit.UserId = 2;
            var submits = new[] { new SubmitResult(submit) { Status = SubmitStatus.Accepted, PassedTests = 10 } };

            _submitResultRepository.Stub(
                o => o.GetSubmits(Arg<long?>.Is.Anything, Arg<long?>.Is.Anything, Arg<int>.Is.Anything, Arg<int>.Is.Anything))
                .Return(submits);

            _taskRepository.Stub(o => o.GetTasks(Arg<long[]>.Is.Anything)).Return(new[] { new TaskName { Id = 1, Name = "A+B" } });

            _userRepository.Stub(o => o.GetUsers(Arg<long[]>.Is.Anything)).Return(new[] { new User { Id = 1 } });

            var model = _service.GetSubmitQueue(1, 1, 1);

            Assert.That(model.Submits.Select(o => o.PassedTests), Is.All.Null);
        }
    }
}
<commit_msg>- HidePassedTestsForAcceptedTest fix<commit_after>﻿using System.Linq;
using Judge.Application;
using Judge.Data;
using Judge.Model.Account;
using Judge.Model.CheckSolution;
using Judge.Model.Configuration;
using Judge.Model.Entities;
using Judge.Model.SubmitSolution;
using NUnit.Framework;
using Rhino.Mocks;

namespace Judge.Tests.Application.SubmitQueueServiceTests
{
    [TestFixture]
    public sealed class GetSubmitQueueTests
    {
        private SubmitQueueService _service;
        private ISubmitResultRepository _submitResultRepository;
        private ITaskNameRepository _taskRepository;
        private IUserRepository _userRepository;

        [SetUp]
        public void SetUp()
        {
            var unitOfWorkFactory = MockRepository.GenerateMock<IUnitOfWorkFactory>();
            var unitOfWork = MockRepository.GenerateMock<IUnitOfWork>();
            _submitResultRepository = MockRepository.GenerateMock<ISubmitResultRepository>();
            var languageRepository = MockRepository.GenerateMock<ILanguageRepository>();
            languageRepository.Stub(o => o.GetLanguages()).Return(new[] { new Language() });

            _taskRepository = MockRepository.GenerateMock<ITaskNameRepository>();
            _userRepository = MockRepository.GenerateMock<IUserRepository>();

            unitOfWork.Stub(o => o.GetRepository<ISubmitResultRepository>()).Return(_submitResultRepository);
            unitOfWork.Stub(o => o.GetRepository<ILanguageRepository>()).Return(languageRepository);
            unitOfWork.Stub(o => o.GetRepository<ITaskNameRepository>()).Return(_taskRepository);
            unitOfWork.Stub(o => o.GetRepository<IUserRepository>()).Return(_userRepository);

            unitOfWorkFactory.Stub(o => o.GetUnitOfWork(Arg<bool>.Is.Anything)).Return(unitOfWork);

            _service = new SubmitQueueService(unitOfWorkFactory);
        }

        [Test]
        public void HidePassedTestsForAcceptedTest()
        {
            var submit = Submit.Create();
            submit.ProblemId = 1;
            submit.UserId = 1;
            var submits = new[] { new SubmitResult(submit) { Status = SubmitStatus.Accepted, PassedTests = 10 } };

            _submitResultRepository.Stub(
                o => o.GetSubmits(Arg<long?>.Is.Anything, Arg<long?>.Is.Anything, Arg<int>.Is.Anything, Arg<int>.Is.Anything))
                .Return(submits);

            _taskRepository.Stub(o => o.GetTasks(Arg<long[]>.Is.Anything)).Return(new[] { new TaskName { Id = 1, Name = "A+B" } });

            _userRepository.Stub(o => o.GetUsers(Arg<long[]>.Is.Anything)).Return(new[] { new User { Id = 1 } });

            var model = _service.GetSubmitQueue(1, 1, 1);

            Assert.That(model.Submits.Select(o => o.PassedTests), Is.All.Null);
        }
    }
}

{'fraction_non_alphanumeric': 0.1165379780930149, 'fraction_numerical': 0.003232178128927994, 'mean_word_length': 3.150521609538003, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 57, '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': '5327924', 'n_tokens_mistral': 1563, 'n_tokens_neox': 1514, 'n_words': 250}