コード例 #1
0
ファイル: CallTest.cs プロジェクト: dsb92/patientcare
        public void SendingCallJSONCategory_JSONConverted()
        {
            try
            {
                // Arrange
                var            testString     = "Test";
                CategoryEntity categoryEntity = new CategoryEntity
                {
                    CategoryId = Guid.NewGuid().ToString(),
                    Name       = "TestTestTest"
                };
                CallEntity callEntity = CallWrapper.WrapCall(CPRNUMMER, CallUtil.StatusCode.Active, categoryEntity, null,
                                                             null);

                //Act
                PatientCall call = new PatientCall();

                var callId = call.MakeCall(callEntity);

                Assert.IsTrue(!String.IsNullOrEmpty(callId));
            }
            catch (Exception ex)
            {
                //Assert
                Assert.Fail("Status Code not OK " + ex.Message);
            }
        }
コード例 #2
0
ファイル: CallTest.cs プロジェクト: dsb92/patientcare
        public void SendingCallJSONCategory_JSONConverted()
        {
            try
            {
                // Arrange
                var testString = "Test";
                CategoryEntity categoryEntity = new CategoryEntity
                {
                    CategoryId = Guid.NewGuid().ToString(),
                    Name = "TestTestTest"
                };
                CallEntity callEntity = CallWrapper.WrapCall(CPRNUMMER, CallUtil.StatusCode.Active, categoryEntity, null,
                    null);

                //Act
                PatientCall call = new PatientCall();

                var callId = call.MakeCall(callEntity);

                Assert.IsTrue(!String.IsNullOrEmpty(callId));
            }
            catch (Exception ex)
            {
                //Assert
                Assert.Fail("Status Code not OK " + ex.Message);
            }
        }
コード例 #3
0
ファイル: CallTest.cs プロジェクト: dsb92/patientcare
        public void SendingCallJSONCategoryChoiceDetail_JSONConverted()
        {
            // Arrange
            var testString = "Test";

            var detail = new DetailEntity()
            {
                DetailId = Guid.NewGuid().ToString(),
                Name     = "Mælk",
            };

            var choice = new ChoiceEntity()
            {
                ChoiceId = Guid.NewGuid().ToString(),
                Name     = "Kaffe",
                Details  = new List <DetailEntity> {
                    detail
                }
            };

            var category = new CategoryEntity()
            {
                CategoryId = Guid.NewGuid().ToString(),
                Name       = "Dinmor",
                //Picture = "http://multimedia.pol.dk/archive/00537/ITALY_CLONED_CHAMPI_537998a.jpg",
                Choices = new List <ChoiceEntity> {
                    choice
                }
            };

            CallEntity callEntity = CallWrapper.WrapCall(CPRNUMMER, CallUtil.StatusCode.Active, category, choice, detail);

            try
            {
                //Act
                PatientCall call   = new PatientCall();
                var         callId = call.MakeCall(callEntity);

                Assert.IsTrue(!String.IsNullOrEmpty(callId));
            }
            catch (Exception ex)
            {
                Assert.Fail("Status Code not OK " + ex.Message);
            }
        }
コード例 #4
0
ファイル: AppDelegate.cs プロジェクト: dsb92/patientcare
        public static void MakeCall(CallEntity callEntity, UIViewController vc)
        {
            var category = callEntity.Category;
            var choice   = callEntity.Choice ?? "";
            var detail   = callEntity.Detail ?? "";

            var confirmAlertController = UIAlertController.Create(category + " " + choice + " " + detail, Strings.CallSendMessage, UIAlertControllerStyle.Alert);

            // When user confirms the service
            var okAction = UIAlertAction.Create(Strings.CallSend, UIAlertActionStyle.Destructive, action =>
            {
                ShowLoadingScreen(vc, Strings.SpinnerDataSending);

                new System.Threading.Thread(new System.Threading.ThreadStart(() =>
                {
                    var callEntities = DataHandler.LoadCallsFromLocalDatabase(new LocalDB());

                    vc.InvokeOnMainThread(() =>
                    {
                        if (callEntities != null && callEntities.Length > 0)
                        {
                            // Check if the call already has been made, then return;
                            if (CallHasBeenMade(callEntities, callEntity))
                            {
                                return;
                            }
                        }

                        new System.Threading.Thread(new System.Threading.ThreadStart(() =>
                        {
                            // Make the async patient call here
                            try
                            {
                                ICall patientCall = new PatientCall();
                                // Assign the callid with the returned MongoDB id
                                callEntity._id = patientCall.MakeCall(callEntity);

                                vc.InvokeOnMainThread(() =>
                                {
                                    // Call successfull, take the user to myCalls passing the viewcontroller and the requested call
                                    GoToMyCalls(vc, callEntity);
                                });
                            }
                            catch (Exception ex)
                            {
                                // Hide the loading screen
                                Console.WriteLine("ERROR making call: " + ex.Message);

                                vc.InvokeOnMainThread(() =>
                                {
                                    loadingOverlay.Hide();
                                    new UIAlertView(Strings.Error, Strings.ErrorSendingCall, null, Strings.OK, null).Show();
                                });
                            }
                        })).Start();
                    });
                })).Start();


                new System.Threading.Thread(new System.Threading.ThreadStart(() =>
                {
                })).Start();
            });

            // When user cancels the service
            var cancelAction = UIAlertAction.Create(Strings.Cancel, UIAlertActionStyle.Cancel, action =>
            {
                // Do nothing.
            });

            confirmAlertController.AddAction(okAction);
            confirmAlertController.AddAction(cancelAction);

            // Display the alert
            vc.PresentViewController(confirmAlertController, true, null);
        }
コード例 #5
0
ファイル: CallTest.cs プロジェクト: dsb92/patientcare
        public void SendingCallJSONCategoryChoice_JSONConverted()
        {
            // Arrange
            var testString = "Test";

            var choice = new ChoiceEntity()
            {
                ChoiceId = Guid.NewGuid().ToString(),
                Name = "Morfin"
            };

            var category = new CategoryEntity()
            {
                CategoryId = Guid.NewGuid().ToString(),
                Name = "Smertestillende",
                //Picture = "http://multimedia.pol.dk/archive/00537/ITALY_CLONED_CHAMPI_537998a.jpg",
                Choices = new List<ChoiceEntity> { choice }
            };

            CallEntity callEntity = CallWrapper.WrapCall(CPRNUMMER, CallUtil.StatusCode.Active, category, choice, null);

            try
            {
                //Act
                PatientCall call = new PatientCall();
                var callId = call.MakeCall(callEntity);

                Assert.IsTrue(!String.IsNullOrEmpty(callId));
            }
            catch (Exception ex)
            {
                // Assert
                Assert.Fail("Status Code not OK " + ex.Message);
            }
        }