Example #1
0
        public void DeleteIncludAllTable()
        {
            var option = new DbContextOptionsBuilder <PermaContext>()
                         .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name)
                         .Options;

            using (var memoryContext = new PermaContext(option))
            {
                //Act
                GenericRepository <Location> locationRepository = new GenericRepository <Location>(memoryContext);
                GenericRepository <Site>     siteRepository     = new GenericRepository <Site>(memoryContext);

                //Arrang
                Location location = new Location {
                    City = "bxl", Number = "20", Street = "Av. Sloubie", Zipcode = "1000"
                };
                Site site = new Site {
                    Location = location, Name = "Kaamelott", Phone = "047852948"
                };
                locationRepository.Insert(location);
                siteRepository.Insert(site);
                memoryContext.SaveChanges();

                //Assert
                var testLocation = locationRepository.GetByID(location.Id);
                var testSite     = siteRepository.GetByID(site.Id);
                //siteRepository.Delete(site.Id);
                locationRepository.Delete(location.Id);
                memoryContext.SaveChanges();
                //Assert.AreEqual(siteRepository.Get().Count(),0);
                //Assert.AreEqual(locationRepository.Get().Count(), 0);
                Assert.AreEqual(locationRepository.Get().Count(), 0);
            }
        }
Example #2
0
        public void AddInGenericRepositoryTest()
        {
            var option = new DbContextOptionsBuilder <PermaContext>()
                         .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name)
                         .Options;

            using (var memoryContext = new PermaContext(option))
            {
                // Act
                GenericRepository <Member> genericRepository = new GenericRepository <Member>(memoryContext);
                //Arrang
                Member membre = new Member {
                    Email = "*****@*****.**", FirstName = "Sponge", LastName = "Bob", Password = "******"
                };
                genericRepository.Insert(membre);
                memoryContext.SaveChanges();
                //Assert
                var testMember = genericRepository.GetByID(membre.Id);
                Assert.AreEqual("Bob", testMember.LastName);
            }
        }
 public CategoriesController(PermaContext context)
 {
     _context           = context;
     categoryRepository = new GenericRepository <Category>(context);
 }
Example #4
0
 public RolesController(PermaContext context)
 {
     _context       = context;
     roleRepository = new GenericRepository <Role>(context);
 }
 public MembersController(PermaContext context)
 {
     _context         = context;
     memberRepository = new GenericRepository <Member>(context);
 }
 public StatesController(PermaContext context)
 {
     _context        = context;
     stateRepository = new GenericRepository <State>(context);
 }
 public ToDoesController(PermaContext context)
 {
     _context       = context;
     toDoRepository = new GenericRepository <ToDo>(context);
 }
Example #8
0
 public LocationsController(PermaContext context)
 {
     _context           = context;
     locationRepository = new GenericRepository <Location>(context);
 }
Example #9
0
 public PrioritiesController(PermaContext context)
 {
     _context           = context;
     priorityRepository = new GenericRepository <Priority>(context);
 }