示例#1
0
        public async Task DeleteLoggedDayAsync_NullDay_DoesNothing()
        {
            // arrange
            var tracker = new Tracker {
                Id = 0
            };
            var vm = new TrackerLogViewModel(tracker, new MockTrackerLogService(), new MockSettingsViewModel());

            vm.AllDays.Add(null);

            // act
            await vm.DeleteLoggedDayAsync(null);

            // assert
            Assert.Single(vm.AllDays, expected: null);
        }
示例#2
0
        public async Task DeleteLoggedDayAsync_ServiceFailure_DoesNotDeleteFromAllDays()
        {
            // 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.DeleteLoggedDayAsync(day);

            // assert
            Assert.Single(vm.AllDays, expected: day);
        }
示例#3
0
        public async Task DeleteLoggedDayAsync_ExistingDay_DeletesDay()
        {
            // arrange
            var tracker = new Tracker {
                Id = 0
            };
            var day = new LoggedDay {
                Id = 0, TrackerId = 0
            };
            var service = new MockTrackerLogService();
            var vm      = new TrackerLogViewModel(tracker, service, new MockSettingsViewModel());

            service.LoggedDays.Add(day);
            vm.AllDays.Add(day);

            // act
            await vm.DeleteLoggedDayAsync(day);

            // assert
            Assert.Empty(vm.AllDays);
            Assert.Empty(service.LoggedDays);
        }
示例#4
0
        public async Task DeleteLoggedDayAsync_ServiceFailure_SendsMessageWithDay()
        {
            // 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);

            LoggedDay sentDay = null;

            MessagingCenter.Subscribe <TrackerLogViewModel, LoggedDay>(this, nameof(vm.DeleteLoggedDayCommand),
                                                                       (sender, loggedDay) => sentDay = loggedDay);

            // act
            await vm.DeleteLoggedDayAsync(day);

            // assert
            Assert.Equal(day, sentDay);
        }