<commit_before>﻿// Copyright (c) 2011 - <NAME> & <NAME>
//
// This file is provided to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file
// except in compliance with the License.  You may obtain
// a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.

using System.Collections.Generic;
using System.Linq;
using CorrugatedIron.Extensions;
using CorrugatedIron.Models;
using CorrugatedIron.Tests.Extensions;
using Moq;
using NUnit.Framework;

namespace CorrugatedIron.Tests.RiakAsyncClientTests
{
    internal abstract class RiakAsyncClientTestBase<TResult>
    {
        protected Mock<IRiakClient> ClientMock;
        protected RiakAsyncClient AsyncClient;
        protected TResult Result;

        protected RiakAsyncClientTestBase()
        {
            ClientMock = new Mock<IRiakClient>();
            AsyncClient = new RiakAsyncClient(ClientMock.Object);
        }
    }

    [TestFixture]
    internal class WhenPingingServerAsync : RiakAsyncClientTestBase<RiakResult>
    {
        [SetUp]
        public void SetUp()
        {
            ClientMock.Setup(m => m.Ping()).Returns(RiakResult.Success());
            Result = AsyncClient.Ping().Result;
        }

        [Test]
        public void AsyncClientInvokesCorrectClientFunction()
        {
            ClientMock.Verify(m => m.Ping(), Times.Once());
        }

        [Test]
        public void AsyncClientReturnsCorrectResult()
        {
            Result.ShouldNotBeNull();
            Result.IsSuccess.ShouldBeTrue();
        }
    }

    [TestFixture]
    internal class WhenCallingGetWithObjectIdAsync : RiakAsyncClientTestBase<RiakResult<RiakObject>>
    {
        [SetUp]
        public void SetUp()
        {
            ClientMock.Setup(m => m.Get(It.IsAny<string>(), It.IsAny<string>(), 2)).Returns(RiakResult<RiakObject>.Success(new RiakObject("foo", "bar", "baz")));
            Result = AsyncClient.Get(new RiakObjectId("foo", "bar")).Result;
        }

        [Test]
        public void AsyncClientInvokesCorrectClientFunction()
        {
            ClientMock.Verify(m => m.Get(It.IsAny<string>(), It.IsAny<string>(), 2), Times.Once());
        }

        [Test]
        public void AsyncClientReturnsCorrectResult()
        {
            Result.ShouldNotBeNull();
            Result.IsSuccess.ShouldBeTrue();
            Result.Value.ShouldNotBeNull();
            Result.Value.Bucket.ShouldEqual("foo");
            Result.Value.Key.ShouldEqual("bar");
            Result.Value.Value.FromRiakString().ShouldEqual("baz");
        }
    }

    [TestFixture]
    internal class WhenCallingGetWithBucketKeyAsync : RiakAsyncClientTestBase<RiakResult<RiakObject>>
    {
        [SetUp]
        public void SetUp()
        {
            ClientMock.Setup(m => m.Get(It.IsAny<string>(), It.IsAny<string>(), 2)).Returns(RiakResult<RiakObject>.Success(new RiakObject("foo", "bar", "baz")));
            Result = AsyncClient.Get("foo", "bar").Result;
        }

        [Test]
        public void AsyncClientInvokesCorrectClientFunction()
        {
            ClientMock.Verify(m => m.Get(It.IsAny<string>(), It.IsAny<string>(), 2), Times.Once());
        }

        [Test]
        public void AsyncClientReturnsCorrectResult()
        {
            Result.ShouldNotBeNull();
            Result.IsSuccess.ShouldBeTrue();
            Result.Value.ShouldNotBeNull();
            Result.Value.Bucket.ShouldEqual("foo");
            Result.Value.Key.ShouldEqual("bar");
            Result.Value.Value.FromRiakString().ShouldEqual("baz");
        }
    }

