Exemplo n.º 1
0
        public void VerifyWcfHostCreateAValidProxyImplementation()
        {
            var          mock     = new Mock <IService>();
            const string Expected = "Hello Jim";

            mock.Setup(x => x.Hello(Name)).Returns(Expected);

            using (var host = WcfTestHostFactory.Create(mock.Object))
            {
                host
                .CreateProxy()
                .Hello(Name).Should().Be.EqualTo(Expected);
            }
        }
Exemplo n.º 2
0
        public void VerifyWcfHostCreateAValidProxyFaultImplementationThrowExpectedException()
        {
            var mock = new Mock <IService>();

            mock.Setup(x => x.Hello(It.IsAny <string>())).Throws <ArgumentException>();

            using (var host = WcfTestHostFactory.Create(mock.Object))
            {
                Executing
                .This(() => host.CreateProxy().Hello(Name))
                .Should().Throw <FaultException <ExceptionDetail> >()
                .And
                .Exception.Detail.Type.Should().Be.EqualTo(typeof(ArgumentException).FullName);
            }
        }