public void AddMethodShouldAddBank()
        {
            var dbContext = YourMoney.Tests.Base.BaseServiceTests.GetDatabase();

            var item = new Bank()
            {
                Name = "ProCredit"
            };

            var items = new BanksService(dbContext);

            items.Add(item.Name);
            var result = dbContext.Banks.Count();


            Assert.AreEqual(1, result);
        }
        public void EditMethodShouldEditBank()
        {
            var dbContext = YourMoney.Tests.Base.BaseServiceTests.GetDatabase();

            var item = new Bank()
            {
                Id   = 1,
                Name = "ProCredit"
            };
            var items = new BanksService(dbContext);

            items.Add(item.Name);
            items.Edit(item.Id, "DSK");

            var result = dbContext.Banks.FirstOrDefault(x => x.Name == "DSK");

            Assert.AreEqual("DSK", result.Name);
        }
Пример #3
0
        public void RemoveMethodShouldRemoveBank()
        {
            var dbContext = YourMoney.Tests.Base.BaseServiceTests.GetDatabase();

            var item = new Bank()
            {
                Id   = 1,
                Name = "ProCredit"
            };
            var items = new BanksService(dbContext);

            items.Add(item.Name);

            items.Remove(item.Id);

            var result = dbContext.Banks.FirstOrDefault();

            Assert.Null(result);
        }
Пример #4
0
        public void AddMethodShouldAddBank()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "AddBank_Banks_DB")
                          .Options;

            var dbContext = new ApplicationDbContext(options);

            var item = new Bank()
            {
                Name = "ProCredit"
            };

            var items = new BanksService(dbContext);

            items.Add(item.Name);
            var result = dbContext.Banks.Count();


            Assert.AreEqual(1, result);
        }
Пример #5
0
        public void ExistByIdMethodShouldCheckIfThereIsBankWithThatId()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "AddBank_Banks_DB")
                          .Options;

            var dbContext = new ApplicationDbContext(options);

            var bank = new Bank()
            {
                Id   = 1,
                Name = "ProCredit"
            };

            var banksService = new BanksService(dbContext);

            banksService.Add(bank.Name);

            var result = banksService.ExistsById(bank.Id);

            Assert.True(result);
        }
Пример #6
0
        public void RemoveMethodShouldRemoveBank()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "AddBank_Banks_DB")
                          .Options;
            var dbContext = new ApplicationDbContext(options);

            var item = new Bank()
            {
                Id   = 1,
                Name = "ProCredit"
            };
            var items = new BanksService(dbContext);

            items.Add(item.Name);

            items.Remove(item.Id);

            var result = dbContext.Banks.FirstOrDefault(b => b.Id == item.Id);

            Assert.Null(result);
        }
Пример #7
0
        public void EditMethodShouldEditBank()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "AddBank_Banks_DB")
                          .Options;

            var dbContext = new ApplicationDbContext(options);

            var item = new Bank()
            {
                Id   = 1,
                Name = "ProCredit"
            };

            var items = new BanksService(dbContext);

            items.Add(item.Name);
            items.Edit(item.Id, "DSK");

            var result = dbContext.Banks.FirstOrDefault(x => x.Name == "DSK");

            Assert.AreEqual("DSK", result.Name);
        }