Ejemplo n.º 1
0
        public async Task ShouldPassDatesProperly()
        {
            // arrange
            var state     = new ScheduleState();
            var StartDate = new DateTime(2019, 8, 25, 14, 0, 0);
            var EndDate   = new DateTime(2019, 8, 25, 16, 0, 0);

            // Act
            var sut = new AvailabilityViewModel()
            {
                MyScheduleState    = state,
                ScheduleRepository = _ScheduleRepository.Object
            };

            sut.MySchedule = new Schedule {
                Id = 1
            };
            sut.NewScheduleItem.StartDateTime = StartDate;
            sut.NewScheduleItem.EndDateTime   = EndDate;
            sut.NewScheduleItem.Name          = "Interview with Emma";
            var results = await sut.AddNewScheduleItem();

            // Assert
            results.Should().BeEmpty();

            _ScheduleRepository.Verify(r => r.AddNewScheduleItem(It.IsAny <Schedule>(),
                                                                 It.Is <ScheduleItem>(i => i.StartDateTime == StartDate && i.EndDateTime == EndDate)),
                                       Times.Once, "Did not load the schedule item properly");
        }
Ejemplo n.º 2
0
        public async Task ShouldReturnAppropriateValidationMessages()
        {
            // arrange
            var state = new ScheduleState();

            // Act
            var sut = new AvailabilityViewModel()
            {
                MyScheduleState    = state,
                ScheduleRepository = _ScheduleRepository.Object
            };
            await sut.AddNewScheduleItem();

            // Assert
            _ScheduleRepository.Verify(r => r.AddNewScheduleItem(It.IsAny <Schedule>(), It.IsAny <ScheduleItem>()),
                                       Times.Never, "Should not have attempted to save the schedule");
        }