Ejemplo n.º 1
0
        public void GetAllMyCurrentSheetPartsTests_Successful()
        {
            var mockUnitOfWork = new Mock <ILibraryUnitOfWork>();

            //mockUnitOfWork.Setup(u => u.InstrumentRepository.GetAll())
            //     .Returns(MockInstruments());
            mockUnitOfWork.Setup(u => u.SheetRepository.GetAll())
            .Returns(MockSheets());
            //mockUnitOfWork.Setup(u => u.LibUserRepository.GetAll())
            //   .Returns(MockLibUsers());
            mockUnitOfWork.Setup(u => u.LibUserRepository.GetByIdentityUserId(It.IsAny <int>()))
            .Returns(new LibUserTO {
                Id = 2, IdentityUserId = 4, InstrumentIds = new List <int> {
                    2, 3
                }
            });
            mockUnitOfWork.Setup(u => u.SheetPartRepository.GetAll())
            .Returns(MockSheetParts());

            var sut    = new MusicianUC(mockUnitOfWork.Object, null);
            var result = sut.GetAllMyCurrentSheetParts(4);

            Assert.IsNotNull(result);
            Assert.AreEqual(0, result.Count(x => x.Instrument.Id == 1));
            Assert.AreEqual(0, result.Count(x => x.Sheet.Id == 1));
            mockUnitOfWork.Verify(u => u.SheetRepository.GetAll(), Times.Once);
            mockUnitOfWork.Verify(u => u.LibUserRepository.GetByIdentityUserId(4), Times.Once);
            mockUnitOfWork.Verify(u => u.SheetPartRepository.GetAll(), Times.AtLeast(1));
        }
Ejemplo n.º 2
0
        public void SeeASheetPartDetails_successful()
        {
            var mockUnitOfWork = new Mock <ILibraryUnitOfWork>();

            mockUnitOfWork.Setup(u => u.SheetPartRepository.GetById(It.IsAny <int>()))
            .Returns(new SheetPartTO {
                Id = 1, Path = $@"\Files\BestOf\Saxophone"
            });

            var sut    = new MusicianUC(mockUnitOfWork.Object, null);
            var result = sut.SeeASheetPartDetails(1);

            Assert.IsNotNull(result);
            mockUnitOfWork.Verify(u => u.SheetPartRepository.GetById(1), Times.Once);
        }