public void DeleteCertification()
        {
            // Arrange
            CertificationController controller = new CertificationController();

            var actResult = controller.Delete(1);
            // Act
            var result = actResult as OkNegotiatedContentResult <bool>;

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Content == true);
        }
Esempio n. 2
0
        public async Task should_delegate_to_repo_to_delete_document_and_related_course_documents()
        {
            var objectId            = ObjectId.Parse(Id);
            var certificationCursor = StubCursor <Certification>(CertCollectionName);
            var cert = new Certification {
                Id = objectId
            };

            StubSingleFoundResult(certificationCursor, cert);
            Repository.Setup(x => x.DeleteManyAsync(CertCollectionName, It.IsAny <Expression <Func <Certification, bool> > >()))
            .ReturnsAsync(new DeleteResult.Acknowledged(1));
            Repository.Setup(x => x.DeleteAsync(CertCollectionName, It.IsAny <Expression <Func <Certification, bool> > >()))
            .ReturnsAsync(new DeleteResult.Acknowledged(1));

            await ExecuteEndpoint(_controller.Delete(Id));

            Repository.Verify(x => x.DeleteAsync(CertCollectionName,
                                                 It.Is <Expression <Func <Certification, bool> > >(e => Lambda.Eq(e, f => f.Id == objectId))));
            Repository.Verify(x => x.DeleteManyAsync(CourseCollectionName,
                                                     It.Is <Expression <Func <Course, bool> > >(e => Lambda.Eq(e, f => f.CertificationId == Id))));
        }