Пример #1
0
        public async Task CreateCompany_AlreadExists()
        {
            //Arrange
            UnityOfWorkContract    unityOfWork    = new ResolveMock().Resolve();
            CompanyServiceContract companyService = new CompanyService(unityOfWork);
            CompanyAppContract     _companyApp    = new CompanyApp(unityOfWork, companyService);

            Company company = new Company("68522679000112", "Company Name", null);

            //Act
            company = await _companyApp.Create(company);

            //Assert
            Assert.AreEqual(true, company.EventNotification.Warnings.Select(x => x.ToString()).Contains("Empresa já Cadastrada."));
        }
Пример #2
0
        public async Task CreateCompany_CNPJ_Wrong()
        {
            //Arrange
            UnityOfWorkContract    unityOfWork    = new ResolveMock().Resolve();
            CompanyServiceContract companyService = new CompanyService(unityOfWork);
            CompanyAppContract     _companyApp    = new CompanyApp(unityOfWork, companyService);

            Company company = new Company("10793548000191", "Company Name", State.Acre);

            //Act
            company = await _companyApp.Create(company);

            //Assert
            Assert.AreEqual(true, company.EventNotification.Warnings.Select(x => x.ToString()).Contains("CNPJ Inválido."));
        }
Пример #3
0
        public async Task CreateCompany_StateEmpty()
        {
            //Arrange
            UnityOfWorkContract    unityOfWork    = new ResolveMock().Resolve();
            CompanyServiceContract companyService = new CompanyService(unityOfWork);
            CompanyAppContract     _companyApp    = new CompanyApp(unityOfWork, companyService);

            Company company = new Company("10793548000190", "Company Name", null);

            //Act
            company = await _companyApp.Create(company);

            //Assert
            Assert.AreEqual(true, company.EventNotification.Warnings.Select(x => x.ToString()).Contains("Estado é obrigatório."));
        }
Пример #4
0
        public async Task UpdateCompany_NotFound()
        {
            //Arrange
            UnityOfWorkContract    unityOfWork    = new ResolveMock().Resolve();
            CompanyServiceContract companyService = new CompanyService(unityOfWork);
            CompanyAppContract     _companyApp    = new CompanyApp(unityOfWork, companyService);

            Company company = new Company("10793548000190", "Company Name alt", State.Acre);

            //Act
            company = await _companyApp.Update(company);

            //Assert
            Assert.AreEqual(true, company.EventNotification.Warnings.Select(x => x.ToString()).Contains("Empresa não encontrada."));
        }
Пример #5
0
        public async Task DeleteCompany_CNPJ_Required()
        {
            //Arrange
            UnityOfWorkContract    unityOfWork    = new ResolveMock().Resolve();
            CompanyServiceContract companyService = new CompanyService(unityOfWork);
            CompanyAppContract     _companyApp    = new CompanyApp(unityOfWork, companyService);

            Company company = new Company("", "", null);

            //Act
            company = await _companyApp.Delete(company);

            //Assert
            Assert.AreEqual(true, company.EventNotification.Warnings.Select(x => x.ToString()).Contains("CNPJ da Empresa é obrigatório."));
        }
Пример #6
0
        public async Task DeleteCompany()
        {
            //Arrange
            UnityOfWorkContract    unityOfWork    = new ResolveMock().Resolve();
            CompanyServiceContract companyService = new CompanyService(unityOfWork);
            CompanyAppContract     _companyApp    = new CompanyApp(unityOfWork, companyService);

            Company company = new Company("68522679000112", "", null);

            //Act
            company = await _companyApp.Delete(company);

            CompanyList itens = await _companyApp.Get();

            //Assert
            Assert.AreEqual(3, itens.Itens.Count);
        }
Пример #7
0
        public async Task CreateCompany()
        {
            //Arrange
            UnityOfWorkContract    unityOfWork    = new ResolveMock().Resolve();
            CompanyServiceContract companyService = new CompanyService(unityOfWork);
            CompanyAppContract     _companyApp    = new CompanyApp(unityOfWork, companyService);

            Company company = new Company("10793548000190", "Company Name", State.Acre);

            //Act
            company = await _companyApp.Create(company);

            CompanyList itens = await _companyApp.Get();

            //Assert
            Assert.AreEqual(true, company.IsValid());
            Assert.AreEqual(5, itens.Itens.Count);
        }
Пример #8
0
        public async Task UpdateCompany()
        {
            string newName  = "Company Name alt";
            State  newState = State.SantaCatarina;
            //Arrange
            UnityOfWorkContract    unityOfWork    = new ResolveMock().Resolve();
            CompanyServiceContract companyService = new CompanyService(unityOfWork);
            CompanyAppContract     _companyApp    = new CompanyApp(unityOfWork, companyService);

            Company company = new Company("68522679000112", newName, newState);

            //Act
            company = await _companyApp.Update(company);

            Company companyUpdated = await _companyApp.Get(company.CNPJ);

            //Assert
            Assert.AreEqual(true, companyUpdated.CompanyName == newName && companyUpdated.State == newState);
        }