public void Save_ReturnsSlot_WhenCalled([NotNull] ISlotForResponse slot)
        {
            // Arrange
            var repository        = Substitute.For <ISlotsRepository>();
            InformationFinder sut = CreateSut(repository);

            // Act
            ISlotForResponse actual = sut.Save(slot);

            // Assert
            AssertSlotIgnoreId(slot,
                               actual);
        }
Esempio n. 2
0
        public void ListForDate_ReturnsEmpty_ForInvalidDateTime()
        {
            // Arrange
            var repository        = Substitute.For <IDaysRepository>();
            InformationFinder sut = CreateSut(repository);

            // Act
            IEnumerable <IDayForResponse> actual = sut.ListForDate("invalid");

            // Assert
            Assert.Equal(0,
                         actual.Count());
        }
Esempio n. 3
0
        public void FindById_ReturnsNull_ForNotExistingId()
        {
            // Arrange
            var repository = Substitute.For <IDaysRepository>();

            repository.FindById(-1).Returns(( IDay )null);
            InformationFinder sut = CreateSut(repository);

            // Act
            IDayForResponse actual = sut.FindById(-1);

            // Assert
            Assert.Null(actual);
        }
        public void Delete_ReturnsNull_ForUnknownId()
        {
            // Arrange
            var repository = Substitute.For <ISlotsRepository>();

            repository.FindById(Arg.Any <int>()).Returns(( ISlot )null);
            InformationFinder sut = CreateSut(repository);

            // Act
            ISlotForResponse actual = sut.Delete(IdDoesNotMatter);

            // Assert
            Assert.Null(actual);
        }
        public void Delete_CallsRemove_WhenCalled([NotNull] ISlot slot)
        {
            // Arrange
            var repository = Substitute.For <ISlotsRepository>();

            repository.FindById(Arg.Any <int>()).Returns(slot);
            InformationFinder sut = CreateSut(repository);

            // Act
            sut.Delete(IdDoesNotMatter);

            // Assert
            repository.Received().Remove(slot);
        }
        public void Delete_ReturnsNull_ForCanNotAdd()
        {
            // Arrange
            var repository = Substitute.For <IDoctorsRepository>();

            repository.Delete(Arg.Any <int>()).Returns(( IDoctor )null);
            InformationFinder sut = CreateSut(repository);

            // Act
            IDoctorForResponse actual = sut.Delete(DoesNotMatter);

            // Assert
            Assert.Null(actual);
        }
Esempio n. 7
0
        public void Delete_CallsRemove_WhenCalled([NotNull] IDay day)
        {
            // Arrange
            var repository = Substitute.For <IDaysRepository>();

            repository.FindById(-1).ReturnsForAnyArgs(day);
            InformationFinder sut = CreateSut(repository);

            // Act
            sut.Delete(DoesNotMatter);

            // Assert
            repository.Received().Remove(day);
        }
        public void FindById_ReturnsNull_ForNotExistingId()
        {
            // Arrange
            var repository = Substitute.For <ISlotsRepository>();

            repository.FindById(IdDoesNotMatter).Returns(( ISlot )null);
            InformationFinder sut = CreateSut(repository);

            // Act
            ISlotForResponse actual = sut.FindById(IdDoesNotMatter);

            // Assert
            Assert.Null(actual);
        }
