private async Task RecursiveInsertFascicleFoldersAsync(Fascicle fascicle, FascicleFolder parent, IEnumerable <FascicleFolder> fascicleFolders, IEnumerable <FascicleFolder> foldersToEvaluate) { if (foldersToEvaluate == null || !foldersToEvaluate.Any()) { return; } FascicleFolder fascicleNode; foreach (FascicleFolder folder in foldersToEvaluate) { fascicleNode = new FascicleFolder { UniqueId = Guid.NewGuid(), Fascicle = fascicle, Name = folder.Name, Category = folder.Category, Status = FascicleFolderStatus.Active, Typology = FascicleFolderTypology.SubFascicle, ParentInsertId = parent.UniqueId }; _unitOfWork.Repository <FascicleFolder>().Insert(fascicleNode); await _unitOfWork.SaveChangesAsync(); await RecursiveInsertFascicleFoldersAsync(fascicle, fascicleNode, fascicleFolders, fascicleFolders.Where(f => f.ParentInsertId.HasValue && f.ParentInsertId.Value == folder.UniqueId)); } }
public async Task TestMethod_Delete_NotThrows() { IMessageService service = _unityContainer.Resolve <IMessageService>(); IDataUnitOfWork unitOfWork = _unityContainer.Resolve <IDataUnitOfWork>(); Message message = CustomElements.CreateMessageModel(); service.Create(message); await unitOfWork.SaveChangesAsync(); Message messageToDelete = service.Queryable().FirstOrDefault(f => f.EntityId == CustomElements.MessageId); service.Delete(messageToDelete); await unitOfWork.SaveChangesAsync(); Message messageDeleted = service.Queryable().FirstOrDefault(f => f.EntityId == CustomElements.MessageId); Assert.IsNull(messageDeleted); }
public async Task TestMethod_Delete_NotThrows() { ICollaborationService service = _unityContainer.Resolve <ICollaborationService>(); IDataUnitOfWork unitOfWork = _unityContainer.Resolve <IDataUnitOfWork>(); Collaboration collaboration = CustomElements.CreateCollaborationModel(); collaboration = service.Create(collaboration); await unitOfWork.SaveChangesAsync(); Collaboration collaborationToDelete = service.Queryable().FirstOrDefault(f => f.EntityId == CustomElements.CollaborationId); service.Delete(collaborationToDelete); await unitOfWork.SaveChangesAsync(); Collaboration collaborationDeleted = service.Queryable().FirstOrDefault(f => f.EntityId == CustomElements.CollaborationId); Assert.IsNull(collaborationDeleted); }
public async Task TestMethod_DeleteAsync_NotThrows() { IDeskService service = _unityContainer.Resolve <IDeskService>(); IDataUnitOfWork unitOfWork = _unityContainer.Resolve <IDataUnitOfWork>(); Desk desk = CustomElements.CreateDeskModel(); service.Create(desk); await unitOfWork.SaveChangesAsync(); Desk deskToDelete = service.Queryable().FirstOrDefault(f => f.UniqueId == CustomElements.DeskId); await service.DeleteAsync(deskToDelete); await unitOfWork.SaveChangesAsync(); Desk deskDeleted = service.Queryable().FirstOrDefault(f => f.UniqueId == CustomElements.DeskId); Assert.IsNull(deskDeleted); }
public async Task TestMethod_Update_NotThrows() { IMessageService service = _unityContainer.Resolve <IMessageService>(); IDataUnitOfWork unitOfWork = _unityContainer.Resolve <IDataUnitOfWork>(); Message message = CustomElements.CreateMessageModel(); service.Create(message); await unitOfWork.SaveChangesAsync(); Message messageToUpdate = service.Queryable().FirstOrDefault(f => f.EntityId == CustomElements.MessageId); messageToUpdate.Status = MessageStatus.Error; service.Update(messageToUpdate); await unitOfWork.SaveChangesAsync(); Message messageModified = service.Queryable().FirstOrDefault(f => f.EntityId == CustomElements.MessageId); Assert.IsNotNull(messageModified); Assert.AreEqual(MessageStatus.Error, messageModified.Status); }
public async Task TestMethod_Update_NotThrows() { ICollaborationService service = _unityContainer.Resolve <ICollaborationService>(); IDataUnitOfWork unitOfWork = _unityContainer.Resolve <IDataUnitOfWork>(); Collaboration collaboration = CustomElements.CreateCollaborationModel(); collaboration = service.Create(collaboration); await unitOfWork.SaveChangesAsync(); Collaboration collaborationToUpdate = service.Queryable().FirstOrDefault(f => f.EntityId == CustomElements.CollaborationId); collaborationToUpdate.Note = "Unit Test - Modifica"; service.Update(collaborationToUpdate); await unitOfWork.SaveChangesAsync(); Collaboration collaborationModified = service.Queryable().FirstOrDefault(f => f.EntityId == CustomElements.CollaborationId); Assert.IsNotNull(collaborationModified); Assert.AreEqual("Unit Test - Modifica", collaborationModified.Note); }
public async Task TestMethod_Update_NotThrows() { IDeskService service = _unityContainer.Resolve <IDeskService>(); IDataUnitOfWork unitOfWork = _unityContainer.Resolve <IDataUnitOfWork>(); Desk desk = CustomElements.CreateDeskModel(); service.Create(desk); await unitOfWork.SaveChangesAsync(); Desk deskToUpdate = service.Queryable().FirstOrDefault(f => f.UniqueId == CustomElements.DeskId); deskToUpdate.Description = "Unit Test - Modifica"; service.Update(deskToUpdate); await unitOfWork.SaveChangesAsync(); Desk deskModified = service.Queryable().FirstOrDefault(f => f.UniqueId == CustomElements.DeskId); Assert.IsNotNull(deskModified); Assert.AreEqual("Unit Test - Modifica", deskModified.Description); }