public void AddProfilePicture_NonExisting_EmptyPath() { UserEntity Entity = new UserEntity() { ID = Guid.NewGuid(), FirstName = "Kiran" }; Mock<IUserEntityRepository> Repository = new Mock<IUserEntityRepository>(); Repository.Setup(o => o.Update(Entity, false)); Repository.SetupSequence(o => o.GetByID(Entity.ID)).Returns(null); Mock<IFileService> FileService = new Mock<IFileService>(); FileService.Setup(o => o.SaveMedia(It.IsAny<string>(), It.IsAny<byte[]>())).Returns(true); Mock<ILoggerService> LoggerService = new Mock<ILoggerService>(); UserService Service = new UserService(Repository.Object, FileService.Object, LoggerService.Object); string path = Service.AddProfilePicture(Entity.ID, Environment.CurrentDirectory, new byte[1]); Assert.AreEqual(string.Empty, path); }
public void AddProfilePicture_ExistingUser_PathAdded() { UserEntity Entity = new UserEntity() { ID = Guid.NewGuid(), FirstName = "Kiran" }; Mock<IUserEntityRepository> Repository = new Mock<IUserEntityRepository>(); Repository.Setup(o => o.Update(Entity, false)); Repository.Setup(o => o.GetByID(Entity.ID)).Returns(Entity); Mock<IFileService> FileService = new Mock<IFileService>(); FileService.Setup(o => o.SaveMedia(It.IsAny<string>(), It.IsAny<byte[]>())).Returns(true); Mock<ILoggerService> LoggerService = new Mock<ILoggerService>(); UserService Service = new UserService(Repository.Object, FileService.Object, LoggerService.Object); string path = Service.AddProfilePicture(Entity.ID, Environment.CurrentDirectory, new byte[1]); string expected = string.Format("{0}/Profile{1}.jpg", Environment.CurrentDirectory, Entity.ID.ToString()); Assert.AreEqual(expected, path); }