Example #1
0
        public void CRUD_One_Attachment_And_Fetch_Runs_Successfully()
        {
            var connectionManager = new ConnectionManager(DbFile.GetConnectionString("testdb.db"));
            var repository        = new AttachmentRepository(connectionManager);
            var entry             = new Attachment
            {
                FileName    = "filename.pdf",
                Description = "New Attachment",
                Extension   = "pdf"
            };

            repository.InsertOne(entry);
            var insertedEntity = repository.GetOne(1);

            Assert.IsNotNull(entry);

            insertedEntity.Description = "Modified Attachment";
            repository.UpdateOne(insertedEntity);

            var updatedEntity = repository.GetOne(1);

            Assert.That(updatedEntity.Description, Is.EqualTo("Modified Attachment"));

            repository.DeleteOne(updatedEntity);

            var deletedEntity = repository.GetOne(insertedEntity.Id);

            Assert.IsNull(deletedEntity);
        }