public void ExposeProcessRequestTest1() { //Arrange var exposeService = MockRepository.GenerateMock <ExposeService>(); exposeService.Stub(x => x.Process(null)).IgnoreArguments().Return(new ResponseList { new UpdateBasketItemResponse { Result = new Basket() } }); var factory = MockRepository.GenerateMock <IServiceFactory>(); factory.Stub(x => x.CreateProxy <ExposeService, ExposeServiceClient>(Arg <bool> .Is.Anything, Arg <ICacheManager> .Is.Anything, Arg <string> .Is.Anything, ref Arg <ExposeServiceClient> .Ref(Is.Anything(), null).Dummy)) .Return(exposeService); // Act using (var client = new AccessClient(factory)) { client.RegisterRequest("1", new UpdateBasketItemRequest()); client.ProcessRequests(); Basket result; client.TryGet("1", out result); // Assert Assert.IsNotNull(result); } }
public void ExceptionWhenProcessingRequestsTest1() { //Arrange var exposeService = MockRepository.GenerateMock <ExposeService>(); exposeService.Stub(x => x.Process(null)).IgnoreArguments().Throw(new ApplicationException()); var factory = MockRepository.GenerateMock <IServiceFactory>(); factory.Stub(x => x.CreateProxy <ExposeService, ExposeServiceClient>(Arg <bool> .Is.Anything, Arg <ICacheManager> .Is.Anything, Arg <string> .Is.Anything, ref Arg <ExposeServiceClient> .Ref(Is.Anything(), null).Dummy)) .Return(exposeService); // Act using (var client = new AccessClient(factory)) { client.RegisterRequest("1", new UpdateBasketItemRequest()); client.ProcessRequests(); } // Assert Assert.Fail("Should not get here. ProcessRequest throws exeption."); }