public void SetUp() { mockRepository = new MockRepository(); mainTransport = mockRepository.StrictMultiMock<ITransport>(); mainTransport.Replay(); retryingTransport = new RetryingTransport(new SilentLogger(), mainTransport, retryCount, retryDelay); }
public void BeginTest() { repo = new MockRepository(); channelFactory = repo.StrictMock<ICanCreateChannels<IService>>(); communicationObject = repo.StrictMultiMock<ICommunicationObject>(typeof(IService)); manager = new SingleActionChannelManager<IService>(channelFactory); }
public void ListByDateReturnsListGreaterThanZero() { // var startDate = DateTime.Now.Date; var endDate = DateTime.Now.Date.AddDays(1); // Arrange var repository = new MockRepository(); var mockService = repository.StrictMultiMock<ITaskService>(typeof(ICommunicationObject)); mockService.Expect(f => f.ListByDate(null)) // ignore arguements below .IgnoreArguments() .Return( new TaskListResponse { Items = new List<TaskDto>() { new TaskDto() } }); //mockService.Expect(f => ((ICommunicationObject)f).State).Return(CommunicationState.Opened); //mockService.Expect(f => ((ICommunicationObject)f).Close()); // only used with invoker, which I'm trying to move to Unity.MVC.WCF instead repository.ReplayAll(); // Act var gateway = new TaskGateway(mockService); var response = gateway.ListByDate(startDate, endDate); // Assert Assert.IsTrue(response.Items.Count > 0); mockService.VerifyAllExpectations(); }
public void Accept () { var mockRepository = new MockRepository (); var visitorMock = mockRepository.StrictMultiMock<ExpressionTreeVisitor> (typeof (ISqlCustomTextGeneratorExpressionVisitor)); var customTextGeneratorExpression = new TestableSqlCustomTextGeneratorExpression (typeof (Cook)); visitorMock .Expect (mock => ((ISqlCustomTextGeneratorExpressionVisitor)mock).VisitSqlCustomTextGeneratorExpression (customTextGeneratorExpression)) .Return (customTextGeneratorExpression); visitorMock.Replay(); customTextGeneratorExpression.Accept (visitorMock); visitorMock.VerifyAllExpectations(); }
public void ListByDateReturnsListGreaterThenZero() { // var startDate = DateTime.Now.Date; var endDate = DateTime.Now.Date.AddDays(1); // Arrange var result = new List<Task>() { new Task { } }; var repository = new MockRepository(); var mockService = repository.StrictMultiMock<ITaskBusinessService>(); mockService .Expect(f => f.ListByDate(startDate, endDate)) // ignore arguements below .IgnoreArguments() .Return(result); // proxy var stubProxy = MockRepository.GenerateStub<ITaskService>(); stubProxy .Stub(m => m.ListByDate(Arg<TaskListRequest>.Is.Anything)) .Return(new TaskListResponse() { Items = new List<TaskDto>() { new TaskDto() { TaskId = 1 } } }); repository.ReplayAll(); // service var service = new TaskService(mockService); // Act var request = new TaskListRequest { StartDate = startDate, EndDate = endDate }; var response = service.ListByDate(request); // Assert Assert.IsTrue(response.Items.Count > 0); }
public void ListByDateReturnsListGreaterThanZero() { // var startDate = DateTime.Now.Date; var endDate = DateTime.Now.Date.AddDays(1); // Arrange var repository = new MockRepository(); var mockService = repository.StrictMultiMock<ITaskRepository>(); mockService.Expect(f => f.ListByDate(startDate, endDate)) // ignore arguements below .IgnoreArguments() .Return(new List<Task> { new Task() }); mockService.Replay(); // Act var service = new TaskBusinessService(mockService); var result = service.ListByDate(startDate, endDate); // Assert Assert.IsTrue(result.Count > 0); }
public void accept_a_visitor_with_no_interception_and_a_visitable_inner() { var mocks = new MockRepository(); var visitor = mocks.StrictMock<IBuildPlanVisitor>(); var inner = mocks.StrictMultiMock<IDependencySource>(typeof (IBuildPlanVisitable)); var plan = new BuildPlan(typeof (IGateway), new ObjectInstance(new StubbedGateway()), inner, null); using (mocks.Ordered()) { visitor.Instance(plan.PluginType, plan.Instance); inner.As<IBuildPlanVisitable>().AcceptVisitor(visitor); } mocks.ReplayAll(); using (mocks.Playback()) { plan.AcceptVisitor(visitor); } }