Esempio n. 9
0
        public void Delete_ReturnsNull_ForCanNotAdd()
        {
            // Arrange
            var repository = Substitute.For <IDaysRepository>();

            repository.FindById(-1).ReturnsForAnyArgs(( IDay )null);
            InformationFinder sut = CreateSut(repository);

            // Act
            IDayForResponse actual = sut.Delete(DoesNotMatter);

            // Assert
            Assert.Null(actual);
        }
        public void FindById_ReturnsSlot_ForExistingId([NotNull] ISlot slot)
        {
            // Arrange
            var repository = Substitute.For <ISlotsRepository>();

            repository.FindById(slot.Id).Returns(slot);
            InformationFinder sut = CreateSut(repository);

            // Act
            ISlotForResponse actual = sut.FindById(slot.Id);

            // Assert
            Assert.Equal(slot.Id,
                         actual.Id);
        }
        public void Delete_ReturnsDeletedSlot_WhenCalled([NotNull] ISlot slot)
        {
            // Arrange
            var repository = Substitute.For <ISlotsRepository>();

            repository.FindById(Arg.Any <int>()).Returns(slot);
            InformationFinder sut = CreateSut(repository);

            // Act
            ISlotForResponse actual = sut.Delete(IdDoesNotMatter);

            // Assert
            Assert.Equal(slot.Id,
                         actual.Id);
        }
        public void Delete_ReturnsNewDoctor_WhenCalled([NotNull] IDoctor doctor)
        {
            // Arrange
            var repository = Substitute.For <IDoctorsRepository>();

            repository.Delete(Arg.Any <int>()).Returns(doctor);
            InformationFinder sut = CreateSut(repository);

            // Act
            IDoctorForResponse actual = sut.Delete(DoesNotMatter);

            // Assert
            Assert.Equal(doctor.Id,
                         actual.Id);
        }
        public void FindByLastName_ReturnsDoctors_WhenCalled([NotNull] IDoctor doctor)
        {
            // Arrange
            var repository = Substitute.For <IDoctorsRepository>();

            repository.FindByLastName(Arg.Any <string>()).Returns(CreateList);
            InformationFinder sut = CreateSut(repository);

            // Act
            IEnumerable <IDoctorForResponse> actual = sut.FindByLastName("any name");

            // Assert
            Assert.Equal(2,
                         actual.Count());
        }
        public void Save_CallsSave_WhenCalled([NotNull] ISlotForResponse slot)
        {
            // Arrange
            var repository        = Substitute.For <ISlotsRepository>();
            InformationFinder sut = CreateSut(repository);

            // Act
            sut.Save(slot);

            // Assert
            repository.Received().Save(Arg.Is <ISlot>(x => x.DayId == slot.DayId &&
                                                      x.StartDateTime == slot.StartDateTime &&
                                                      x.EndDateTime == slot.EndDateTime &&
                                                      x.Status == slot.Status));
        }
Esempio n. 15
0
        public void Delete_ReturnsDeletedDoctor_WhenCalled([NotNull] IDay day)
        {
            // Arrange
            var repository = Substitute.For <IDaysRepository>();

            repository.FindById(-1).ReturnsForAnyArgs(day);
            InformationFinder sut = CreateSut(repository);

            // Act
            IDayForResponse actual = sut.Delete(DoesNotMatter);

            // Assert
            Assert.Equal(day.Id,
                         actual.Id);
        }
Esempio n. 16
0
        public void ListForDate_ReturnsDays_WhenCalled()
        {
            // Arrange
            var repository = Substitute.For <IDaysRepository>();

            repository.FindByDate(Arg.Any <DateTime>()).Returns(CreateList);
            InformationFinder sut = CreateSut(repository);

            // Act
            IEnumerable <IDayForResponse> actual = sut.ListForDate("2000-01-01");

            // Assert
            Assert.Equal(2,
                         actual.Count());
        }
Esempio n. 17
0
        public void List_ReturnsDays_WhenCalled()
        {
            // Arrange
            var repository = Substitute.For <IDaysRepository>();

            repository.All.Returns(CreateList);
            InformationFinder sut = CreateSut(repository);

            // Act
            IEnumerable <IDayForResponse> actual = sut.List();

            // Assert
            Assert.Equal(2,
                         actual.Count());
        }
Esempio n. 18
0
        public void Save_CallsSave_WhenCalled([NotNull] IDayForResponse toBeUpdated,
                                              [NotNull] IDay day)
        {
            // Arrange
            var repository = Substitute.For <IDaysRepository>();

            repository.Save(Arg.Any <IDay>());
            InformationFinder sut = CreateSut(repository);

            // Act
            sut.Save(toBeUpdated);

            // Assert
            repository.Received().Save(Arg.Is <IDay>(x => x.Id == toBeUpdated.Id));
        }
Esempio n. 19
0
        public void FindById_ReturnsDay_ForExistingId([NotNull] IDay day)
        {
            // Arrange
            var repository = Substitute.For <IDaysRepository>();

            repository.FindById(day.Id).Returns(day);
            InformationFinder sut = CreateSut(repository);

            // Act
            IDayForResponse actual = sut.FindById(day.Id);

            // Assert
            Assert.Equal(day.Id,
                         actual.Id);
        }
Esempio n. 20
0
        public void FindById_ReturnsDay_FindByDoctorId([NotNull] IDay day)
        {
            // Arrange
            var repository = Substitute.For <IDaysRepository>();

            repository.FindByDoctorId(1).Returns(CreateList);
            InformationFinder sut = CreateSut(repository);

            // Act
            IEnumerable <IDayForResponse> actual = sut.FindByDoctorId(1);

            // Assert
            Assert.Equal(2,
                         actual.Count());
        }
