public void Insert(clinic_service clinic_service) { _serviceList.Add(clinic_service); _clinicEntities.clinic_service.Add(clinic_service); Save(); }
public void AddServiceToBill_NoneExistsBillId_ThrowsArgumentOutOfRangeException() { clinic_service validService = new clinic_service(); int NoneExistsBillId = -1; Action act = () => _sut.AddServiceToBill(NoneExistsBillId, validService); act.Should().Throw <ArgumentOutOfRangeException>() .WithMessage("Bill Khong Ton Tai\nParameter name: billId"); }
public static ServiceVM ServiceTransform(clinic_service service) { return(new ServiceVM { Id = service.id, Name = service.service_name, Price = service.price.ToString(), Type = service.Type, MedicineUsage = service.medicine != null ? service.medicine.medicine_name : string.Empty }); }
private clinic_service GetServiceFromView() { clinic_service clinic_Service = new clinic_service() { service_name = _view.TxtServiceName, price = long.Parse(_view.TxtPrice), Type = _view.CbServiceTypes.Text, Medicine_Id = _view.SelectedMedicineId, is_active = true }; return(clinic_Service); }
public void DeleteService_ExistsId_DelelteServiceInDatabaseSuccessfully() { SetupDbSetForUsingFindMethod(); int id = 1; var serviceDeleted = new clinic_service(); _stubDbContext.Setup(c => c.clinic_service.Remove(It.IsAny <clinic_service>())) .Callback <clinic_service>(service => serviceDeleted = service); _sut.Delete(id); _stubDbContext.Verify(c => c.clinic_service.Remove(serviceDeleted), Times.Once); _stubDbContext.Verify(c => c.SaveChanges()); }
public void InsertService_WithValidService_InsertToDatabaseSuccessfully() { var newService = new clinic_service() { id = 4, service_name = "test", is_active = true, price = 10000 }; Action act = () => _sut.Insert(newService); act.Should().NotThrow(); }
public void Update(clinic_service serviceChanged) { int indexToReplace = (_serviceList).FindIndex(m => m.id == serviceChanged.id); _serviceList[indexToReplace] = serviceChanged;//replace this way for refresh list immediately var serviceFromDb = _clinicEntities.clinic_service.Find(serviceChanged.id); if (serviceFromDb != null) { _clinicEntities.Entry(serviceFromDb).CurrentValues.SetValues(serviceChanged); Save(); } }
public void InsertService_WithValidService_InsertToList() { var newService = new clinic_service() { id = 4, service_name = "test" , is_active = true, price = 10000 }; _sut.Insert(newService); _sut.GetAll().Should().Contain(newService); }
public void AddServiceToBill(int billId, clinic_service service) { bill bill = GetUnpaidBillById(billId); if (bill is null) { throw new ArgumentOutOfRangeException("billId", "Bill Khong Ton Tai"); } var serviceToAdd = _clinicEntities.clinic_service.Find(service.id); bill.clinic_service.Add(serviceToAdd); Save(); }
public void AddServiceToBill_ExistsBillIdAndValidService_NotThrowsException() { clinic_service validService = new clinic_service() { id = 1, service_name = "Thu mau", price = 50000, is_active = true }; _stubDbContext.Setup(c => c.clinic_service.Attach(validService)); int NoneExistsBillId = 1; Action act = () => _sut.AddServiceToBill(NoneExistsBillId, validService); act.Should().NotThrow(); }
public void UpdateService_WithValidService_UpdateServiceInList() { var serviceUpdated = new clinic_service() { id = 1, service_name = "test", is_active = true, price = 10000 }; _sut.Update(serviceUpdated); _sut.GetAll().Should() .Contain(serviceUpdated) .And .NotContain(_stubServiceList[0]); }
public void Add() { var service = new clinic_service() { service_name = _view.TxtServiceName, price = long.Parse(_view.TxtPrice), Type = _view.CbServiceTypes.Text, is_active = true }; if (_view.SelectedMedicineId != null) { service.Medicine_Id = _view.SelectedMedicineId; } _repository.Insert(service); }
private void DisplayServiceSelected(clinic_service serviceSelected) { _view.DgvServicesSelected.Rows.Add(serviceSelected.service_name, serviceSelected.price); }