public void CreatePermohonan_expected_Null_actual_Null() { var t = new layanan { Id = 1, IdKategoriLayanan = 1 }; var itemPermohonan = new permohonan { IdLayanan = t.Id, IdPemohon = 1, Status = AppCore.StatusPermohonan.Baru }; A.CallTo(() => (unitWork.InsertNewPermohonan(itemPermohonan, t))).WithAnyArguments().Returns(null); Assert.Throws <ArgumentNullException>(() => service.CreatePermohonan(t)); }
public void CreateTestValidate() { //TestParameter Layanan IsNull, expected ThrowArgumentNull , actual ThrowargumenNull IPermohonanService newservice = new PermohonanService(new pemohon { Id = 1 }, unitWork); Assert.Throws <ArgumentNullException>(() => newservice.CreatePermohonan(null)); //TestParameter Pemohon IsNull , expected ThrowArgumentNull, actual ThrowargumentNull newservice = new PermohonanService(null, unitWork); Assert.Throws <ArgumentNullException>(() => newservice.CreatePermohonan(new layanan())); }
public IActionResult Post([FromBody] permohonan value) { try { var id = UserManagers.GetUserId(User); var client = new ClientService(id); if (client.Pemohon == null) { throw new SystemException("Maaf Anda Belum Terdaftar"); } var service = new PermohonanService(client.Pemohon, new UOWPermohonan()); var result = service.CreatePermohonan(new layanan { Id = value.IdLayanan }); return(Ok(result)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }