Ejemplo n.º 1
0
        public void WhenMeetingsAreReturned_ThenViewModelIsPopulated()
        {
            var asyncResultMock = new Mock<IAsyncResult>();

            var calendarServiceMock = new Mock<ICalendarService>(MockBehavior.Strict);
            AsyncCallback callback = null;
            calendarServiceMock
                .Setup(svc => svc.BeginGetMeetings(It.IsAny<AsyncCallback>(), null))
                .Callback<AsyncCallback, object>((ac, o) => callback = ac)
                .Returns(asyncResultMock.Object);
            var meeting = new Meeting { };
            calendarServiceMock
                .Setup(svc => svc.EndGetMeetings(asyncResultMock.Object))
                .Returns(new[] { meeting });


            var viewModel = new CalendarViewModel(calendarServiceMock.Object, new Mock<IRegionManager>().Object);

            this.EnqueueConditional(() => callback != null);

            this.EnqueueCallback(
                () =>
                {
                    callback(asyncResultMock.Object);
                });

            this.EnqueueCallback(
                () =>
                {
                    CollectionAssert.AreEqual(viewModel.Meetings, new[] { meeting });
                    calendarServiceMock.VerifyAll();
                });

            this.EnqueueTestComplete();
        }
Ejemplo n.º 2
0
        public void WhenCreated_ThenRequestsMeetingsToService()
        {
            var calendarServiceMock = new Mock<ICalendarService>();
            var requested = false;
            calendarServiceMock
                .Setup(svc => svc.BeginGetMeetings(It.IsAny<AsyncCallback>(), null))
                .Callback(() => requested = true);

            var viewModel = new CalendarViewModel(calendarServiceMock.Object, new Mock<IRegionManager>().Object);

            Assert.IsTrue(requested);
        }
        public void WhenExecutingTheGoToEmailCommand_ThenNavigatesToEmailView()
        {
            var meeting = new Meeting { EmailId = Guid.NewGuid() };

            var calendarServiceMock = new Mock<ICalendarService>();

            Mock<IRegionManager> regionManagerMock = new Mock<IRegionManager>();
            regionManagerMock.Setup(x => x.RequestNavigate(RegionNames.MainContentRegion, new Uri(@"EmailView?EmailId=" + meeting.EmailId.ToString("N"), UriKind.Relative))).Verifiable();

            var viewModel = new CalendarViewModel(calendarServiceMock.Object, regionManagerMock.Object);

            viewModel.OpenMeetingEmailCommand.Execute(meeting);

            regionManagerMock.VerifyAll();
        }
Ejemplo n.º 4
0
        public void WhenExecutingTheGotToEmailCommand_ThenNavigatesToEmailView()
        {
            var meeting = new Meeting { EmailId = Guid.NewGuid() };

            var calendarServiceMock = new Mock<ICalendarService>();

            Mock<IRegion> regionMock = new Mock<IRegion>();
            regionMock
                .Setup(x => x.RequestNavigate(new Uri(@"EmailView?EmailId=" + meeting.EmailId.ToString("N"), UriKind.Relative), It.IsAny<Action<NavigationResult>>()))
                .Callback<Uri, Action<NavigationResult>>((s, c) => c(new NavigationResult(null, true)))
                .Verifiable();

            Mock<IRegionManager> regionManagerMock = new Mock<IRegionManager>();
            regionManagerMock.Setup(x => x.Regions.ContainsRegionWithName(RegionNames.MainContentRegion)).Returns(true);
            regionManagerMock.Setup(x => x.Regions[RegionNames.MainContentRegion]).Returns(regionMock.Object);

            var viewModel = new CalendarViewModel(calendarServiceMock.Object, regionManagerMock.Object);

            viewModel.OpenMeetingEmailCommand.Execute(meeting);

            regionMock.VerifyAll();
        }
        public CalendarView(CalendarViewModel viewModel)
        {
            InitializeComponent();

            this.ViewModel = viewModel;
        }