    [TestFixture]<commit_msg>Fix broken Async unit tests<commit_after>﻿// Copyright (c) 2011 - <NAME> & <NAME>
//
// This file is provided to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file
// except in compliance with the License.  You may obtain
// a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.

using System.Collections.Generic;
using System.Linq;
using CorrugatedIron.Extensions;
using CorrugatedIron.Models;
using CorrugatedIron.Tests.Extensions;
using Moq;
using NUnit.Framework;

namespace CorrugatedIron.Tests.RiakAsyncClientTests
{
    internal abstract class RiakAsyncClientTestBase<TResult>
    {
        protected Mock<IRiakClient> ClientMock;
        protected RiakAsyncClient AsyncClient;
        protected TResult Result;

        protected RiakAsyncClientTestBase()
        {
            ClientMock = new Mock<IRiakClient>();
            AsyncClient = new RiakAsyncClient(ClientMock.Object);
        }
    }

    [TestFixture]
    internal class WhenPingingServerAsync : RiakAsyncClientTestBase<RiakResult>
    {
        [SetUp]
        public void SetUp()
        {
            ClientMock.Setup(m => m.Ping()).Returns(RiakResult.Success());
            Result = AsyncClient.Ping().Result;
        }

        [Test]
        public void AsyncClientInvokesCorrectClientFunction()
        {
            ClientMock.Verify(m => m.Ping(), Times.Once());
        }

        [Test]
        public void AsyncClientReturnsCorrectResult()
        {
            Result.ShouldNotBeNull();
            Result.IsSuccess.ShouldBeTrue();
        }
    }

    [TestFixture]
    internal class WhenCallingGetWithObjectIdAsync : RiakAsyncClientTestBase<RiakResult<RiakObject>>
    {
        [SetUp]
        public void SetUp()
        {
            ClientMock.Setup(m => m.Get(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<uint>())).Returns(RiakResult<RiakObject>.Success(new RiakObject("foo", "bar", "baz")));
            Result = AsyncClient.Get(new RiakObjectId("foo", "bar")).Result;
        }

        [Test]
        public void AsyncClientInvokesCorrectClientFunction()
        {
            ClientMock.Verify(m => m.Get(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<uint>()), Times.Once());
        }

        [Test]
        public void AsyncClientReturnsCorrectResult()
        {
            Result.ShouldNotBeNull();
            Result.IsSuccess.ShouldBeTrue();
            Result.Value.ShouldNotBeNull();
            Result.Value.Bucket.ShouldEqual("foo");
            Result.Value.Key.ShouldEqual("bar");
            Result.Value.Value.FromRiakString().ShouldEqual("baz");
        }
    }

    [TestFixture]
    internal class WhenCallingGetWithBucketKeyAsync : RiakAsyncClientTestBase<RiakResult<RiakObject>>
    {
        [SetUp]
        public void SetUp()
        {
            ClientMock.Setup(m => m.Get(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<uint>())).Returns(RiakResult<RiakObject>.Success(new RiakObject("foo", "bar", "baz")));
            Result = AsyncClient.Get("foo", "bar").Result;
        }

        [Test]
        public void AsyncClientInvokesCorrectClientFunction()
        {
            ClientMock.Verify(m => m.Get(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<uint>()), Times.Once());
        }

        [Test]
        public void AsyncClientReturnsCorrectResult()
        {
            Result.ShouldNotBeNull();
            Result.IsSuccess.ShouldBeTrue();
            Result.Value.ShouldNotBeNull();
            Result.Value.Bucket.ShouldEqual("foo");
            Result.Value.Key.ShouldEqual("bar");
            Result.Value.Value.FromRiakString().ShouldEqual("baz");
        }
    }

    [TestFixture]
{'fraction_non_alphanumeric': 0.11947791164658635, 'fraction_numerical': 0.0025100401606425703, 'mean_word_length': 2.5214317277949623, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 59, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2640322', 'n_tokens_mistral': 2318, 'n_tokens_neox': 2243, 'n_words': 463}