示例#1
0
        public async Task CompanyService_CompanyDetails()
        {
            AddAndEditCompanyBindingModel model = new AddAndEditCompanyBindingModel()
            {
                Id = 1, Name = "STPDelete", Description = "Some description"
            };

            dbContext.SaveChanges();

            var service = new CompanyService(dbContext, AutoMapper.Mapper.Instance);

            await service.AddCompanyAsync(model);

            Assert.IsNotNull(dbContext.Companies.FirstOrDefault(c => c.Name == "STPDelete"));
            Assert.IsNotNull(dbContext.Companies.FirstOrDefault(c => c.Description == "Some description"));

            var companyDetailsModel = await service.CompanyDetailsAsync(1);

            Assert.AreEqual(companyDetailsModel.Name, dbContext.Companies.Find(1).Name);
            Assert.AreEqual(companyDetailsModel.Description, dbContext.Companies.Find(1).Description);
        }