Esempio n. 1
0
        public void CanGet()
        {
            _testDatabase.RunAndRollback(dbContext =>
            {
                var test1 = new Business.Entity.Test
                {
                    Name = "Snijden",
                    Date = DateTime.Today
                };

                var test2 = new Business.Entity.Test
                {
                    Name = "Bakken",
                    Date = DateTime.Today
                };

                dbContext.Tests.Add(test1);
                dbContext.Tests.Add(test2);
                dbContext.SaveChanges();

                var test = new TestRepository(dbContext).Get(test2.Id);

                Assert.NotNull(test);
                Assert.Equal(test2.Id, test.Id);
            });
        }
Esempio n. 2
0
        public void CanCreate()
        {
            _testDatabase.RunAndRollback(dbContext =>
            {
                var test = new Business.Entity.Test
                {
                    Name = "Snijden",
                    Date = DateTime.Today
                };

                var createdTest = new TestRepository(dbContext).Create(test);

                Assert.NotNull(createdTest);
                Assert.True(createdTest.Id > 0);
                Assert.Equal(test.Name, createdTest.Name);
            });
        }
Esempio n. 3
0
        public void CanUpdate()
        {
            _testDatabase.RunAndRollback(dbContext =>
            {
                var updatedName = "Koken";

                var test = new Business.Entity.Test
                {
                    Name = "Snijden",
                    Date = DateTime.Today
                };

                dbContext.Tests.Add(test);
                dbContext.SaveChanges();

                test.Name = updatedName;
                var updatedTest = new TestRepository(dbContext).Update(test);

                Assert.NotNull(updatedTest);
                Assert.Equal(test.Id, updatedTest.Id);
                Assert.Equal(updatedName, updatedTest.Name);
            });
        }