public void AddDiploma_CorrectDiploma_CallsCreateAndSave() { _sut = new PhotoService(_exampleWorkRepositoryMock.Object, _diplomaRepositoryMock.Object, _unitOfWorkMock.Object); _sut.AddDiploma(new Diploma()); _diplomaRepositoryMock.Verify(m => m.Create(It.IsAny <Diploma>()), Times.Once); _unitOfWorkMock.Verify(m => m.SaveChanges(), Times.Once); }
public ActionResult AddDiploma(DiplomaViewModel diploma) { var user = _userService.GetCurrent(User.Identity.Name); foreach (var photo in diploma.Photos) { var diplomaToAdd = new Diploma { MasterId = user.Master.MasterId }; using (var binaryReader = new BinaryReader(photo.InputStream)) { diplomaToAdd.ScanDiploma = binaryReader.ReadBytes(photo.ContentLength); } _photoService.AddDiploma(diplomaToAdd); } return(RedirectToAction("UserProfile", "User")); }