Esempio n. 21
0
        public void Save_ReturnsUpdatedDoctor_ForExisting([NotNull] IDayForResponse toBeUpdated,
                                                          [NotNull] IDay day)
        {
            // Arrange
            var repository = Substitute.For <IDaysRepository>();

            repository.Save(Arg.Any <IDay>());
            InformationFinder sut = CreateSut(repository);

            // Act
            IDayForResponse actual = sut.Save(toBeUpdated);

            // Assert
            Assert.Equal(toBeUpdated.Id,
                         actual.Id);
        }
Esempio n. 22
0
        public void ListForDateAndDoctorId_ReturnsDays_WhenCalled()
        {
            // Arrange
            var repository = Substitute.For <IDaysRepository>();

            repository.All.Returns(CreateDaysForListForDateAndDoctorId);
            InformationFinder sut = CreateSut(repository);

            // Act
            IEnumerable <IDayForResponse> actual =
                sut.ListForDateAndDoctorId("2000-01-01",
                                           DefaultDoctorId);

            // Assert
            Assert.Equal(1,
                         actual.Count());
        }
        public void List_ReturnsCorrectNumberOfSlots_ForStatusOpen(string slotStatus,
                                                                   int expected)
        {
            // Arrange
            var repository = Substitute.For <IDoctorsSlotsRepository>();

            repository.FindSlotsForDoctorByDoctorId(Arg.Any <int>()).Returns(CreateList);
            InformationFinder sut = CreateSut(repository);

            // Act
            IEnumerable <ISlot> actual = sut.List(DoesNotMatter,
                                                  null,
                                                  slotStatus);

            // Assert
            Assert.Equal(expected,
                         actual.Count());
        }
        public void List_ReturnsSlots_ForDate(string date,
                                              int expected)
        {
            // Arrange
            var repository = Substitute.For <IDoctorsSlotsRepository>();

            repository.FindSlotsForDoctorByDoctorId(Arg.Any <int>()).Returns(CreateList);
            InformationFinder sut = CreateSut(repository);

            // Act
            ISlot actual = sut.List(DoesNotMatter,
                                    date,
                                    null).First();

            // Assert
            Assert.Equal(expected,
                         actual.Id);
        }
        public void List_ReturnsSlots_ForMultipleForStatus(SlotStatus status,
                                                           int expected)
        {
            // Arrange
            IEnumerable <ISlot> list = CreateListWithSameStatus(status);
            var repository           = Substitute.For <IDoctorsSlotsRepository>();

            repository.FindSlotsForDoctorByDoctorId(Arg.Any <int>()).Returns(list);
            InformationFinder sut = CreateSut(repository);

            // Act
            IEnumerable <ISlot> actual = sut.List(DoesNotMatter,
                                                  null,
                                                  status.ToString());

            // Assert
            Assert.Equal(expected,
                         actual.Count());
        }
        public void List_ReturnsSlots_ForMultipleForDates()
        {
            // Arrange
            const string        date = "2001-01-01";
            IEnumerable <ISlot> list = CreateListWithSameDate(date);
            var repository           = Substitute.For <IDoctorsSlotsRepository>();

            repository.FindSlotsForDoctorByDoctorId(Arg.Any <int>()).Returns(list);
            InformationFinder sut = CreateSut(repository);

            // Act
            IEnumerable <ISlot> actual = sut.List(DoesNotMatter,
                                                  date,
                                                  null);

            // Assert
            Assert.Equal(3,
                         actual.Count());
        }
        public void FindByDayId_ReturnsSlots_ForExistingDayId([NotNull] ISlot slot)
        {
            // Arrange
            var slots = new[]
            {
                slot
            };

            var repository = Substitute.For <ISlotsRepository>();

            repository.FindByDayId(Arg.Any <int>()).Returns(slots);
            InformationFinder sut = CreateSut(repository);

            // Act
            IEnumerable <ISlotForResponse> actual = sut.FindByDayId(slot.DayId);

            // Assert
            Assert.Equal(1,
                         actual.Count());
        }
Esempio n. 28
0
        public void FilterByDoctorId_ReturnsEmpty_ForNotExistingDoctorId()
        {
            // Arrange
            IEnumerable <IDay> days = CreateDaysWithMatchingDateTime(DefaultDate,
                                                                     DefaultDoctorId);
            var repository = Substitute.For <IDaysRepository>();

            repository.All.Returns(days);

            InformationFinder sut = CreateSut(repository);

            // Act
            IEnumerable <IDayForResponse> actual =
                sut.ListForDateAndDoctorId(DefaultDate,
                                           "-1");

            // Assert
            Assert.Equal(0,
                         actual.Count());
        }