public async Task PostCompanyInfoAsyncTest()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString());

            var repository = new EfDeletableEntityRepository <CompanyInfo>(new ApplicationDbContext(options.Options));

            foreach (var item in this.GetCompanyInfoData())
            {
                await repository.AddAsync(item);

                await repository.SaveChangesAsync();
            }

            var service = new CompanyInfoService(repository);

            var fileMockCv = new Mock <IFormFile>();

            var content  = "Hello World from a Fake File";
            var fileName = "test.pdf";
            var ms       = new MemoryStream();
            var writer   = new StreamWriter(ms);

            writer.Write(content);
            writer.Flush();
            ms.Position = 0;
            fileMockCv.Setup(_ => _.OpenReadStream()).Returns(ms);
            fileMockCv.Setup(_ => _.FileName).Returns(fileName);
            fileMockCv.Setup(_ => _.Length).Returns(ms.Length);

            WebClient client = new WebClient();
            var       stream = client.OpenRead("https://ichef.bbci.co.uk/news/976/cpsprodpb/41CF/production/_109474861_angrycat-index-getty3-3.jpg");

            var fileMockImage = new Mock <IFormFile>();

            fileMockImage.Setup(_ => _.OpenReadStream()).Returns(stream);
            fileMockImage.Setup(_ => _.FileName).Returns("cat.jpg");

            var inputModel = new CompanyInfoInputModel
            {
                UserId      = "6",
                Name        = "Andrea",
                Description = "bgscdsu",
                Logo        = fileMockImage.Object,
                Address     = "bcsuigvfdgvdfcdz",
                PhoneNumber = "0888130130",
            };

            await service.PostCompanyInfoAsync(inputModel);

            var candidatesCount = repository.All().ToList().Count;

            Assert.Equal(4, candidatesCount);
        }
        public void CheckIfHasInformationTest()
        {
            var mockRepository = new Mock <IDeletableEntityRepository <CompanyInfo> >();

            mockRepository.Setup(x => x.All()).Returns(this.GetCompanyInfoData());

            var service = new CompanyInfoService(mockRepository.Object);

            var check = service.CheckIfHasInformation("1");

            Assert.True(check);
        }
        public void GetCompanyInfoIdTest()
        {
            var mockRepository = new Mock <IDeletableEntityRepository <CompanyInfo> >();

            mockRepository.Setup(x => x.All()).Returns(this.GetCompanyInfoData());

            var service = new CompanyInfoService(mockRepository.Object);

            var check = service.GetCompanyInfoId("1");

            Assert.Equal("11", check);
        }
        public async Task MarkCompanyInfoAsDeletedTest()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString());

            var repository = new EfDeletableEntityRepository <CompanyInfo>(new ApplicationDbContext(options.Options));

            foreach (var item in this.GetCompanyInfoData())
            {
                await repository.AddAsync(item);

                await repository.SaveChangesAsync();
            }

            var service = new CompanyInfoService(repository);

            await service.MarkCompanyInfoAsDeleted("1");

            var user = repository.AllWithDeleted().Where(x => x.UserId == "1").FirstOrDefault();

            Assert.True(user.IsDeleted);
        }
Ejemplo n.º 5
0
 public ChangeProfileDataViewModel(Company company)
 {
     _company            = company;
     _companyInfoService = new CompanyInfoService(_company);
 }
Ejemplo n.º 6
0
 public ChangePasswordViewModel(Company company)
 {
     _company            = company;
     _companyInfoService = new CompanyInfoService(_company);
 }
Ejemplo n.º 7
0
 public ProducerHomeViewModel(Company company)
 {
     _company            = company;
     _companyInfoService = new CompanyInfoService(_company);
     GetCustomerData();
 }
        public ActionResult Delete(string key)
        {
            bool result = CompanyInfoService.DeleteCompanyInfo(key);

            return(Json(result.ToString().ToLower()));
        }
        public ActionResult Save(string key, string content)
        {
            bool result = CompanyInfoService.SaveCompanyInfo(key, content);

            return(Json(result.ToString().ToLower()));
        }
 public ActionResult Index()
 {
     ViewBag.Company = CompanyInfoService.LoadCompanyInfo();
     return(View("Index"));
 }