public void GetAccountDetailsTest()
        {
            // Arrange
            DbContextOptions <BookShopDatabaseontext> options =
                new DbContextOptionsBuilder <BookShopDatabaseontext>()
                .UseInMemoryDatabase(databaseName: "BookShopDatabase")
                .Options;

            List <AccountDetails> result = new List <AccountDetails>();

            using (BookShopDatabaseontext dbContext = new BookShopDatabaseontext(options))
            {
                dbContext.AccountDetail.Add(new AccountDetails()
                {
                    AccountId   = 6,
                    AccountName = "R&D",
                    Balance     = 500,
                });
                dbContext.AccountDetail.Add(new AccountDetails()
                {
                    AccountId   = 7,
                    AccountName = "Canteen",
                    Balance     = 500,
                });
                dbContext.SaveChanges();

                //Act
                IAccountDetailsRepository accountDetailsRepository = new AccountDetailsRepository(dbContext);
                result = accountDetailsRepository.GetAccountDetails().ToList();

                //Assert
                Assert.Equal(7, result.Count);
                dbContext.Dispose();
            }
        }
        /// <summary>
        /// Setup dependancies for controller, application service, repository.
        /// </summary>
        public AccountDetailsTest()
        {
            DbContextOptions <BookShopDatabaseontext> options =
                new DbContextOptionsBuilder <BookShopDatabaseontext>()
                .UseInMemoryDatabase(databaseName: "TestDB")
                .Options;

            BookShopDatabaseontext dbContext =
                new BookShopDatabaseontext(options);

            AccountDetailsRepository accountDetailsRepository = new AccountDetailsRepository(dbContext);

            AccountDetailsApplicationService accountDetailsApplicationService =
                new AccountDetailsApplicationService(accountDetailsRepository);

            accountDetailsController = new AccountDetailsController(accountDetailsApplicationService);
        }
Exemple #3
0
 public AccountDetailsRepository(BookShopDatabaseontext _BookShopDatabaseontext)
 {
     this._BookShopDatabaseontext = _BookShopDatabaseontext;
 }