Beispiel #1
0
        public void GetStudioByName_ShouldCallRepository_WhenParametersAreCorrect(string name)
        {
            var repositoryMock = new Mock <IRepository <Studio> >();
            var unitOfWorkMock = new Mock <IUnitOfWork>();
            var factoryMock    = new Mock <IStudioFactory>();

            var service = new StudioService(repositoryMock.Object, unitOfWorkMock.Object, factoryMock.Object);

            service.GetStudioByName(name);

            repositoryMock.Verify(r => r.Entities, Times.Once);
        }
Beispiel #2
0
        public void GetStudioByName_ShouldReturnCorrectStudio_WhenParametersAreCorrect(string name)
        {
            var repositoryMock = new Mock <IRepository <Studio> >();
            var unitOfWorkMock = new Mock <IUnitOfWork>();
            var factoryMock    = new Mock <IStudioFactory>();
            var listOfStudios  = new List <Studio>();
            var studio         = new Studio(name, null);

            listOfStudios.Add(studio);
            repositoryMock.Setup(r => r.Entities).Returns(listOfStudios.AsQueryable);

            var service = new StudioService(repositoryMock.Object, unitOfWorkMock.Object, factoryMock.Object);
            var result  = service.GetStudioByName(name);

            Assert.AreSame(studio, result);
        }