예제 #1
0
 public GivenThreeAdaptersInHierarchy()
 {
     this.service = new AdapterService();
     this.service.Register(Mock.Of <IAdapter <IFrom, string> >(a => a.Adapt(It.IsAny <IFrom>()) == "from"));
     this.service.Register(Mock.Of <IAdapter <IFrom2, string> >(a => a.Adapt(It.IsAny <IFrom2>()) == "from2"));
     this.service.Register(Mock.Of <IAdapter <IFrom3, string> >(a => a.Adapt(It.IsAny <IFrom3>()) == "from3"));
 }
예제 #2
0
 public GivenAConcreteTypeAdapter()
 {
     this.service = new AdapterService();
     this.service.Register(new ConcreteFromAdapter());
     this.service.Register(Mock.Of <IAdapter <IFrom, string> >(a => a.Adapt(It.IsAny <IFrom>()) == "from"));
     this.service.Register(Mock.Of <IAdapter <IFrom2, string> >(a => a.Adapt(It.IsAny <IFrom2>()) == "from2"));
     this.service.Register(Mock.Of <IAdapter <IFrom3, string> >(a => a.Adapt(It.IsAny <IFrom3>()) == "from3"));
 }
예제 #3
0
        public void WhenAdapterImplementsMultipleAdapterInterfaces_ThenRegistersForAll()
        {
            var service = new AdapterService();

            var adapter = new Mock <IAdapter <IFrom, string> >();

            adapter.Setup(a => a.Adapt(It.IsAny <IFrom>())).Returns("from");
            adapter.As <IAdapter <IFrom2, string> >().Setup(a => a.Adapt(It.IsAny <IFrom2>())).Returns("from2");
            adapter.As <IAdapter <IFrom3, string> >().Setup(a => a.Adapt(It.IsAny <IFrom3>())).Returns("from3");

            service.Register(adapter.Object);

            Assert.Equal("from", service.To <string>(Mock.Of <IFrom>()));
            Assert.Equal("from2", service.To <string>(Mock.Of <IFrom2>()));
            Assert.Equal("from3", service.To <string>(Mock.Of <IFrom3>()));
        }
예제 #4
0
 public GivenASingleAdapter()
 {
     this.service = new AdapterService();
     this.service.Register(Mock.Of <IAdapter <IFrom, string> >(a => a.Adapt(It.IsAny <IFrom>()) == "from"));
 }