コード例 #1
0
        public void Equals_DifferentObjectWithDifferentValueAndBody([Values] bool method, [Values] bool uri, [Values] bool headers, [Values] bool body)
        {
            var cassetteRecordRequest = new CassetteRecordRequest(
                HttpMethod.Get.Method,
                new Uri("http://localhost:5000/api/users/1"),
                new NameValueCollection
            {
                { "Some-Header", "value" },
            },
                new StringCassetteBody("{}"));
            var differentCassetteRecordRequest = new CassetteRecordRequest(
                method ? HttpMethod.Get.Method : HttpMethod.Post.Method,
                uri ? new Uri("http://localhost:5000/api/users/1") : new Uri("http://localhost:5000/api/users/2"),
                new NameValueCollection
            {
                { "Some-Header", headers ? "value" : "other" },
            },
                new StringCassetteBody(body ? "{}" : "{\"a\": 1}"));

            var equal = method && uri && headers && body;

            Assert.That(cassetteRecordRequest.Equals(differentCassetteRecordRequest), Is.EqualTo(equal));
            Assert.That(cassetteRecordRequest.Equals((object)differentCassetteRecordRequest), Is.EqualTo(equal));
            Assert.That(cassetteRecordRequest == differentCassetteRecordRequest, Is.EqualTo(equal));
            Assert.That(cassetteRecordRequest != differentCassetteRecordRequest, Is.EqualTo(!equal));
        }
コード例 #2
0
        public void Equals_TheSameObject_True()
        {
            var cassetteRecordRequest          = new CassetteRecordRequest(HttpMethod.Get.Method, new Uri("http://localhost:5000/api/users/1"), new NameValueCollection());
            var differentCassetteRecordRequest = cassetteRecordRequest;

            Assert.That(cassetteRecordRequest.Equals(differentCassetteRecordRequest), Is.True);
            Assert.That(cassetteRecordRequest.Equals((object)differentCassetteRecordRequest), Is.True);
            Assert.That(cassetteRecordRequest == differentCassetteRecordRequest, Is.True);
            Assert.That(cassetteRecordRequest != differentCassetteRecordRequest, Is.False);
        }
コード例 #3
0
        public void Equals_DifferentObjectWithSameValueAndSameBody_True()
        {
            var cassetteRecordRequest          = new CassetteRecordRequest(HttpMethod.Get.Method, new Uri("http://localhost:5000/api/users/1"), new NameValueCollection(), new StringCassetteBody("{}"));
            var differentCassetteRecordRequest = new CassetteRecordRequest(HttpMethod.Get.Method, new Uri("http://localhost:5000/api/users/1"), new NameValueCollection(), new StringCassetteBody("{}"));

            Assert.That(cassetteRecordRequest.Equals(differentCassetteRecordRequest), Is.True);
            Assert.That(cassetteRecordRequest.Equals((object)differentCassetteRecordRequest), Is.True);
            Assert.That(cassetteRecordRequest == differentCassetteRecordRequest, Is.True);
            Assert.That(cassetteRecordRequest != differentCassetteRecordRequest, Is.False);
        }
コード例 #4
0
        public void Equals_DifferentObjectWithDifferentHeader_False([Values(1, 2, 3, 4)] int headers)
        {
            var cassetteRecordRequest = new CassetteRecordRequest(
                HttpMethod.Get.Method,
                new Uri("http://localhost:5000/api/users/1"),
                new NameValueCollection
            {
                { "Some-Header", "value" },
            },
                new StringCassetteBody("{}"));
            var differentCassetteRecordRequest = new CassetteRecordRequest(
                HttpMethod.Get.Method,
                new Uri("http://localhost:5000/api/users/1"),
                new NameValueCollection(),
                new StringCassetteBody("{}"));

            switch (headers)
            {
            case 1:     // Different Value
                differentCassetteRecordRequest.Headers.Add("Some-Header", "other");
                break;

            case 2:     // Different Headers Count
                differentCassetteRecordRequest.Headers.Add("Some-Header", "value");
                differentCassetteRecordRequest.Headers.Add("Some-Other-Header", "other");
                break;

            case 3:     // Different Header Value Count
                differentCassetteRecordRequest.Headers.Add("Some-Header", "value");
                differentCassetteRecordRequest.Headers.Add("Some-Header", "other");
                break;

            case 4:     // Different Headers
                differentCassetteRecordRequest.Headers.Add("Some-Other-Header", "other");
                break;
            }
            ;

            Assert.That(cassetteRecordRequest.Equals(differentCassetteRecordRequest), Is.False);
            Assert.That(cassetteRecordRequest.Equals((object)differentCassetteRecordRequest), Is.False);
            Assert.That(cassetteRecordRequest == differentCassetteRecordRequest, Is.False);
            Assert.That(cassetteRecordRequest != differentCassetteRecordRequest, Is.True);
        }
コード例 #5
0
        public void Equals_String_False()
        {
            var cassetteRecordRequest = new CassetteRecordRequest(HttpMethod.Get.Method, new Uri("http://localhost:5000/api/users/1"), new NameValueCollection());

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