示例#1
0
        public async Task PopulateAllDaysAsync_ServiceFailure_DoesNotChangeState()
        {
            // arrange
            var tracker = new Tracker {
                Id = 0
            };
            var day = new LoggedDay {
                Id = 0, TrackerId = 0
            };
            var vm = new TrackerLogViewModel(tracker, new FailingTrackerLogService(), new MockSettingsViewModel());

            vm.AllDays.Add(day);

            // act
            await vm.PopulateAllDaysAsync();

            // assert
            Assert.Single(vm.AllDays, expected: day);
        }
示例#2
0
        public async Task PopulateAllDaysAsync_ServiceFailure_SendsMessage()
        {
            // arrange
            var tracker = new Tracker {
                Id = 0
            };
            var vm = new TrackerLogViewModel(tracker, new FailingTrackerLogService(), new MockSettingsViewModel());

            bool messageSent = false;

            MessagingCenter.Subscribe <TrackerLogViewModel>(this, TrackerLogViewModel.DatabaseErrorMessage,
                                                            sender => messageSent = true);

            // act
            await vm.PopulateAllDaysAsync();

            // assert
            Assert.True(messageSent);
        }