Ejemplo n.º 1
0
        public void CallOnce_EfDbContextSave_When_Photocourse_IsNotNull()
        {
            // Arange
            Fixture fixture               = new Fixture();
            var     sanitaizerResult      = fixture.Create <string>();
            var     mockedModelDbFactory  = new Mock <IModelDbFactory>();
            var     mockedSanitizer       = new Mock <ISanitizer>();
            var     mockedMapper          = new Mock <IAutoMapperService>();
            var     mockedEfDbContext     = new Mock <IEfDbContextSaveChanges>();
            var     mockedIEfDbRepository = new Mock <IPhotoArtSystemEfDbRepository <Photocourse> >();
            var     service               = new PhotocourseService(
                mockedModelDbFactory.Object,
                mockedSanitizer.Object,
                mockedMapper.Object,
                mockedEfDbContext.Object,
                mockedIEfDbRepository.Object);

            mockedSanitizer.Setup(x => x.Sanitize(It.IsAny <string>())).Returns(sanitaizerResult);

            // Act
            service.Create(new PhotocourseTransitional());

            // Assert
            mockedEfDbContext.Verify(x => x.Save(), Times.Once);
        }
Ejemplo n.º 2
0
        public void Throw_ArgumentNullException_WithProperMessage_When_Photocourse_IsNull()
        {
            // Arange
            var mockedModelDbFactory  = new Mock <IModelDbFactory>();
            var mockedSanitizer       = new Mock <ISanitizer>();
            var mockedMapper          = new Mock <IAutoMapperService>();
            var mockedEfDbContext     = new Mock <IEfDbContextSaveChanges>();
            var mockedIEfDbRepository = new Mock <IPhotoArtSystemEfDbRepository <Photocourse> >();
            var service = new PhotocourseService(
                mockedModelDbFactory.Object,
                mockedSanitizer.Object,
                mockedMapper.Object,
                mockedEfDbContext.Object,
                mockedIEfDbRepository.Object);

            // Act & Assert
            Assert.That(
                () => service.Create(null),
                Throws.ArgumentNullException.With.Message.Contains(
                    GlobalConstants.PhotocourseTransitionalRequiredExceptionMessage));
        }