Esempio n. 1
0
        public void CreateStudio_ShouldCallFactory_WhenParametersAreCorrect(string name, string address)
        {
            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.CreateStudio(name, address);

            factoryMock.Verify(f => f.CreateStudio(name, address), Times.Once);
        }
Esempio n. 2
0
        public void CreateStudio_ShouldReturnTheSameStudio_WhenParametersAreCorrect(string name, string address)
        {
            var repositoryMock = new Mock <IRepository <Studio> >();
            var unitOfWorkMock = new Mock <IUnitOfWork>();
            var factoryMock    = new Mock <IStudioFactory>();
            var studioMock     = new Mock <Studio>();

            factoryMock.Setup(f => f.CreateStudio(name, address)).Returns(studioMock.Object);

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

            Assert.AreSame(studioMock.Object, result);
        }