Esempio n. 1
0
        private void OperationButtons_OnSaveButtonClick(object sender, EventArgs e)
        {
            var model = new SubTipeModel
            {
                nama       = textBoxNama.Text,
                keterangan = textBoxKeterangan.Text
            };

            var modelArgs = new ModelEventArgs <SubTipeModel>(model);

            if (_isNewData)
            {
                if (Messages.ConfirmSave(_typeName))
                {
                    OnSaveData?.Invoke(this, modelArgs);
                }
            }
            else if (Messages.ConfirmUpdate(_typeName))
            {
                model.id = _model.id;
                OnSaveData?.Invoke(this, modelArgs);
            }
        }
Esempio n. 2
0
        private void ShouldReturnErrorDuplicateInsert()
        {
            var dataAccessJsonStr = string.Empty;
            var formattedJsonStr  = string.Empty;

            try
            {
                var model = new SubTipeModel()
                {
                    nama = "Sub tipe #2",
                };

                _services.Insert(model);
            }
            catch (DataAccessException ex)
            {
                dataAccessJsonStr = JsonConvert.SerializeObject(ex.DataAccessStatusInfo);
                formattedJsonStr  = JToken.Parse(dataAccessJsonStr).ToString();
            }
            finally
            {
                _testOutputHelper.WriteLine(formattedJsonStr);
            }
        }
Esempio n. 3
0
        private void ShouldReturnSuccessForInsert()
        {
            var operationSecceded = false;
            var formattedJsonStr  = string.Empty;

            try
            {
                for (int i = 1; i <= 10; i++)
                {
                    var model = new SubTipeModel()
                    {
                        nama       = $"Sub tipe #{i}",
                        keterangan = $"Keterangan Sub tipe #{i}"
                    };

                    _services.Insert(model);
                }

                operationSecceded = true;
            }
            catch (DataAccessException ex)
            {
                operationSecceded = false;
                formattedJsonStr  = TestsHelper.DataAccessStatusInfoToJson(ex);
            }

            try
            {
                Assert.True(operationSecceded);
                _testOutputHelper.WriteLine("Data berhasil ditambahkan.");
            }
            finally
            {
                _testOutputHelper.WriteLine(formattedJsonStr);
            }
        }
Esempio n. 4
0
 public SubTipeServicesFixture()
 {
     Model    = new SubTipeModel();
     Services = new SubTipeServices(null, new ModelDataAnnotationCheck());
 }