コード例 #1
0
        public static void ObjectBody(this IWebRequestResponseConfigurator configurator, Action <IWebRequestResponseObjectConfigurator>?config)
        {
            var spec = new WebRequestResponseObjectSpecification();

            config?.Invoke(spec);
            configurator.SetBodySpecification(spec);
        }
コード例 #2
0
        public async Task Given_Spec_When_Build_Then_WriterCreatesResponse()
        {
            var obj = new object();

            var writer     = A.Dummy <Func <IWebResponse, object?, Task> >();
            var writerSpec = A.Fake <IWebWriterSpecification>();

            A.CallTo(() => writerSpec.Build()).Returns(writer);

            var response = A.Dummy <IWebResponse>();

            var sut = new WebRequestResponseObjectSpecification();

            sut.Object(obj);
            sut.SetWriterSpecification(writerSpec);

            var objectWriter = sut.Build();

            Assert.That(objectWriter, Is.Not.Null);

            await objectWriter(response);

            A.CallTo(() => writer.Invoke(response, obj)).MustHaveHappenedOnceExactly();
        }
コード例 #3
0
        public void Given_InvalidWriter_When_SetWriterSpecification_Then_Exception()
        {
            var sut = new WebRequestResponseObjectSpecification();

            Assert.That(() => sut.SetWriterSpecification(null), Throws.ArgumentNullException.With.Property("ParamName").EqualTo("writerSpecification"));
        }