using BeWo.Data.Security; using BS.Shared; using BS.Shared.Core; using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.Collections.Generic; namespace TranslationUnitTest { [TestClass] public class EnumTranslationTest { public Dictionary Dict { get; set; } public List UserRightTypesVersion1dot0 { get; set; } [TestInitialize] public void Init() { UserRightTypesVersion1dot0 = new List() { UserRightType.None, UserRightType.DeleteAll, UserRightType.CreateAll, UserRightType.EditAll, UserRightType.ViewAll, UserRightType.ServiceRecordView_View, UserRightType.ServiceRecordView_Edit, UserRightType.ServiceRecordView_Create, UserRightType.ServiceRecordView_Delete, UserRightType.AccountingTransactionView_View, UserRightType.AccountingTransactionView_Edit, UserRightType.AccountingTransactionView_Create, UserRightType.AccountingTransactionView_Delete, UserRightType.ResourceBookingView_View, UserRightType.ResourceBookingView_Edit, UserRightType.ResourceBookingView_Create, UserRightType.ResourceBookingView_Delete, UserRightType.QueryView_View, UserRightType.QueryView_Edit, UserRightType.QueryView_Create, UserRightType.QueryView_Delete, UserRightType.SupportConceptView_View, UserRightType.SupportConceptView_Edit, UserRightType.SupportConceptView_Create, UserRightType.SupportConceptView_Delete, UserRightType.CustomerView_View, UserRightType.CustomerView_Edit, UserRightType.CustomerView_Create, UserRightType.CustomerView_Delete, UserRightType.OrganisationView_View, UserRightType.OrganisationView_Edit, UserRightType.OrganisationView_Create, UserRightType.OrganisationView_Delete, UserRightType.PersonView_View, UserRightType.PersonView_Edit, UserRightType.PersonView_Create, UserRightType.PersonView_Delete, UserRightType.EmployeeView_View, UserRightType.EmployeeView_Edit, UserRightType.EmployeeView_Create, UserRightType.EmployeeView_Delete, UserRightType.TeamView_ViewAll, UserRightType.TeamView_Edit, UserRightType.TeamView_Create, UserRightType.TeamView_Delete, UserRightType.UserView_View, UserRightType.UserView_Edit, UserRightType.UserView_Create, UserRightType.UserView_Delete, UserRightType.UserGroupView_View, UserRightType.UserGroupView_Edit, UserRightType.UserGroupView_Create, UserRightType.UserGroupView_Delete, UserRightType.AdministrationView_View, UserRightType.AdministrationView_Edit, UserRightType.AdministrationView_Create, UserRightType.AdministrationView_Delete, UserRightType.Employee_ShowFinance, UserRightType.Analysis_Settlement_View, UserRightType.Analysis_EmployeeOverviewAll_View, UserRightType.Analysis_ServiceOverview_View, UserRightType.Analysis_SupportConceptOverviewAll_View, UserRightType.UserView_AllowChangePassword, UserRightType.OrganisationView_AllowEditCostBearer, UserRightType.ServiceRecord_AllowChangeWithin24Hours, UserRightType.ServiceRecord_AllowCreateServiceRecordsForAllClients, UserRightType.SupportConcept_ViewAllSupportConcepts, UserRightType.SupportConcept_AllowGoalOrientedSupportConcepts, UserRightType.Customer_ViewMyCustomers, UserRightType.Analysis_AllowFLSOverviewForCostbearer, UserRightType.SupportConceptView_AllowArchiving, UserRightType.Person_AllowArchiving, UserRightType.Customer_AllowArchiving, UserRightType.ServiceRecord_AllowCreationForOtherEmployees, UserRightType.ResourceBookingView_AllowEditResourcesFromOtherEmployees, UserRightType.ServiceRecord_AllowEditAfterMaxDaysInNextMonth, UserRightType.AssessmentSheet_View, UserRightType.AssessmentSheet_Edit, UserRightType.AssessmentSheet_Create, UserRightType.AssessmentSheet_Delete, UserRightType.ServiceRecord_AllowCreateMoreFLSThanApproved, UserRightType.Analysis_AuslastungAllEmployee_View, UserRightType.Analysis_AuslastungTeam_View, UserRightType.Analysis_Auslastung_View, UserRightType.Analysis_AllowFLSOverviewForTeam, UserRightType.Analysis_AllowFLSOverviewForAllTeams, UserRightType.ServiceRecord_AllowCreateOverlappingFLS, UserRightType.ServiceRecord_AllowCreationForOtherTeamMember, UserRightType.BookServiceRecordOutOfSupportConcept, UserRightType.BookServiceRecordAfterSettlementInvoice, UserRightType.Organisation_AllowArchiving, UserRightType.ServiceRecord_ShowHistory, UserRightType.ServiceRecord_AllowCreateOverlappingFLSForEmployee, UserRightType.ServiceRecord_AllowCreatingGroupBooking, UserRightType.ServiceRecord_AllowCreatingMultiBooking, UserRightType.TeamView_ViewMyTeams, UserRightType.Customer_ViewMyTeams, UserRightType.SupportConcept_ViewMyTeams, UserRightType.Employee_AllowEditExtendedProperties, UserRightType.Employee_AllowEditContracts, UserRightType.Employee_AllowEditOwnEmployees, UserRightType.Employee_AllowArchiving, UserRightType.User_AllowOrderLicense, UserRightType.Employee_AllowViewOwnEmployees, UserRightType.Employee_AllowViewOwnTeam, UserRightType.Employee_ViewNotizen, UserRightType.Employee_EditNotizen, UserRightType.Employee_DeleteNotizen, UserRightType.GroupOfPeopleView_Edit, UserRightType.GroupOfPeopleView_Create, UserRightType.GroupOfPeopleView_Delete, UserRightType.AdditionalService_View, UserRightType.OvertimeView, UserRightType.Mitarbeiterstundenkonto_ViewSelf, UserRightType.Mitarbeiterstundenkonto_ViewAll, UserRightType.Mitarbeiterstundenkonto_ViewTeams, UserRightType.Auswertungen_BerichteAnsehen, UserRightType.Auswertungen_StundenuebersichtAnsehen, UserRightType.Auswertungen_HilfeplanuebersichtAnsehen, UserRightType.Support_View, UserRightType.SupportConcept_AllowEditGoals, UserRightType.SupportConcept_AllowEditTasks, UserRightType.ServiceRecord_AllowEditForOtherEmployees, UserRightType.KalenderAnsehen, UserRightType.KalenderMitarbeitertermineAnsehen, UserRightType.KalenderMitarbeitertermineAnlegen, UserRightType.KalenderMitarbeitertermineAendern, UserRightType.KalenderKliententermineAlleAnsehen, UserRightType.KalenderKliententermineAnlegen, UserRightType.KalenderKliententermineAendern, UserRightType.KalenderRessourcentermineAnsehen, UserRightType.KalenderRessourcentermineAnlegen, UserRightType.KalenderRessourcentermineAendern, UserRightType.KalenderRessourcentermineAndererAendern, UserRightType.KalenderInZeiterfassungUebernehmen, UserRightType.AllowChangeOwnPassword, UserRightType.TextbausteineAlleAnsehen, UserRightType.TextbausteineNurEigeneAnsehen, UserRightType.TextbausteineAlleBearbeiten, UserRightType.TextbausteineNurEigeneBearbeiten, UserRightType.BargeldverwaltungAnsehen, UserRightType.BargeldverwaltungNurEigeneAnsehen, UserRightType.BargeldverwaltungBearbeiten, UserRightType.BargeldverwaltungAnlegen, UserRightType.BargeldverwaltungLoeschen, UserRightType.SupportConceptAllowReactivation, UserRightType.CustomerAllowReactivation, UserRightType.OrganisationAllowReactivation, UserRightType.PersonAllowReactivation, UserRightType.EmployeeAllowReactivation, UserRightType.ServiceRecordAllowRebooking, UserRightType.CostbearerAllowChange, UserRightType.ServiceRecordAllowEditAfterMindays, UserRightType.DocumentsAllowViewAll, UserRightType.DocumentsDownloadAll, UserRightType.DocumentsEditFolders, UserRightType.DocumentsUploadAll, UserRightType.DocumentsDeleteAll, UserRightType.Customer_ViewMedication, UserRightType.Customer_ViewDiagnosis, UserRightType.Customer_ViewNotizen, UserRightType.Customer_EditNotizen, UserRightType.Customer_DeleteNotizen, UserRightType.WohnheimView_View, UserRightType.WohnheimView_Edit, UserRightType.WohnheimView_Create, UserRightType.WohnheimView_Delete, UserRightType.Wohnheim_AllowArchiving, UserRightType.Betreuungsschluessel_View, UserRightType.Betreuungsschluessel_Edit, UserRightType.Betreuungsschluessel_Delete, UserRightType.Betreuungsschluessel_Create, UserRightType.Jahresbericht, UserRightType.DokumenteFinanzen, UserRightType.DokumenteKlienten, UserRightType.DokumenteMitarbeiter, UserRightType.DokumenteOrganisationen, UserRightType.DokumentePersonen, UserRightType.DokumenteHilfeplaene, UserRightType.DokumenteTeams, UserRightType.BargeldverwaltungFinanzenAnsehen, UserRightType.BargeldverwaltungFinanzenAnlegen, UserRightType.BargeldverwaltungFinanzenBearbeiten, UserRightType.BargeldverwaltungFinanzenLoeschen, UserRightType.ChatSettings, UserRightType.ChatAdminSettings, UserRightType.Kilometerauswertung_View, UserRightType.BewertungAuswertung_View, UserRightType.BewertenInZeiterfassung, UserRightType.PivotTabelleAnsehen, UserRightType.DienstplanungAnsehen, UserRightType.AbwesenheitsPlanungAnsehen, UserRightType.KilometerauswertungEigene_View, UserRightType.VertretungenView_View, UserRightType.CustomerTeam_View, UserRightType.CustomerTeam_Edit, UserRightType.CustomerTeam_Delete, UserRightType.CustomerTeam_Create, UserRightType.Person_FamilyView, UserRightType.Customer_Anonymization, UserRightType.Customer_Full_Delete, UserRightType.Person_Full_Delete, UserRightType.Employee_Full_Delete, UserRightType.Employee_Anonymization, UserRightType.Termine_IntervalDelete, UserRightType.ServiceRecord_AllowCreateAfterEmployeeSignature, UserRightType.ServiceRecord_AllowEditAfterEmployeeSignature, UserRightType.ServiceRecord_AllowDeleteAfterEmployeeSignature, UserRightType.ConfirmationReceiptSignatures_Delete, UserRightType.Signature_ProvideSingleSignature, UserRightType.Signature_ProvideMonthlySignature, UserRightType.Signature_ProvideMonthlySignatureByProxy, }; } [TestMethod] public void DictionaryCreation() { var values = new Dictionary(); foreach (UserRightType item in Enum.GetValues(typeof(UserRightType))) { var value = (long)item; if (values.ContainsKey(value)) Assert.Fail($"\"{item}\" und \"{values[value]}\" haben den gleichen Wert \"{value}\""); values.Add(value, item); } } [TestMethod] public void DictionaryComplete() { Dict = EnumTranslations.UserRightType2Translations; foreach (UserRightType item in Enum.GetValues(typeof(UserRightType))) { if (item != UserRightType.None && !Dict.ContainsKey(item)) Assert.Fail($"UserRight \"{item}\" hat keine Übersetzung in {nameof(EnumTranslations.UserRightType2Translations)}"); } } [TestMethod] public void UserRightHelperComplete() { foreach (UserRightType item in Enum.GetValues(typeof(UserRightType))) { var has_special_version = UserRightHelper.GetRightVersion(item) != UserRightHelper.BASE_VERSION; if (has_special_version) continue; var is_base_version = UserRightTypesVersion1dot0.Contains(item); if (is_base_version) continue; Assert.Fail($"UserRight \"{item}\" hat keine Versionierung in {nameof(UserRightHelper.GetRightVersion)} ({nameof(UserRightHelper)})"); } } } }