Exemplo n.º 1
0
        public async Task <COAModel> GetTestData()
        {
            COAModel model = GetNewData();
            await Service.CreateAsync(model);

            return(await Service.ReadByIdAsync(model.Id));
        }
        public async Task DeleteModel(int id)
        {
            COAModel model = await ReadModelById(id);

            EntityExtension.FlagForDelete(model, IdentityService.Username, UserAgent, true);
            DbSet.Update(model);
        }
        public void Should_Success_Map_COA()
        {
            var mapper = new MapperConfiguration(configuration => configuration.AddProfile <COAProfile>()).CreateMapper();
            var model  = new COAModel();
            var vm     = mapper.Map <COAViewModel>(model);

            Assert.True(true);
        }
Exemplo n.º 4
0
        public async Task Should_Success_Create_Data()
        {
            COAService service  = new COAService(GetServiceProvider().Object, _dbContext(GetCurrentMethod()));
            COAModel   model    = _dataUtil(service).GetNewData();
            var        Response = await service.CreateAsync(model);

            Assert.NotEqual(0, Response);
        }
Exemplo n.º 5
0
        public async Task Should_Success_Get_Data_By_Id()
        {
            COAService service = new COAService(GetServiceProvider().Object, _dbContext(GetCurrentMethod()));
            COAModel   model   = await _dataUtil(service).GetTestData();

            var Response = await service.ReadByIdAsync(model.Id);

            Assert.NotNull(Response);
        }
Exemplo n.º 6
0
        public async Task <COAModel> GetTestData2()
        {
            COAModel model = GetNewData();

            model.Code  = "1111.11.1.00";
            model.Code4 = "00";
            await Service.CreateAsync(model);

            return(await Service.ReadByIdAsync(model.Id));
        }
Exemplo n.º 7
0
        public async Task Should_Success_Get_Empty_Name_Coa()
        {
            COAService service = new COAService(GetServiceProvider().Object, _dbContext(GetCurrentMethod()));
            COAModel   model   = _dataUtil(service).GetNewData();

            model.Name = null;
            await service.CreateAsync(model);

            var reportResponse = await service.GetEmptyNames();

            Assert.NotEmpty(reportResponse);
        }
Exemplo n.º 8
0
        public async Task Should_Success_Update_Data()
        {
            COAService service = new COAService(GetServiceProvider().Object, _dbContext(GetCurrentMethod()));
            COAModel   model   = await _dataUtil(service).GetTestData();

            var newModel = await service.ReadByIdAsync(model.Id);

            newModel.Name += "[Updated]";
            var Response = await service.UpdateAsync(newModel.Id, newModel);

            Assert.NotEqual(0, Response);
        }
Exemplo n.º 9
0
        public async Task Should_Success_Upload_Data()
        {
            COAService service = new COAService(GetServiceProvider().Object, _dbContext(GetCurrentMethod()));
            COAModel   model   = _dataUtil(service).GetNewData();

            List <COAModel> coa = new List <COAModel>()
            {
                model
            };

            await service.UploadData(coa);

            Assert.True(true);
        }
Exemplo n.º 10
0
        public async Task Should_Success_Revise_Empty_Name_Coa_But_Empty_List()
        {
            COAService service = new COAService(GetServiceProvider().Object, _dbContext(GetCurrentMethod()));
            COAModel   model   = _dataUtil(service).GetNewData();
            await service.CreateAsync(model);

            var createdModel = await service.ReadByIdAsync(model.Id);

            createdModel.Name = null;
            List <COAModel> models = new List <COAModel>()
            {
                createdModel
            };

            var reportResponse = await service.ReviseEmptyNamesCoa(models);

            Assert.NotEqual(0, reportResponse);
        }
Exemplo n.º 11
0
        public async Task Should_Fail_Upload_Existed_Data()
        {
            COAService   service   = new COAService(GetServiceProvider().Object, _dbContext(GetCurrentMethod()));
            COAViewModel viewModel = _dataUtil(service).GetNewViewModel();

            List <COAViewModel> coa = new List <COAViewModel>()
            {
                viewModel
            };
            COAModel model = _dataUtil(service).GetNewData();

            List <COAModel> coaModel = new List <COAModel>()
            {
                model
            };
            await service.UploadData(coaModel);

            var Response2 = service.UploadValidate(ref coa, null);

            Assert.False(Response2.Item1);
        }
 public async Task <int> CreateAsync(COAModel model)
 {
     CreateModel(model);
     return(await DbContext.SaveChangesAsync());
 }
 public void UpdateModelAsync(int id, COAModel model)
 {
     EntityExtension.FlagForUpdate(model, IdentityService.Username, UserAgent);
     DbSet.Update(model);
 }
 public void CreateModel(COAModel model)
 {
     EntityExtension.FlagForCreate(model, IdentityService.Username, UserAgent);
     DbSet.Add(model);
 }
 public async Task <int> UpdateAsync(int id, COAModel model)
 {
     UpdateModelAsync(id, model);
     return(await DbContext.SaveChangesAsync());
 }