Esempio n. 1
0
        public void WhenEntityIsInvalidThenThrowExceptionAndDontSave()
        {
            //Arrange
            var album     = new Album();
            var daoAlbum  = new DaoStub <Album>().AddEntity(album);
            var validator = new Mock <IEntityValidator>();

            validator.Setup(v => v.IsValid(album)).Returns(false);
            var model = new AlbumManager(daoAlbum, validator.Object);

            //Act
            model.Executing(am => am.Save(album))
            .Throws <InvalidOperationException>();                    //assert

            //assert
            daoAlbum.Mock.Verify(da => da.MakePersistent(album), Times.Never());
        }