public void SetUp() { filesManager = new Mock <IFilesManager>(); database = new Mock <IDatabase>(); tempDatabaseCleaner = new Mock <ITempDatabaseCleaner>(); customInteriorManager = new Mock <ICustomInteriorManager>(); httpContextReader = new Mock <IHttpContextReader>(); filesManager.Setup(f => f.Upload(It.IsNotNull <IFormFile>(), It.IsNotNull <string>())) .ReturnsAsync(uploadedFile); database.Setup(d => d.PremiumFileRepository.Insert(It.IsNotNull <PremiumFile>(), false)).ReturnsAsync(true); database.Setup(d => d.PremiumFileRepository.GetFileWithOrder(OldFileId)).ReturnsAsync(() => { var premiumFile = new PremiumFile(); premiumFile.SetOrder(new Order()); return(premiumFile); }); database.Setup(d => d.PremiumFileRepository.GetFileWithOrderAndEstate(OldFileId)).ReturnsAsync(() => { var premiumFile = new PremiumFile(); premiumFile.SetOrder(new Order()); premiumFile.SetEstate(new Estate()); return(premiumFile); }); database.Setup(d => d.BeginTransaction()).Returns(new DatabaseTransaction()); database.Setup(d => d.PremiumFileRepository.Delete(It.IsNotNull <PremiumFile>())).ReturnsAsync(true); database.Setup(d => d.OrderRepository.Update(It.IsNotNull <Order>())).ReturnsAsync(true); customInteriorManager.Setup(c => c.InitGameTempObjectsAndInteriors(It.IsNotNull <Estate>(), It.IsNotNull <PremiumFile>())) .Returns((new List <GameTempObject>(), new GameTempInterior())); httpContextReader.Setup(h => h.CurrentUserId).Returns(UserId); premiumUserLibraryManager = new PremiumUserLibraryManager(filesManager.Object, database.Object, tempDatabaseCleaner.Object, customInteriorManager.Object, httpContextReader.Object); }