Beispiel #1
0
        public void Test_Account_Repository_Exists_Record_Not_Exists()
        {
            //setup
            DbContextOptionsBuilder optionsBuilder = new DbContextOptionsBuilder();

            optionsBuilder.UseInMemoryDatabase("test1");
            var context = new ApplicationDbContext(optionsBuilder.Options);
            IAccountRepositoryV9 repository = new AccountRepositoryV9(context);

            //act
            bool exists = repository.Exists("testing");

            exists.Should().BeFalse();
        }
Beispiel #2
0
        public async void Test_Account_Repository_Find_Record_Not_Exists()
        {
            //setup
            DbContextOptionsBuilder optionsBuilder = new DbContextOptionsBuilder();

            optionsBuilder.UseInMemoryDatabase("test1");
            var context = new ApplicationDbContext(optionsBuilder.Options);
            IAccountRepositoryV9 repository = new AccountRepositoryV9(context);

            //act
            Account record = await repository.Find(1);

            //verify
            record.Should().BeNull();
        }
Beispiel #3
0
        public void Test_Account_Repository_Create()
        {
            //setup
            DbContextOptionsBuilder optionsBuilder = new DbContextOptionsBuilder();

            optionsBuilder.UseInMemoryDatabase("test1");
            var context = new ApplicationDbContext(optionsBuilder.Options);
            IAccountRepositoryV9 repository = new AccountRepositoryV9(context);

            //act
            repository.Create(new Account());

            //verify
            context.Accounts.Count().Should().Be(1);
        }
Beispiel #4
0
        public async void Test_Account_Repository_Find_Record_Exists()
        {
            //setup
            DbContextOptionsBuilder optionsBuilder = new DbContextOptionsBuilder();

            optionsBuilder.UseInMemoryDatabase("test1");
            var context = new ApplicationDbContext(optionsBuilder.Options);
            IAccountRepositoryV9 repository = new AccountRepositoryV9(context);

            context.Accounts.Add(new Account(1, default(string), default(string), default(DateTime), default(string)));
            context.SaveChanges();

            //act
            Account record = await repository.Find(1);

            //verify
            record.Should().NotBeNull();
        }
Beispiel #5
0
        public void Test_Account_Repository_Exists_Record_Exists()
        {
            //setup
            DbContextOptionsBuilder optionsBuilder = new DbContextOptionsBuilder();

            optionsBuilder.UseInMemoryDatabase("test1");
            var context = new ApplicationDbContext(optionsBuilder.Options);
            IAccountRepositoryV9 repository = new AccountRepositoryV9(context);

            context.Accounts.Add(new Account(default(int), "test", default(string), default(DateTime), default(string)));
            context.SaveChanges();

            //act
            bool exists = repository.Exists("test");

            //verify
            exists.Should().BeTrue();
        }