Esempio n. 1
0
        public async Task AllAsync_SouldReturn_CollectionWithThreeCompanies_IfThreeAreInDb()
        {
            var db     = this.GetDatabase();
            var mapper = this.GetMapper();

            var firstCompany = new Company {
                Id = 1, Name = "Свеплина", Bulstat = "903097356"
            };
            var secondCompany = new Company {
                Id = 2, Name = "Просперитет", Bulstat = "BG909087356"
            };
            var thirdCompany = new Company {
                Id = 3, Name = "Тотал Щета", Bulstat = "903099066"
            };
            await db.Companies.AddRangeAsync(firstCompany, secondCompany, thirdCompany);

            await db.SaveChangesAsync();

            var companyService = new CompaniesService(db, mapper);

            var result = await companyService.AllAsync();

            result
            .Should()
            .NotBeEmpty()
            .And
            .HaveCount(3)
            .And
            .Match(c =>
                   c.ElementAt(0).Name == "Свеплина" &&
                   c.ElementAt(1).Bulstat == "BG909087356" &&
                   c.ElementAt(2).Name == "Тотал Щета");
        }
Esempio n. 2
0
        public async Task AllAsync_SouldReturn_Null_IfNoCompaniesInDb()
        {
            var db     = this.GetDatabase();
            var mapper = this.GetMapper();

            ;
            var companyService = new CompaniesService(db, mapper);

            var result = await companyService.AllAsync();

            result
            .Should()
            .BeEmpty();
        }