Example #1
0
        public void CreatePatient_Test()
        {
            var patient = new Patient("Ime", "Prezime", DateTime.Today, "31231231", "email");

            var patientRepositoryMock = new Mock <IRepository <Patient> >();

            patientRepositoryMock.Setup(m => m.Insert(patient)).Verifiable();

            var unitOfWorkMock = new Mock <IUnitOfWork>();

            unitOfWorkMock.Setup(m => m.PatientRepository).Returns(patientRepositoryMock.Object);

            IPatientSystem patientSystem = new PatientSystem(unitOfWorkMock.Object);

            //Act
            patientSystem.CreatePatient();

            //Assert
            unitOfWorkMock.Verify(r => r.PatientRepository.Insert(patient), Times.Once);
            unitOfWorkMock.Verify(u => u.SaveChanges(), Times.Once);
        }
    public override void OnInspectorGUI()
    {
        PatientSystem _patientSystem = (PatientSystem)target;

        EditorGUILayout.LabelField($"Loaded patients: {_patientSystem.GetLoadedPatients().Length}");

        string patientName = "No Active Patient";

        if (_patientSystem.ActivePatient != null)
        {
            patientName = _patientSystem.ActivePatient.PatientName;
        }
        EditorGUILayout.LabelField($"Active Patient: {patientName}");

        EditorGUILayout.Space(5);
        EditorGUILayout.LabelField("Set active patient");

        _popupOptions.Clear();
        _popupOptions.Add("-- SELECT ITEM --");
        foreach (PatientFile patientFile in _patientSystem.GetLoadedPatients())
        {
            _popupOptions.Add(patientFile.PatientName);
        }

        EditorGUILayout.BeginHorizontal();
        _selectedObject = EditorGUILayout.Popup(_selectedObject, _popupOptions.ToArray());
        if (GUILayout.Button("Set"))
        {
            if (_selectedObject == 0)
            {
                Debug.LogError("Nothing Selected!");
            }
            else
            {
                _patientSystem.SetActivePatient(_patientSystem.GetLoadedPatients()[_selectedObject - 1]);
                _selectedObject = 0;
            }
        }
        EditorGUILayout.EndHorizontal();
    }