public static void Test() { try { //EventRecallService init = new EventRecallService(); Console.WriteLine("Creating sample data..."); Pharmacy pharm = new Pharmacy(2, "test2", "test3", "test4"); using (var service = new PharmacyService()) { service.Update(pharm); } MessageTemplate temp = new MessageTemplate(pharm, MessageTemplateType.RECALL, MessageTemplateMedia.EMAIL, "this is a test"); using (var service = new MessageTemplateService()) { service.Update(temp); } Drug drug = new Drug(7, "Omeprazole Cap Delayed Release 20 MG"); using (var service = new DrugService()) { service.Update(drug); } Console.WriteLine("Samples created successfully.\nUploading patients..."); //init.SendRecalls(@"..\..\App_Data\RecallCSVTest.csv", pharm, temp, drug); Console.WriteLine("Patients uploaded successfully.\nAll tests successful..."); } catch (Exception ex) { Console.WriteLine(ex); Console.ReadKey(); } }
public List <DrugDTO> GetMedicineInObject() { DrugService drugService = new DrugService(); List <DrugDTO> medicinetInObject = drugService.GetDrugsByRoomNumber((int)MapObjectEntity.Id); return(medicinetInObject); }
public void Moq_GetTheDrugs() { // Arrange var mockDataAccess = new Mock <IDataAccess>(); mockDataAccess.Setup(da => da.GetAllTheDrugs()).Returns(_fakeDrugList); var mockThirdPartyAccess = new Mock <IThirdPartyDataAccess>(MockBehavior.Strict); mockThirdPartyAccess.SetupSequence(tpa => tpa.GetThirdPartyDrugInfo(It.IsAny <Drug>())) .Returns(FakeThirdPartyInfo1) .Returns(FakeThirdPartyInfo2) .Returns(FakeThirdPartyInfo3); var drugService = new DrugService(mockDataAccess.Object, mockThirdPartyAccess.Object); // Act var actualDrugs = drugService.GetTheDrugs(); // Assert actualDrugs.Count().ShouldBe(3); mockDataAccess.Verify(da => da.GetAllTheDrugs(), Times.Once); mockThirdPartyAccess.Verify(da => da.GetThirdPartyDrugInfo(It.IsAny <Drug>()), Times.Exactly(3)); }
public async Task GetDrugsTest() { var drugs = new List <Drug> { new Drug() { Name = "Korvalol", Type = "For heart", Description = "heart for designed medicine" }, new Drug() { Name = "Korvalol", Type = "For heart", Description = "heart for designed medicine" }, }; var fakeRepositoryMock = new Mock <IDrugRepository>(); fakeRepositoryMock.Setup(x => x.GetDrugs()).ReturnsAsync(drugs); var drugService = new DrugService(fakeRepositoryMock.Object); var resultDrugs = await drugService.GetDrugs(); Assert.Collection(resultDrugs, drug => { Assert.Equal("Korvalol", drug.Name); }, drug => { Assert.Equal("For heart", drug.Type); }); }
public async Task SearchTest() { var movies = new List <Drug> { new Drug() { Name = "Korvalol", Type = "For heart", Description = "heart for designed medicine" }, new Drug() { Name = "Korvalol", Type = "For heart", Description = "heart for designed medicine" }, }; var fakeRepositoryMock = new Mock <IDrugRepository>(); fakeRepositoryMock.Setup(x => x.GetDrugWithPredicate(It.IsAny <Expression <Func <Drug, bool> > >())).ReturnsAsync(movies); var drugService = new DrugService(fakeRepositoryMock.Object); var resultDrugs = await drugService.Search("Dias"); Assert.Collection(resultDrugs, drug => { Assert.Equal("Korvalol", drug.Name); }, drug => { Assert.Equal("For heart", drug.Type); }); }
public AdverseEffectWindow(PharmacyUser user) { InitializeComponent(); _user = user; _service = ServiceProvider.GetDrugService(); }
public SearchDrugWindow(PharmacyUser user) { InitializeComponent(); _user = user; _service = ServiceProvider.GetDrugService(); }
public DrugPageViewModel( INavigationService navigationService, DrugService drugService) : base(navigationService) { _drugService = drugService; RemoveCommand = new DelegateCommand <Drug>(OnRemoveCommand); }
protected void RestockButton_Command(object sender, CommandEventArgs e) { if (!Page.IsValid) { return; } DrugService.Restock(GetPzn(), GetQuantity(), GetDateOfAction()); UpdateData(); }
public async Task GetByIdAsync_ThrowsArgumentException(int id) { // Arrange this.mockUnitOfWork.Setup(u => u.Drugs.GetAsync(id)).ReturnsAsync(default(Drug)); this.service = new DrugService(this.mockUnitOfWork.Object); // Act Drug actual = await this.service.GetByIdAsync(id); }
public async Task GetAllByNameAsync_ThrowsNoContentException(string name) { // Arrange this.mockUnitOfWork.Setup(u => u.Drugs.GetAllAsync(It.IsAny <Expression <Func <Drug, bool> > >())) .ReturnsAsync(this.drugsList.Where(d => d.IsDeleted == false && d.Name.StartsWith(name)).AsQueryable()); this.service = new DrugService(this.mockUnitOfWork.Object); // Act IEnumerable <Drug> actual = await this.service.GetAllByNameAsync(name); }
public DrugWindow(PharmacyUser user) { InitializeComponent(); _user = user; _drugService = ServiceProvider.GetDrugService(); this.drugsGrid.CanUserDeleteRows = false; this.drugsGrid.CanUserAddRows = false; }
public TakePillPageViewModel( INavigationService navigationService, DrugService drugService) : base(navigationService) { Title = "Take Pill"; _drugService = drugService; DrugList = _drugService.Drugs; TakePillCommand = new DelegateCommand <Drug>(OnTakePillCommand); }
private static void ValidateDrugExists(Int32 pzn) { try { DrugService.GetDrug(pzn); } catch { throw new WebFaultException(System.Net.HttpStatusCode.NotFound); } }
public async Task DeleteTest() { var fakeRepository = Mock.Of <IDrugRepository>(); var drugService = new DrugService(fakeRepository); var drug = new Drug() { Name = "Korvalol", Type = "For heart", Description = "heart for designed medicine" }; await drugService.Delete(drug); }
public void GetByIdAsync_ReturnsDrugCorrectly(int id) { // Arrange this.mockUnitOfWork.Setup(u => u.Drugs.GetAsync(id)).ReturnsAsync(this.drugsList[id - 1]); this.service = new DrugService(this.mockUnitOfWork.Object); // Act Drug actual = this.service.GetByIdAsync(id).Result; // Assert Assert.AreEqual(this.drugsList[id - 1], actual); }
private void UpdateSuggestion() { if (DrugService.RequiresReplenishment(GetPzn())) { SuggestionLabel.Visible = true; int replenishmentSuggestion = DrugService.GetReplenishmentSuggestion(GetPzn()); SuggestionLabel.Text = String.Format("Requires replenishment of {0} items", replenishmentSuggestion); } else { SuggestionLabel.Visible = false; } }
public MainPageViewModel( INavigationService navigationService, DrugService drugService, IDialogService dialogService) : base(navigationService) { Title = "Medicine Overview"; NavigateToCommand = new DelegateCommand <string>(OnNavigationToCommand); NavigateToDrugCommand = new DelegateCommand <Drug>(OnNavigationToCommand); _drugService = drugService; _dialogService = dialogService; _Drugs = new List <Drug>(); }
public void DrugExistsTest() { int UserId = 1; var fakeRepositoryMock = new Mock <IDrugRepository>(); fakeRepositoryMock.Setup(x => x.DrugExists(UserId)).Returns(true); var drugService = new DrugService(fakeRepositoryMock.Object); var isExist = drugService.DrugExists(UserId); Assert.True(isExist); }
public AddMedicinePageViewModel( INavigationService navigationService, DrugService drugService, DrugInteractionService drugInteractionService, IDialogService dialogService, IPageDialogService pageDialogService) : base(navigationService) { _drugInteractionService = drugInteractionService; _dialogService = dialogService; _pageDialogService = pageDialogService; Title = "Add Medicine"; DrugService = drugService; AddMedicineCommand = new DelegateCommand(OnAddMedicineCommand); }
public App() { var doctorRepository = new DoctorRepository(); var drugRepository = new DrugRepository(); var managerRepository = new ManagerRepository(); var medicalExamRepository = new MedicalExamRepository(); var medicalRecordRepository = new MedicalRecordRepository(); var medicalSupplyRepository = new MedicalSupplyRepository(); var notificationRepository = new NotificationRepository(); var patientRepository = new PatientRepository(); var reportRepository = new ReportRepository(); var resourceRepository = new ResourceRepository(); var roomRepository = new RoomRepository(); var secretaryRepository = new SecretaryRepository(); var textContentRepository = new TextContentRepository(); var renovationRepository = new RenovationRepository(); var guestUserRepository = new GuestUserRepository(); var notificationService = new NotificationService(notificationRepository); var doctorService = new DoctorService(doctorRepository, notificationService); var doctorReviewService = new DoctorReviewService(medicalExamRepository); var drugService = new DrugService(drugRepository, doctorService); var employeeService = new EmployeeService(managerRepository, doctorService, secretaryRepository); var guestUserService = new GuestUserService(guestUserRepository); var medicalExamService = new MedicalExamService(medicalExamRepository); var medicalSupplyService = new MedicalSupplyService(medicalSupplyRepository); var patientService = new PatientService(patientRepository); var reportService = new ReportService(reportRepository, managerRepository); var resourceService = new ResourceService(resourceRepository); var roomService = new RoomService(roomRepository, renovationRepository, medicalExamService, patientService, resourceService); var userService = new UserService(employeeService, patientService); var textContentService = new TextContentService(textContentRepository); TextContentController = new TextContentController(textContentService); NotificationController = new NotificationController(notificationService); DoctorController = new DoctorController(doctorService); DoctorReviewController = new DoctorReviewController(doctorReviewService); DrugController = new DrugController(drugService); EmployeeController = new EmployeeController(employeeService); GuestUserController = new GuestUserController(guestUserService); MedicalExamController = new MedicalExamController(medicalExamService); MedicalSupplyController = new MedicalSupplyController(medicalSupplyService); PatientController = new PatientController(patientService); ReportController = new ReportController(reportService); ResourceController = new ResourceController(resourceService); RoomController = new RoomController(roomService); UserController = new UserController(userService); }
public void NSubstitute_onDrugRetrieved_WhenEventRaised_HaveDrugsBeenReceivedIsSet() { // Arrange var mockDataAccess = Substitute.For <IDataAccess>(); var mockThirdPartyAccess = Substitute.For <IThirdPartyDataAccess>(); var drugService = new DrugService(mockDataAccess, mockThirdPartyAccess); drugService.HaveDrugsBeenReceived.ShouldBeFalse(); // Act // Assert mockThirdPartyAccess.OnDrugsRetrievedEvent += Raise.Event <EventHandler <DrugsRetrievedArgs> >(mockThirdPartyAccess, new DrugsRetrievedArgs { HaveDrugsBeenRetrieved = true }); drugService.HaveDrugsBeenReceived.ShouldBeTrue(); }
public void Moq_onDrugRetrieved_WhenEventRaised_HaveDrugsBeenReceivedIsSet() { // Arrange var mockDataAccess = new Mock <IDataAccess>(); var mockThirdPartyAccess = new Mock <IThirdPartyDataAccess>(MockBehavior.Strict); var drugService = new DrugService(mockDataAccess.Object, mockThirdPartyAccess.Object); drugService.HaveDrugsBeenReceived.ShouldBeFalse(); // Act // Assert mockThirdPartyAccess.Raise(tpa => tpa.OnDrugsRetrievedEvent += null, mockThirdPartyAccess.Object, new DrugsRetrievedArgs { HaveDrugsBeenRetrieved = true }); drugService.HaveDrugsBeenReceived.ShouldBeTrue(); }
public void NSubstitute_Exception() { // Arrange var mockDataAccess = Substitute.For <IDataAccess>(); mockDataAccess.GetSpecificDrugs(Arg.Any <List <int> >()).Throws <ArgumentException>(); var mockThirdPartyAccess = Substitute.For <IThirdPartyDataAccess>(); var drugService = new DrugService(mockDataAccess, mockThirdPartyAccess); // Act Action getSpecificDrugs = () => drugService.GetSpecificDrugs(Arg.Any <List <int> >()); // Assert getSpecificDrugs.ShouldThrow <ArgumentException>(); }
public void Moq_Exception() { // Arrange var mockDataAccess = new Mock <IDataAccess>(); mockDataAccess.Setup(da => da.GetSpecificDrugs(It.IsAny <IEnumerable <int> >())).Throws <ArgumentException>(); var mockThirdPartyAccess = new Mock <IThirdPartyDataAccess>(MockBehavior.Strict); var drugService = new DrugService(mockDataAccess.Object, mockThirdPartyAccess.Object); // Act Action getSpecificDrugs = () => drugService.GetSpecificDrugs(It.IsAny <IEnumerable <int> >()); // Assert getSpecificDrugs.ShouldThrow <ArgumentException>(); }
public void Rhino_Exception() { // Arrange var mockDataAccess = MockRepository.GenerateMock <IDataAccess>(); mockDataAccess.Stub(da => da.GetSpecificDrugs(Arg <List <int> > .Is.Anything)).Throw(new ArgumentException()); var mockThirdPartyAccess = MockRepository.GenerateMock <IThirdPartyDataAccess>(); var drugService = new DrugService(mockDataAccess, mockThirdPartyAccess); // Act Action getSpecificDrugs = () => drugService.GetSpecificDrugs(Arg <List <int> > .Is.Anything); // Assert getSpecificDrugs.ShouldThrow <ArgumentException>(); }
public void Rhino_onDrugRetrieved_WhenEventRaised_HaveDrugsBeenReceivedIsSet() { // Arrange var mockDataAccess = MockRepository.GenerateMock <IDataAccess>(); var mockThirdPartyAccess = MockRepository.GenerateMock <IThirdPartyDataAccess>(); var drugService = new DrugService(mockDataAccess, mockThirdPartyAccess); drugService.HaveDrugsBeenReceived.ShouldBeFalse(); // Act // Assert mockThirdPartyAccess.Raise(tpa => tpa.OnDrugsRetrievedEvent += null, mockThirdPartyAccess, new DrugsRetrievedArgs { HaveDrugsBeenRetrieved = true }); drugService.HaveDrugsBeenReceived.ShouldBeTrue(); }
protected async void OnAddMedicineCommand() { try { IsOnAddMedicineCommandProcessing = true; StopRefreshDrugSuggestion(); Warnings = await GetWarningsAsync(); if (CanAddMedicine) { DrugService.AddDrug(SelectedDrug); #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed NavigationService.NavigateAsync(nameof(MainPageViewModel)); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed } else { var parameters = new DialogParameters { { "Warnings", Warnings }, }; Action <IDialogResult> action = (a) => { var u = a.Parameters.GetValue <bool>("Result"); if (u) { DrugService.AddDrug(SelectedDrug); } #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed NavigationService.NavigateAsync(nameof(MainPageViewModel)); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed }; _dialogService.ShowDialog(nameof(DDIWarningViewViewModel), parameters, action); } } catch (Exception e) { _dialogService.ShowDialog(e.ToString()); } finally { IsOnAddMedicineCommandProcessing = false; } }
public async Task GetAllByNameAsync_ReturnsAllFoundDrugsCorrectly(string name, int expected) { // Arrange this.mockUnitOfWork.Setup(u => u.Drugs.GetAllAsync(It.IsAny <Expression <Func <Drug, bool> > >())) .ReturnsAsync(this.drugsList.Where(d => d.IsDeleted == false && d.Name.ToLower().StartsWith(name.ToLower())).AsQueryable()); this.service = new DrugService(this.mockUnitOfWork.Object); // Amount of actual matches. int actual = 0; // Act IEnumerable <Drug> drugs = await this.service.GetAllByNameAsync(name); actual = drugs.Count(); // Assert Assert.AreEqual(expected, actual); }
private void SearchEquimentAndMedicineButton_Click(object sender, RoutedEventArgs e) { String equipmentOrMedicineNameUserInput = EquipmentOrMedicineNameTextBox.Text.Trim().ToLower(); if (String.IsNullOrEmpty(equipmentOrMedicineNameUserInput)) { return; } EquipmentService equipmentService = new EquipmentService(); DrugService drugService = new DrugService(); List <EquipmentWithRoomDTO> searchResultEquipment = equipmentService.GetEquipmentWithRoomForSearchTerm(equipmentOrMedicineNameUserInput); List <DrugWithRoomDTO> searchResultDrugs = drugService.GetDrugsWithRoomForSearchTerm(equipmentOrMedicineNameUserInput); EquipmentSearchResultsDataGrid.ItemsSource = searchResultEquipment; MedicineSearchResultsDataGrid.ItemsSource = searchResultDrugs; }