Ejemplo n.º 1
0
        public void GetHashCode_DifferentObjectsDifferentBody_DifferentHashCode()
        {
            var stringCassetteBody          = new StringCassetteBody("1");
            var differentStringCassetteBody = new StringCassetteBody("2");

            Assert.That(stringCassetteBody.GetHashCode(), Is.Not.EqualTo(differentStringCassetteBody.GetHashCode()));
        }
Ejemplo n.º 2
0
        public static async Task <(CassetteBody?cassetteBody, HttpContent?content)> CreateCassetteBody(HttpContent content)
        {
            switch (content)
            {
            case StringContent c:
                return(await StringCassetteBody.FromContentAsync(c), null);

            case ByteArrayContent c:
                return(await BytesCassetteBody.FromContentAsync(c), null);

            case StreamContent c:
            {
                var bytesCassetteBody = await BytesCassetteBody.FromContentAsync(c);

                return(bytesCassetteBody, bytesCassetteBody.CreateContentWithHeaders(c.Headers));
            }

            case { Headers: var headers } c when IsTextContent(c) :
            {
                    var stringContent = await c.ReadAsStringAsync();

                    var stringCassetteBody = new StringCassetteBody(stringContent);

                    return(stringCassetteBody, stringCassetteBody.CreateContentWithHeaders(headers));
            }
Ejemplo n.º 3
0
        public void GetHashCode_DifferentObjectsSameBody_EqualHashCode()
        {
            var stringCassetteBody          = new StringCassetteBody("some text");
            var differentStringCassetteBody = new StringCassetteBody("some text");

            Assert.That(stringCassetteBody.GetHashCode(), Is.EqualTo(differentStringCassetteBody.GetHashCode()));
        }
Ejemplo n.º 4
0
        public void Equals_DifferentObjectWithSameValue_True()
        {
            var stringCassetteBody          = new StringCassetteBody("some text");
            var differentStringCassetteBody = new StringCassetteBody("some text");

            Assert.That(stringCassetteBody.Equals(differentStringCassetteBody), Is.True);
            Assert.That(stringCassetteBody.Equals((object)differentStringCassetteBody), Is.True);
            Assert.That(stringCassetteBody == differentStringCassetteBody, Is.True);
            Assert.That(stringCassetteBody != differentStringCassetteBody, Is.False);
        }
Ejemplo n.º 5
0
        public void Equals_Null_False()
        {
            var stringCassetteBody          = new StringCassetteBody("some text");
            var differentStringCassetteBody = (StringCassetteBody)null;

            Assert.That(stringCassetteBody.Equals(differentStringCassetteBody), Is.False);
            Assert.That(stringCassetteBody.Equals((object)differentStringCassetteBody), Is.False);
            Assert.That(stringCassetteBody == differentStringCassetteBody, Is.False);
            Assert.That(stringCassetteBody != differentStringCassetteBody, Is.True);
        }
Ejemplo n.º 6
0
        public void ToString_SomeString_ContainsBody(string value)
        {
            var stringCassetteBody = new StringCassetteBody(value);

            Assert.That(stringCassetteBody.ToString(), Contains.Substring(value));
        }
Ejemplo n.º 7
0
        public void Equals_String_False()
        {
            var stringCassetteBody = new StringCassetteBody("some text");

            Assert.That(stringCassetteBody.Equals("String"), Is.False);
        }