Esempio n. 1
0
        public void InvokeIAdvertService_GetAllAdvertsMethodOnce()
        {
            var editAdvertViewMock = new Mock <IEditAdvertsView>();

            editAdvertViewMock.SetupGet(view => view.Model).Returns(new EditAdvertsViewModel());

            var advertServiceMock = new Mock <IAdvertServices>();

            var editAdvertPresenter = new EditAdvertsPresenter(editAdvertViewMock.Object, advertServiceMock.Object);

            editAdvertPresenter.View_OnAdvertsGetData(null, EventArgs.Empty);

            advertServiceMock.Verify(a => a.GetAllAdverts(), Times.Once);
        }
Esempio n. 2
0
        public void AddAdvertsToViewModel_WhenOnAdvertsGetDataEventIsRaised(string testPicturePath)
        {
            var editAdvertViewMock = new Mock <IEditAdvertsView>();

            editAdvertViewMock.SetupGet(view => view.Model).Returns(new EditAdvertsViewModel());

            var adverts           = GetAdverts();
            var advertServiceMock = new Mock <IAdvertServices>();

            advertServiceMock.Setup(a => a.GetAllAdverts()).Returns(adverts);

            var editAdvertPresenter = new EditAdvertsPresenter(editAdvertViewMock.Object, advertServiceMock.Object);

            editAdvertPresenter.View_OnAdvertsGetData(null, EventArgs.Empty);

            editAdvertViewMock.Raise(v => v.OnAdvertsGetData += null, EventArgs.Empty);

            CollectionAssert.AreEquivalent(adverts, editAdvertViewMock.Object.Model.Adverts);
        }