Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }