コード例 #1
0
        public void ExistsShouldReturnFalseWhenEntityWithTheGivenIdIsNotPresentedInDatabase()
        {
            ApplicationDbContext dbContext = this.GetNewDbContext();

            var creditCompanyRepository = new EfRepository <CreditCompany>(dbContext);

            ICreditCompanyService creditCompanyService = new CreditCompanyService(creditCompanyRepository);

            Assert.False(creditCompanyService.Exists(Guid.NewGuid().ToString()));
        }
コード例 #2
0
        public async Task ExistsShouldReturnTrueWhenEntityWithTheGivenIdIsPresentedInDatabase()
        {
            const string id   = "123";
            const string name = "name";

            ApplicationDbContext dbContext = this.GetNewDbContext();

            dbContext.CreditCompanies.Add(new CreditCompany
            {
                Id   = id,
                Name = name,
            });

            await dbContext.SaveChangesAsync();

            var creditCompanyRepository = new EfRepository <CreditCompany>(dbContext);

            ICreditCompanyService creditCompanyService = new CreditCompanyService(creditCompanyRepository);

            Assert.True(creditCompanyService.Exists(id));
        }