示例#1
0
        public void CallBreweryServiceSearchMethodOnceWithCorrectParams()
        {
            var viewModel = new MockedBreweriesViewModel();
            var view      = new Mock <IBreweriesView>();

            view.Setup(v => v.Model)
            .Returns(viewModel);
            var service   = new Mock <IBreweryService>();
            var args      = MockedEventArgsGenerator.GetSearchEventArgs();
            var presenter = new BreweriesPresenter(service.Object, view.Object);

            view.Raise(v => v.BrewerySearch += null, view.Object, args);

            service.Verify(s => s.Search(args.Pattern), Times.Once);
        }
示例#2
0
        public void SetResultFromServiceToViewModel()
        {
            var expectedBreweries = new List <IBrewery>();

            var viewModel = new MockedBreweriesViewModel();
            var view      = new Mock <IBreweriesView>();

            view.Setup(v => v.Model)
            .Returns(viewModel);
            var args    = MockedEventArgsGenerator.GetSearchEventArgs();
            var service = new Mock <IBreweryService>();

            service.Setup(s => s.Search(args.Pattern))
            .Returns(expectedBreweries);
            var presenter = new BreweriesPresenter(service.Object, view.Object);

            view.Raise(v => v.BrewerySearch += null, view.Object, args);

            Assert.AreSame(expectedBreweries, view.Object.Model.Breweries);
        }