コード例 #1
0
        public void TestAdministratorGet2()
        {
            var id = Guid.NewGuid();
            IMMRequestContext       IMMRequestContext = ContextFactory.GetNewContext();
            AdministratorRepository adminRepo         = new AdministratorRepository(IMMRequestContext);

            Administrator admin1 = new Administrator()
            {
                Id       = Guid.NewGuid(),
                Name     = "Just Testing",
                Email    = "*****@*****.**",
                Password = "******"
            };

            Administrator admin2 = new Administrator()
            {
                Id       = id,
                Name     = "Just Testing again",
                Email    = "*****@*****.**",
                Password = "******"
            };

            adminRepo.Add(admin1);
            adminRepo.Add(admin2);
            adminRepo.Save();

            Assert.AreEqual(adminRepo.Get(id), admin2);
        }
コード例 #2
0
        public void GetInvalid()
        {
            var id = Guid.NewGuid();
            IMMRequestContext       IMMRequestContext = ContextFactory.GetNewContext();
            AdministratorRepository adminRepo         = new AdministratorRepository(IMMRequestContext);

            adminRepo.Get(id);
        }
コード例 #3
0
        public void GetOneAdministrator()
        {
            var options = new DbContextOptionsBuilder <BetterCalmContext>()
                          .UseInMemoryDatabase(databaseName: "MSP.BetterCalmDatabase").Options;
            var context = new BetterCalmContext(options);

            listAdministrators.ForEach(cat => context.Add(cat));
            context.SaveChanges();
            repository = new AdministratorRepository(context);
            var category = repository.Get(listAdministrators[0].Id);

            context.Database.EnsureDeleted();
            Assert.AreEqual(listAdministrators[0].Id, category.Id);
        }
コード例 #4
0
        public void DeleteAdministrator()
        {
            var options = new DbContextOptionsBuilder <BetterCalmContext>()
                          .UseInMemoryDatabase(databaseName: "MSP.BetterCalmDatabase").Options;
            var context = new BetterCalmContext(options);

            listAdministrators.ForEach(track => context.Add(track));
            context.SaveChanges();
            repository = new AdministratorRepository(context);
            repository.Delete(listAdministrators[0]);
            context.Database.EnsureDeleted();
            Administrator getAdmin = repository.Get(1);

            Assert.AreEqual(null, getAdmin);
        }
コード例 #5
0
        public void testGet()
        {
            // Arrange
            int count = repo.All().Count();

            this.repo.Add(entity);
            this.repo.SaveChanges();


            // Act
            Administrator actual = repo.Get(x => (x.FirstName == fn &&
                                                  x.LastName == ln)).FirstOrDefault();

            // Assert

            Assert.NotNull(actual);

            this.repo.HardDelete(entity);
            this.repo.SaveChanges();
        }
コード例 #6
0
 public async Task <Administrator> Get(long id)
 {
     return(await _repository.Get(id));
 }