Beispiel #1
0
        public void GetById_GivenNonExistingId_ShouldReturnNull()
        {
            // arrange
            int id = 10;

            Mock <IDbRepository <Drive> > mockRepository = new Mock <IDbRepository <Drive> >();

            mockRepository.Setup(m => m.GetById(It.Is <int>(i => i == id)))
            .Returns <Drive>(null);

            IDrivesService service = new DrivesService(mockRepository.Object, null, null);

            // act
            var result = service.GetById(id);

            // assert
            result.Should().BeNull();
        }
Beispiel #2
0
        public void GetById_GivenValidId_ShouldReturnValidDrive()
        {
            // arrange
            int id = 1;
            Mock <IDbRepository <Drive> > mockRepository = new Mock <IDbRepository <Drive> >();

            mockRepository.Setup(m => m.GetById(It.Is <int>(i => i == id)))
            .Returns(new Drive()
            {
                Id = id
            });

            IDrivesService service = new DrivesService(mockRepository.Object, null, null);

            // act
            var result = service.GetById(id);

            // assert
            result.Should().Equals(new Drive()
            {
                Id = id
            });
        }