Esempio n. 1
0
        public void ShouldCreateUpdateAndDeleteNode()
        {
            var p = new Person
            {
                Name  = "my name",
                Extra = "extra info"
            };

            // Create
            var created = _repository.Create(p);

            Assert.NotNull(created);
            Assert.AreSame(p, created);
            Assert.NotNull(created.Id);
            Assert.NotNull(created.CreatedAt);
            Assert.NotNull(created.UpdatedAt);

            var loaded = _repository.FindById <Person>(p.Id.Value);

            Assert.NotNull(loaded);
            Assert.AreEqual(p.Id, loaded.Id);
            Assert.AreEqual(p.Name, loaded.Name);
            Assert.NotNull(loaded.CreatedAt);
            Assert.NotNull(loaded.UpdatedAt);

            // Update
            p.Name = "System";
            _repository.Update(p);

            loaded = _repository.FindById <Person>(p.Id.Value);
            Assert.AreEqual("System", loaded.Name);

            // Delete
            _repository.DeleteById <Person>(p.Id.Value, true);
            Assert.Null(_repository.FindById <Person>(p.Id.Value));
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            NeoDataBaseGenerator.Generate();

            var repository = new NeoRepository <Student>();

            repository.Create(new Student {
                Id = Guid.NewGuid(), Name = "Test", Email = "*****@*****.**"
            });

            var student = repository.Get(p => p.Name == "Test");

            student.Name = "Test1";
            student      = repository.Update(student);

            repository.Delete(student);
        }