<commit_before>﻿using System.Threading.Tasks;
using Moq;
using Ploeh.AutoFixture.AutoMoq.UnitTest.TestTypes;
using Ploeh.AutoFixture.Kernel;
using Xunit;

namespace Ploeh.AutoFixture.AutoMoq.UnitTest
{
    public class StubPropertiesCommandTest
    {
        [Theory]
        [ClassData(typeof (ValidNonMockSpecimens))]
        public void ExecuteDoesNotThrowsWhenSpecimenIsValidNonMockSpecimen(object validNonMockSpecimen)
        {
            // Fixture setup
            var context = new Mock<ISpecimenContext>().Object;
            var sut = new StubPropertiesCommand();
            // Exercise system and verify outcome
            Assert.Null(Record.Exception(() => sut.Execute(validNonMockSpecimen, context)));
        }

        [Fact]
        public void IgnoresNonMockSpecimens()
        {
            // Fixture setup
            var request = new object();
            var context = new Mock<ISpecimenContext>().Object;
            var sut = new StubPropertiesCommand();
            // Exercise system and verify outcome
            Assert.Null(Record.Exception(() => sut.Execute(request, context)));
        }

        [Fact]
        public void StubsProperties()
        {
            // Fixture setup
            const string expectedPropertyValue = "a string";
            var request = new Mock<IInterfaceWithProperty>();
            var context = new Mock<ISpecimenContext>().Object;
            var sut = new StubPropertiesCommand();
            // Exercise system
            sut.Execute(request, context);
            // Verify outcome
            request.Object.Property = expectedPropertyValue;
            Assert.Equal(expectedPropertyValue, request.Object.Property);
        }

        [Fact]
        public void DoesNotHangIfMockedTypeHasPropertiesWithCircularDependencies()
        {
            // Fixture setup
            var request = new Mock<IInterfaceWithPropertyWithCircularDependency>()
            {
                DefaultValue = DefaultValue.Mock
            };
            var context = new Mock<ISpecimenContext>().Object;
            var sut = new StubPropertiesCommand();
            // Exercise system
            var task = Task.Factory.StartNew(() => sut.Execute(request, context));
            bool ranToCompletion = task.Wait(1000) && task.Status == TaskStatus.RanToCompletion;
            // Verify outcome
            Assert.True(ranToCompletion);
        }

        [Theory]<commit_msg>Fix flaky test by increasing the timeout<commit_after>﻿using System.Threading.Tasks;
using Moq;
using Ploeh.AutoFixture.AutoMoq.UnitTest.TestTypes;
using Ploeh.AutoFixture.Kernel;
using Xunit;

namespace Ploeh.AutoFixture.AutoMoq.UnitTest
{
    public class StubPropertiesCommandTest
    {
        [Theory]
        [ClassData(typeof (ValidNonMockSpecimens))]
        public void ExecuteDoesNotThrowsWhenSpecimenIsValidNonMockSpecimen(object validNonMockSpecimen)
        {
            // Fixture setup
            var context = new Mock<ISpecimenContext>().Object;
            var sut = new StubPropertiesCommand();
            // Exercise system and verify outcome
            Assert.Null(Record.Exception(() => sut.Execute(validNonMockSpecimen, context)));
        }

        [Fact]
        public void IgnoresNonMockSpecimens()
        {
            // Fixture setup
            var request = new object();
            var context = new Mock<ISpecimenContext>().Object;
            var sut = new StubPropertiesCommand();
            // Exercise system and verify outcome
            Assert.Null(Record.Exception(() => sut.Execute(request, context)));
        }

        [Fact]
        public void StubsProperties()
        {
            // Fixture setup
            const string expectedPropertyValue = "a string";
            var request = new Mock<IInterfaceWithProperty>();
            var context = new Mock<ISpecimenContext>().Object;
            var sut = new StubPropertiesCommand();
            // Exercise system
            sut.Execute(request, context);
            // Verify outcome
            request.Object.Property = expectedPropertyValue;
            Assert.Equal(expectedPropertyValue, request.Object.Property);
        }

        [Fact]
        public void DoesNotHangIfMockedTypeHasPropertiesWithCircularDependencies()
        {
            // Fixture setup
            var request = new Mock<IInterfaceWithPropertyWithCircularDependency>()
            {
                DefaultValue = DefaultValue.Mock
            };
            var context = new Mock<ISpecimenContext>().Object;
            var sut = new StubPropertiesCommand();
            // Exercise system
            var task = Task.Factory.StartNew(() => sut.Execute(request, context));
            bool ranToCompletion = task.Wait(5000) && task.Status == TaskStatus.RanToCompletion;
            // Verify outcome
            Assert.True(ranToCompletion);
        }

        [Theory]
{'fraction_non_alphanumeric': 0.08848114169215086, 'fraction_numerical': 0.0016309887869520897, 'mean_word_length': 2.095268138801262, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 21, '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': '1782490', 'n_tokens_mistral': 1239, 'n_tokens_neox': 1196, 'n_words': 275}