public void HaveContentWithProperty_WhenExpectedNotToFail_ShouldNotFail()
        {
            var expectedContent = new ModelA {
                StringProperty = "string", IntProperty = 1
            };

            _subject.Content = new StringContent(JsonConvert.SerializeObject(expectedContent));

            _subject.Should().HaveContentWithProperty <ModelA>(x => x.IntProperty, 1);
        }
Ejemplo n.º 2
0
        public void Sample2()
        {
            var expectedContent = new ModelA {
                StringProperty = "test", IntProperty = 2
            };

            var response = new HttpResponseMessage();

            response.Should()
            .HaveContent <ModelA>(expectedContent, options => options.Excluding(x => x.IntProperty));
        }
        public void HaveContentWithProperty_WhenExpectedToFail_ShouldFail()
        {
            var expectedContent = new ModelA {
                StringProperty = "string", IntProperty = 1
            };

            _subject.Content = new StringContent(JsonConvert.SerializeObject(expectedContent));

            Action act = () => _subject.Should().HaveContentWithProperty <ModelA>(x => x.IntProperty, 2);

            act.Should().Throw <XunitException>();
        }
        public void HaveTypedContentWithEquivalencyOptions_WhenExpectedToFail_ShouldFail()
        {
            var expectedContent = new ModelA {
                StringProperty = "string", IntProperty = 1
            };

            _subject.Content = new StringContent(JsonConvert.SerializeObject(expectedContent));

            Action act = () => _subject.Should().HaveContent(new ModelA {
                StringProperty = "otherstring", IntProperty = 1
            }, options => options.Including(x => x.StringProperty));

            act.Should().Throw <XunitException>();
        }
        public void HaveTypedContentWithEquivalencyOptions_WhenExpectedNotToFail_ShouldNotFail()
        {
            var expectedContent = new ModelA {
                StringProperty = "string", IntProperty = 1
            };

            _subject.Content = new StringContent(JsonConvert.SerializeObject(expectedContent));

            _subject.Should().HaveContent(new ModelA {
                StringProperty = "otherstring", IntProperty = 1
            }, options => options.Including(x => x.IntProperty));
            _subject.Should().HaveContent(new ModelA {
                StringProperty = "otherstring", IntProperty = 1
            }, options => options.Excluding(x => x.StringProperty));
        }
Ejemplo n.º 6
0
        public void Sample1()
        {
            var expectedContent = new ModelA {
                StringProperty = "test", IntProperty = 1
            };

            var response = new HttpResponseMessage();

            response.Should()
            .HaveStatusCode(HttpStatusCode.Created)
            .And
            .HaveHeaderForETag(new EntityTagHeaderValue("etag"))
            .And
            .HaveContent <ModelA>(expectedContent);
        }