public void WhenFirstRun_LoadAppointmentsAndShowSettingsWithDataFromFirstAppointment() { // Arrange var appService = new ServerAppService(_repositoryMock.Object, _apiMock.Object, _dentalApiFactoryServiceMock.Object, _clientCallbackServiceMock.Object); // Act DispatcherHelper.WaitWithDispatcher(1000); // Assert AssertLoadingIndicator(); _dialogServiceMock.Verify(m => m.Show(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()), Times.Never, "Shouldn't have popup messages"); _apiMock.Verify(m => m.RegisterPlugin(It.IsAny <RegisterPluginRequest>()), Times.Never, "Shouldn't register plugin"); Assert.AreEqual(ServerState.Ready, appService.GetState()); _dentalApiMock.Verify(m => m.GetAppointmentsForToday(), Times.Once); _apiMock.Verify(m => m.Initialize(It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <string>()), Times.Never, "Should not initialize Chewsi API"); AssertClaims(appService.GetClaims(true), _appointmentsPms); _settingsViewModelMock.Verify(m => m.InjectAppServiceAndInit(It.IsAny <IClientAppService>(), It.IsAny <SettingsDto>()), Times.Once, "Should fill settings with values from appointment"); _settingsViewModelMock.Verify(m => m.Show(It.IsAny <Action>()), Times.Once, "Should show settings popup"); }
public void WhenNotFirstRun_ShouldDisplayAppointmentsOnlyFromPms() { // Arrange // Act var appService = new ServerAppService(_repositoryMock.Object, _apiMock.Object, _dentalApiFactoryServiceMock.Object, _clientCallbackServiceMock.Object); DispatcherHelper.WaitWithDispatcher(1000); // Assert AssertLoadingIndicator(); _dialogServiceMock.Verify(m => m.Show(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()), Times.Never, "Shouldn't have popup messages"); _apiMock.Verify(m => m.RegisterPlugin(It.IsAny <RegisterPluginRequest>()), Times.Never, "Shouldn't register plugin"); Assert.AreEqual(ServerState.Ready, appService.GetState()); _dentalApiMock.Verify(m => m.GetAppointmentsForToday(), Times.Once); _apiMock.Verify(m => m.Initialize(It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <string>()), Times.Once, "Should initialize Chewsi API"); _apiMock.Verify(m => m.GetClaimProcessingStatus(It.IsAny <ClaimProcessingStatusRequest>()), Times.Never, "Should not load claim statuses from Chewsi API"); AssertClaims(appService.GetClaims(true), _appointmentsPms); _settingsViewModelMock.Verify(m => m.InjectAppServiceAndInit(It.IsAny <IClientAppService>(), It.IsAny <SettingsDto>()), Times.Never, "Should not touch settings model"); _settingsViewModelMock.Verify(m => m.Show(It.IsAny <Action>()), Times.Never, "Should not show settings popup"); }
public void WhenNotFirstRunAndSomeAppointmentsWereSubmittedBefore_ShouldDisplayAppointmentsFromPmsAndService() { // Arrange var statusResponse = new ClaimProcessingStatusResponse(); var submittedClaims = TestDataGenerator.GetAppointments(_appointmentsPms[0].ProviderId) .Take(5) .Select(TestDataGenerator.ToRepositoryAppointment) .ToList(); statusResponse.AddRange(submittedClaims.Select(TestDataGenerator.ToClaimStatus)); foreach (var appointment in _appointmentsRepository.Take(5)) { appointment.State = AppointmentState.ValidationCompletedAndClaimSubmitted; } _repositoryMock.Setup(m => m.GetAppointments()).Returns(_appointmentsRepository); _apiMock.Setup(m => m.GetClaimProcessingStatus(It.IsAny <ClaimProcessingStatusRequest>())).Returns(statusResponse); var appService = new ServerAppService(_repositoryMock.Object, _apiMock.Object, _dentalApiFactoryServiceMock.Object, _clientCallbackServiceMock.Object); // Act DispatcherHelper.WaitWithDispatcher(20000); // Assert AssertLoadingIndicator(); _dialogServiceMock.Verify(m => m.Show(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()), Times.Never, "Shouldn't have popup messages"); _apiMock.Verify(m => m.RegisterPlugin(It.IsAny <RegisterPluginRequest>()), Times.Never, "Shouldn't register plugin"); _dentalApiMock.Verify(m => m.GetAppointmentsForToday(), Times.Once); _apiMock.Verify(m => m.Initialize(It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <string>()), Times.Once, "Should initialize Chewsi API"); _apiMock.Verify(m => m.GetClaimProcessingStatus(It.IsAny <ClaimProcessingStatusRequest>()), Times.Once, "Should load claim statuses from Chewsi API"); // skip last 5 (claim statuses) AssertClaims(appService.GetClaims(true).Take(_appointmentsPms.Count - 5).ToList(), _appointmentsPms); foreach (var claimItem in appService.GetClaims(false).Skip(_appointmentsPms.Count)) { Assert.IsTrue( submittedClaims.Any( m => m.PatientId == claimItem.PatientId && m.DateTime == claimItem.Date && m.ChewsiId == claimItem.ChewsiId), "ServerAppService doesn't display all claim statuses"); } _settingsViewModelMock.Verify(m => m.InjectAppServiceAndInit(It.IsAny <IClientAppService>(), It.IsAny <SettingsDto>()), Times.Never, "Should not touch settings model"); _settingsViewModelMock.Verify(m => m.Show(It.IsAny <Action>()), Times.Never, "Should not show settings popup"); }
public void WhenRepositoryIsNotInitialized_DontCallChewsiApiItAndNoMessage() { // Arrange _repositoryMock.Setup(m => m.Ready).Returns(false); // Act var appService = new ServerAppService(_repositoryMock.Object, _apiMock.Object, _dentalApiFactoryServiceMock.Object, _clientCallbackServiceMock.Object); // Assert //AssertLoadingIndicator(); Assert.IsFalse(_loadingIndicatorShown, "Loading is not hidden"); _dialogServiceMock.Verify(m => m.Show(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()), Times.Never, "Shouldn't have popup messages"); _apiMock.Verify(m => m.RegisterPlugin(It.IsAny <RegisterPluginRequest>()), Times.Never, "Shouldn't register plugin"); Assert.AreEqual(ServerState.InvalidSettings, appService.GetState()); }
public void WhenPmsVersionNotChanged_ShouldNotUpdatePluginRegistration() { // Arrange _repositoryMock.Setup(m => m.GetSettingValue <string>(Settings.PMS.VersionKey)).Returns("v1"); _repositoryMock.Setup(m => m.GetSettingValue <string>(Settings.OsKey)).Returns(Utils.GetOperatingSystemInfo()); _repositoryMock.Setup(m => m.GetSettingValue <string>(Settings.AppVersionKey)).Returns(Utils.GetPluginVersion()); _dentalApiMock.Setup(m => m.GetVersion()).Returns("v1"); var appService = new ServerAppService(_repositoryMock.Object, _apiMock.Object, _dentalApiFactoryServiceMock.Object, _clientCallbackServiceMock.Object); // Act DispatcherHelper.WaitWithDispatcher(1000); // Assert AssertLoadingIndicator(); _apiMock.Verify(m => m.UpdatePluginRegistration(It.IsAny <UpdatePluginRegistrationRequest>()), Times.Never); }
protected override void OnStart(string[] args) { //Thread.Sleep(20000); Logger.Info("Service is starting. Operating system: {0}", Utils.GetOperatingSystemInfo()); AppDomain.CurrentDomain.UnhandledException += ApplicationDomainUnhandledException; _repository = new Repository(); _clientBroadcastService = new ClientBroadcastService(); _dentalApiFactoryService = new DentalApiFactoryService(_repository); _serverAppService = new ServerAppService(_repository, new ChewsiApi(), _dentalApiFactoryService, _clientBroadcastService); _serviceHost = new ServiceHost(_serverAppService); ServiceDiscoveryBehavior serviceDiscoveryBehavior = new ServiceDiscoveryBehavior(); serviceDiscoveryBehavior.AnnouncementEndpoints.Add(new UdpAnnouncementEndpoint()); _serviceHost.Description.Behaviors.Add(serviceDiscoveryBehavior); _serviceHost.AddServiceEndpoint(new UdpDiscoveryEndpoint()); var binding = new WSDualHttpBinding(WSDualHttpSecurityMode.Message) { OpenTimeout = new TimeSpan(0, 10, 0), CloseTimeout = new TimeSpan(0, 10, 0), SendTimeout = new TimeSpan(0, 10, 0), ReceiveTimeout = new TimeSpan(0, 10, 0), Security = new WSDualHttpSecurity { Mode = WSDualHttpSecurityMode.None } }; ServiceEndpoint endpoint = new ServiceEndpoint(ContractDescription.GetContract(typeof(IServerAppService)), binding, new EndpointAddress(Utils.GetAddressFromHost(System.Net.Dns.GetHostName()))); _serviceHost.AddServiceEndpoint(endpoint); _serviceHost.Open(); Logger.Info("The service is ready at {0}", string.Join(", ", _serviceHost.BaseAddresses)); }
public void WhenSubmittingClaim_ShouldUpdateList() { // Arrange var appService = new ServerAppService(_repositoryMock.Object, _apiMock.Object, _dentalApiFactoryServiceMock.Object, _clientCallbackServiceMock.Object); var procedure = new ProcedureInfo { Date = DateTime.Now, Amount = 123, Code = "1234" }; _dentalApiMock.Setup(m => m.GetProcedures(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <DateTime>())) .Returns(new List <ProcedureInfo> { procedure }); _repositoryMock.Setup(m => m.GetAppointmentById(It.IsAny <string>())).Returns(_appointmentsRepository[0]); _repositoryMock.Setup(m => m.UpdateAppointment(It.IsAny <Api.Repository.Appointment>())) .Callback(() => _appointmentsRepository[0].State = AppointmentState.ValidationCompletedAndClaimSubmitted); _apiMock.Setup(m => m.ValidateSubscriberAndProvider( It.IsAny <ProviderInformation>(), It.IsAny <ProviderAddressInformation>(), It.IsAny <SubscriberInformation>())).Returns(new ValidateSubscriberAndProviderResponse { ProviderValidationStatus = "Valid", SubscriberValidationStatus = "Valid" }); DispatcherHelper.WaitWithDispatcher(2000); var claim = appService.GetClaims(true).First(); // Act var result = appService.ValidateAndSubmitClaim(claim.Id); DispatcherHelper.WaitWithDispatcher(2000); // Assert Assert.AreEqual(SubmitClaimResult.Ok, result); AssertLoadingIndicator(); // skip first 1 (submitted) AssertClaims(appService.GetClaims(false), _appointmentsPms.Skip(1).ToList()); _apiMock.Verify(m => m.ValidateSubscriberAndProvider( It.Is <ProviderInformation>(n => n.NPI == _provider.Npi && n.TIN == _provider.Tin), It.Is <ProviderAddressInformation>(n => n.RenderingAddress1 == _provider.AddressLine1 && n.RenderingCity == _provider.City && n.RenderingAddress2 == _provider.AddressLine2 && n.RenderingState == _provider.State && n.RenderingZip == _provider.ZipCode), It.Is <SubscriberInformation>(n => n.Id == _patientInfo.ChewsiId && n.SubscriberFirstName == _patientInfo.SubscriberFirstName && n.SubscriberLastName == _patientInfo.SubscriberLastName && n.SubscriberDateOfBirth == _patientInfo.BirthDate)), Times.Once); _apiMock.Verify(m => m.ProcessClaim(It.IsAny <string>(), It.Is <ProviderInformation>(n => n.NPI == _provider.Npi && n.TIN == _provider.Tin), It.Is <SubscriberInformation>(n => n.Id == _patientInfo.ChewsiId && n.PatientFirstName == _patientInfo.PatientFirstName && n.PatientLastName == _patientInfo.PatientLastName && n.SubscriberFirstName == _patientInfo.SubscriberFirstName && n.SubscriberLastName == _patientInfo.SubscriberLastName && n.SubscriberDateOfBirth == _patientInfo.BirthDate), It.Is <List <ClaimLine> >(n => n[0].DateOfService == procedure.Date.ToString("d") && n[0].ProcedureCharge == procedure.Amount.ToString("F") && n[0].ProcedureCode == procedure.Code), It.IsAny <DateTime>()), Times.Once); AssertLoadingIndicator(); _dialogServiceMock.Verify(m => m.Show(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()), Times.Never, "Shouldn't have popup messages"); }