示例#1
0
        public void GetAll_ShouldReturnAllLaptopsFromDatabase_WhickAreNotDeleted()
        {
            // Arrange
            var mockedEfRepository = new Mock <IEfRepository <Laptop> >();
            var mockedUnitOfWork   = new Mock <IUnitOfWork>();

            mockedEfRepository.Setup(x => x.All);

            var service = new LaptopsService(mockedEfRepository.Object, mockedUnitOfWork.Object);

            // Act
            var result = service.GetAll();

            // Assert
            mockedEfRepository.Verify(x => x.All, Times.Once);
        }
示例#2
0
        public void DeleteLaptop_ShouldDeleteLaptopInDatabase()
        {
            // Arrange
            var mockedEfRepository = new Mock <IEfRepository <Laptop> >();
            var mockedUnitOfWork   = new Mock <IUnitOfWork>();
            var laptop             = new Laptop();

            mockedEfRepository.Setup(x => x.Delete(laptop));

            var service = new LaptopsService(mockedEfRepository.Object, mockedUnitOfWork.Object);


            // Act
            service.Delete(laptop);

            // Assert
            mockedEfRepository.Verify(x => x.Delete(laptop), Times.Once);
        }
 public LaptopController()
 {
     this.service = new LaptopsService();
 }