diff --git a/src/System Application/App/Environment Information/src/EnvironmentInformationImpl.Codeunit.al b/src/System Application/App/Environment Information/src/EnvironmentInformationImpl.Codeunit.al index 590e184c53..6a90407f93 100644 --- a/src/System Application/App/Environment Information/src/EnvironmentInformationImpl.Codeunit.al +++ b/src/System Application/App/Environment Information/src/EnvironmentInformationImpl.Codeunit.al @@ -27,26 +27,12 @@ codeunit 3702 "Environment Information Impl." DefaultProductionEnvironmentNameTxt: Label 'Production', Locked = true; procedure IsProduction(): Boolean - var - Production: Boolean; - TestMode: Boolean; begin - OnBeforeIsProduction(TestMode, Production); - if TestMode then - exit(Production); - exit(NavTenantSettingsHelper.IsProduction()) end; procedure IsSandbox(): Boolean - var - Sandbox: Boolean; - TestMode: Boolean; begin - OnBeforeIsSandbox(TestMode, Sandbox); - if TestMode then - exit(Sandbox); - if TestabilitySandbox then exit(true); @@ -60,12 +46,7 @@ codeunit 3702 "Environment Information Impl." procedure GetEnvironmentName(): Text var EnvironmentName: Text; - TestMode: Boolean; begin - OnBeforeEnvironmentName(TestMode, EnvironmentName); - if TestMode then - exit(EnvironmentName); - EnvironmentName := NavTenantSettingsHelper.GetEnvironmentName(); if EnvironmentName <> '' then exit(EnvironmentName); @@ -89,13 +70,7 @@ codeunit 3702 "Environment Information Impl." procedure IsSaaS(): Boolean var ServerSettings: Codeunit "Server Setting"; - TestMode: Boolean; - SaaS: Boolean; begin - OnBeforeIsSaaS(TestMode, SaaS); - if TestMode then - exit(SaaS); - if TestabilitySoftwareAsAService then exit(true); @@ -110,13 +85,7 @@ codeunit 3702 "Environment Information Impl." procedure IsSaaSInfrastructure(): Boolean var UserAccountHelper: DotNet NavUserAccountHelper; - SaaSInfrastructure: Boolean; - TestMode: Boolean; begin - OnBeforeIsSaaSInfrastructure(TestMode, SaaSInfrastructure); - if TestMode then - exit(SaaSInfrastructure); - if TestabilitySoftwareAsAService then exit(true); @@ -134,28 +103,15 @@ codeunit 3702 "Environment Information Impl." end; procedure GetApplicationFamily(): Text - var - TestMode: Boolean; - ApplicationFamily: Text; begin - OnBeforeApplicationFamily(TestMode, ApplicationFamily); - if TestMode then - exit(ApplicationFamily); - exit(NavTenantSettingsHelper.GetApplicationFamily()); end; procedure VersionInstalled(AppID: Guid): Integer var AppInfo: ModuleInfo; - WhichVersionInstalled: Integer; - TestMode: Boolean; begin - OnBeforeVersionInstalled(TestMode, WhichVersionInstalled); - if TestMode then - exit(WhichVersionInstalled); - - NavApp.GetModuleInfo(AppId, AppInfo); + NavApp.GetModuleInfo(AppID, AppInfo); exit(AppInfo.DataVersion.Major()); end; @@ -198,54 +154,5 @@ codeunit 3702 "Environment Information Impl." // An event which asks for the AppId to be filled in by the subscriber. // Do not use this event in a production environment. This should be subscribed to only in tests. end; - - [InternalEvent(false)] - procedure OnBeforeIsSaaSInfrastructure(var TestMode: Boolean; var IsSaaSInfrastructure: Boolean) - begin - // An event which asks for the IsSaaSInfrastructure to be filled in by the subscriber. - // Do not use this event in a production environment. This should be subscribed to only in tests. - end; - - [InternalEvent(false)] - procedure OnBeforeVersionInstalled(var TestMode: Boolean; var VersionInstalled: Integer) - begin - // An event which asks for the VersionInstalled to be filled in by the subscriber. - // Do not use this event in a production environment. This should be subscribed to only in tests. - end; - - [InternalEvent(false)] - procedure OnBeforeIsSaaS(var TestMode: Boolean; var IsSaaS: Boolean) - begin - // An event which asks for the IsSaaS to be filled in by the subscriber. - // Do not use this event in a production environment. This should be subscribed to only in tests. - end; - - [InternalEvent(false)] - procedure OnBeforeEnvironmentName(var TestMode: Boolean; var EnvironmentName: Text) - begin - // An event which asks for the EnvironmentName to be filled in by the subscriber. - // Do not use this event in a production environment. This should be subscribed to only in tests. - end; - - [InternalEvent(false)] - procedure OnBeforeIsSandbox(var TestMode: Boolean; var IsSandbox: Boolean) - begin - // An event which asks for the IsSandbox to be filled in by the subscriber. - // Do not use this event in a production environment. This should be subscribed to only in tests. - end; - - [InternalEvent(false)] - procedure OnBeforeIsProduction(var TestMode: Boolean; var IsProduction: Boolean) - begin - // An event which asks for the IsProduction to be filled in by the subscriber. - // Do not use this event in a production environment. This should be subscribed to only in tests. - end; - - [InternalEvent(false)] - procedure OnBeforeApplicationFamily(var TestMode: Boolean; var ApplicationFamily: Text) - begin - // An event which asks for the ApplicationFamily to be filled in by the subscriber. - // Do not use this event in a production environment. This should be subscribed to only in tests. - end; } diff --git a/src/System Application/Test Library/Environment Information/src/EnvironmentInfoTestLibrary.Codeunit.al b/src/System Application/Test Library/Environment Information/src/EnvironmentInfoTestLibrary.Codeunit.al index 6bc4e4070c..fa5dd7e5c9 100644 --- a/src/System Application/Test Library/Environment Information/src/EnvironmentInfoTestLibrary.Codeunit.al +++ b/src/System Application/Test Library/Environment Information/src/EnvironmentInfoTestLibrary.Codeunit.al @@ -15,13 +15,6 @@ codeunit 135094 "Environment Info Test Library" var EnvironmentInformationImpl: Codeunit "Environment Information Impl."; TestAppId: Text; - TestApplicationFamily: Text; - TestIsProduction: Boolean; - TestIsSandbox: Boolean; - TestEnvironmentName: Text; - TestIsSaaS: Boolean; - TestVersionInstalled: Integer; - TestIsSaaSInfrastructure: Boolean; /// /// Sets the testability sandbox flag. @@ -30,6 +23,7 @@ codeunit 135094 "Environment Info Test Library" /// This functions should only be used for testing purposes. /// /// The value to be set to the testability sandbox flag. + [Scope('OnPrem')] procedure SetTestabilitySandbox(EnableSandboxForTest: Boolean) begin EnvironmentInformationImpl.SetTestabilitySandbox(EnableSandboxForTest); @@ -42,91 +36,23 @@ codeunit 135094 "Environment Info Test Library" /// This functions should only be used for testing purposes. /// /// The value to be set to the testability SaaS flag. + [Scope('OnPrem')] procedure SetTestabilitySoftwareAsAService(EnableSoftwareAsAServiceForTest: Boolean) begin EnvironmentInformationImpl.SetTestabilitySoftwareAsAService(EnableSoftwareAsAServiceForTest); end; /// - /// Sets the App ID that of the current application (for example, 'FIN' - Financials) when the subscription is bound. + /// Sets the App ID that of the current application (for example, 'FIN' - Financials) when the sunscription is bound. /// Uses event. /// /// The desired ne App ID. + [Scope('OnPrem')] procedure SetAppId(NewAppId: Text) begin TestAppId := NewAppId; end; - /// - /// Sets the Is SaaS Infrastructure that of the current Environment when the subscription is bound. - /// Uses event. - /// - /// The desired new Is SaaS Infrastructure. - procedure SetIsSaaSInfrastructure(NewIsSaaSInfrastructure: Boolean) - begin - TestIsSaaSInfrastructure := NewIsSaaSInfrastructure; - end; - - /// - /// Sets the App Version that of the current application when the subscription is bound. - /// Uses event. - /// - /// The desired new Version Installed - procedure SetVersionInstalled(NewVersionInstalled: Integer) - begin - TestVersionInstalled := NewVersionInstalled; - end; - - /// - /// Sets the IsSaas of the current environment when the subscription is bound. - /// Uses event. - /// - /// The desired new Is SaaS - procedure SetIsSaaS(NewIsSaaS: Boolean) - begin - TestIsSaaS := NewIsSaaS; - end; - - /// - /// Sets the Environment Name of the current environment when the subscription is bound. - /// Uses event. - /// - /// The desired new Environment Name. - procedure SetEnvironmentName(NewEnvironmentName: Text) - begin - TestEnvironmentName := NewEnvironmentName; - end; - - /// - /// Sets the IsSandbox that of the current environment when the subscription is bound. - /// Uses event. - /// - /// The desired ne App ID. - procedure SetIsSandbox(NewIsSandbox: Boolean) - begin - TestIsSandbox := NewIsSandbox; - end; - - /// - /// Sets the IsProduction that of the current environment when the subscription is bound. - /// Uses event. - /// - /// The desired new is production. - procedure SetIsProduction(NewIsProduction: Boolean) - begin - TestIsProduction := NewIsProduction; - end; - - /// - /// Sets the Application Family that of the current application when the subscription is bound. - /// Uses event. - /// - /// The desired new Application Family. - procedure SetApplicationFamily(NewApplicationFamily: Text) - begin - TestApplicationFamily := NewApplicationFamily; - end; - /// /// Overwrite the current App ID. /// @@ -136,88 +62,5 @@ codeunit 135094 "Environment Info Test Library" begin AppId := TestAppId; end; - - /// - /// Overwrite the current Application Family - /// - /// The current Application Family. - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Environment Information Impl.", 'OnBeforeApplicationFamily', '', false, false)] - local procedure SetApplicationFamilyOnBeforeApplicationFamily(var TestMode: Boolean; var ApplicationFamily: Text) - begin - TestMode := true; - ApplicationFamily := TestApplicationFamily; - end; - - /// - /// Overwrite Is SaaS Infrastructure. - /// - /// Sets Test Mode - /// The current Is SaaS Infrastructure. - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Environment Information Impl.", 'OnBeforeIsSaaSInfrastructure', '', false, false)] - local procedure SetIsSaaSInfrastructureOnBeforeIsSaaSInfrastructure(var TestMode: Boolean; var IsSaaSInfrastructure: Boolean) - begin - TestMode := true; - IsSaaSInfrastructure := TestIsSaaSInfrastructure; - end; - - /// - /// Overwrite the current Version Installed. - /// - /// Sets Test Mode - /// The current Version Installed - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Environment Information Impl.", 'OnBeforeVersionInstalled', '', false, false)] - local procedure SetVersionInstalledOnBeforeVersionInstalled(var TestMode: Boolean; var VersionInstalled: Integer) - begin - TestMode := true; - VersionInstalled := TestVersionInstalled; - end; - - /// - /// Overwrite the current Is SaaS. - /// - /// Sets Test Mode - /// The current Is SaaS - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Environment Information Impl.", 'OnBeforeIsSaaS', '', false, false)] - local procedure SetIsSaaSOnBeforeIsSaaS(var TestMode: Boolean; var IsSaaS: Boolean) - begin - TestMode := true; - IsSaaS := TestIsSaaS; - end; - - /// - /// Overwrite the current Environment Name. - /// - /// Sets Test Mode - /// The current Environment Name. - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Environment Information Impl.", 'OnBeforeEnvironmentName', '', false, false)] - local procedure SetEnvironmentNameOnBeforeEnvironmentName(var TestMode: Boolean; var EnvironmentName: Text) - begin - TestMode := true; - EnvironmentName := TestEnvironmentName; - end; - - /// - /// Overwrite the current Is Sandbox. - /// - /// Sets Test Mode - /// The current Is Sandbox. - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Environment Information Impl.", 'OnBeforeIsSandbox', '', false, false)] - local procedure SetIsSandboxOnBeforeIsSandbox(var TestMode: Boolean; var IsSandbox: Boolean) - begin - TestMode := true; - IsSandbox := TestIsSandbox; - end; - - /// - /// Overwrite the current Is Production. - /// - /// Sets Test Mode - /// The current Is Sandbox. - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Environment Information Impl.", 'OnBeforeIsProduction', '', false, false)] - local procedure SetIsProductionOnBeforeIsProduction(var TestMode: Boolean; var IsProduction: Boolean) - begin - TestMode := true; - IsProduction := TestIsProduction; - end; } diff --git a/src/System Application/Test/Environment Information/src/EnvironmentInformationTest.Codeunit.al b/src/System Application/Test/Environment Information/src/EnvironmentInformationTest.Codeunit.al index 71d9613321..7d396be39a 100644 --- a/src/System Application/Test/Environment Information/src/EnvironmentInformationTest.Codeunit.al +++ b/src/System Application/Test/Environment Information/src/EnvironmentInformationTest.Codeunit.al @@ -40,7 +40,7 @@ codeunit 135091 "Environment Information Test" // [When] Poll for IsSandbox // [Then] Should return true - Assert.IsTrue(EnvironmentInformation.IsSandbox(), 'Environment Information should have returned the setup of a sandbox environment'); + Assert.IsTrue(EnvironmentInformation.IsSandbox(), 'Testability should have dictacted a sandbox environment'); end; [Test] @@ -54,7 +54,7 @@ codeunit 135091 "Environment Information Test" // [When] Poll for IsSandbox // [Then] Should return false - Assert.IsFalse(EnvironmentInformation.IsSandbox(), 'Environment Information should have returned the setup of a non-sandbox environment'); + Assert.IsFalse(EnvironmentInformation.IsSandbox(), 'Testability should have dictacted a non-sandbox environment'); end; [Test] @@ -68,7 +68,7 @@ codeunit 135091 "Environment Information Test" // [When] Poll for IsSaaS // [Then] Should return true - Assert.IsTrue(EnvironmentInformation.IsSaaS(), 'Environment Information should have returned the setup of a SaaS environment'); + Assert.IsTrue(EnvironmentInformation.IsSaaS(), 'Testability should have dictacted a SaaS environment'); end; [Test] @@ -82,97 +82,7 @@ codeunit 135091 "Environment Information Test" // [When] Poll for IsSaaS // [Then] Should return false - Assert.IsFalse(EnvironmentInformation.IsSaaS(), 'Environment Information should have returned the setup of a non-SaaS environment'); - end; - - [Test] - procedure TestIsSaaSInfrastructureIsTrueWhenTestabilitySaaSInfrastructureIsSetTrue() - begin - // [SCENARIO] Set the testability to true. IsSaaSInfrastructure returns correct values. - if BindSubscription(EnvironmentInfoTestLibrary) then; - - // [Given] Set the testability SaaS to true - EnvironmentInfoTestLibrary.SetIsSaaSInfrastructure(true); - - // [When] Poll for IsSaaSInfrastructure - // [Then] Should return true - Assert.IsTrue(EnvironmentInformation.IsSaaSInfrastructure(), 'Environment Information should have returned the setup of a SaaS infrastructure'); - if UnbindSubscription(EnvironmentInfoTestLibrary) then; - end; - - [Test] - procedure TestVersionInstalledIsTrueWhenTestabilityVersionInstalledIsSet() - begin - // [SCENARIO] Set the testability to true. VersionInstalled returns correct values. - if BindSubscription(EnvironmentInfoTestLibrary) then; - - // [Given] Set the testability VersionInstalled to 23 - EnvironmentInfoTestLibrary.SetVersionInstalled(23); - - // [When] Poll for VersionInstalled - // [Then] Should return the correct version installed - Assert.AreEqual(23, EnvironmentInformation.VersionInstalled('35de2eee-c479-459e-b70b-2f244708415a'), 'Environment Information should have returned the correct version installed'); - if UnbindSubscription(EnvironmentInfoTestLibrary) then; - end; - - [Test] - procedure TestIsSaaSIsTrueWhenTestabilityIsSaaSIsSet() - begin - // [SCENARIO] Set the testability to true. IsSaaS returns correct values. - if BindSubscription(EnvironmentInfoTestLibrary) then; - - // [Given] Set the testability SaaS to true - EnvironmentInfoTestLibrary.SetIsSaaS(true); - - // [When] Poll for IsSaaS - // [Then] Should return true - Assert.IsTrue(EnvironmentInformation.IsSaaS(), 'Environment Information should have returned the setup of a SaaS environment'); - if UnbindSubscription(EnvironmentInfoTestLibrary) then; - end; - - [Test] - procedure TestEnvironmentNameIsTrueWhenTestabilityEnvironmentNameIsSet() - begin - // [SCENARIO] Set the testability to true. EnvironmentName returns correct values. - if BindSubscription(EnvironmentInfoTestLibrary) then; - - // [Given] Set the testability EnvironmentName to '123' - EnvironmentInfoTestLibrary.SetEnvironmentName('123'); - - // [When] Poll for EnvironmentName - // [Then] Should return the correct environment name - Assert.AreEqual('123', EnvironmentInformation.GetEnvironmentName(), 'Environment Information should have returned the correct environment name'); - if UnbindSubscription(EnvironmentInfoTestLibrary) then; - end; - - [Test] - procedure TestIsProductionIsTrueWhenTestabilityIsProductionIsSet() - begin - // [SCENARIO] Set the testability to true. IsProduction returns correct values. - if BindSubscription(EnvironmentInfoTestLibrary) then; - - // [Given] Set the testability IsProduction to true - EnvironmentInfoTestLibrary.SetIsProduction(true); - - // [When] Poll for IsProduction - // [Then] Should return true - Assert.IsTrue(EnvironmentInformation.IsProduction(), 'Environment Information should have returned the setup of a production environment'); - if UnbindSubscription(EnvironmentInfoTestLibrary) then; - end; - - [Test] - procedure TestApplicationFamilyIsTrueWhenTestabilityApplicationFamilyIsSet() - begin - // [SCENARIO] Set the testability to true. ApplicationFamily returns correct values. - if BindSubscription(EnvironmentInfoTestLibrary) then; - - // [Given] Set the testability ApplicationFamily to 1234 - EnvironmentInfoTestLibrary.SetApplicationFamily('1234'); - - // [When] Poll for ApplicationFamily - // [Then] Should return the correct application family - Assert.AreEqual('1234', EnvironmentInformation.GetApplicationFamily(), 'Environment Information should have returned the correct application family'); - if UnbindSubscription(EnvironmentInfoTestLibrary) then; + Assert.IsFalse(EnvironmentInformation.IsSaaS(), 'Testability should have dictacted a non- SaaS environment'); end; } diff --git a/src/System Application/Test/Satisfaction Survey/src/SatisfactionSurveyTests.Codeunit.al b/src/System Application/Test/Satisfaction Survey/src/SatisfactionSurveyTests.Codeunit.al index 25f904ffd8..d8f893533e 100644 --- a/src/System Application/Test/Satisfaction Survey/src/SatisfactionSurveyTests.Codeunit.al +++ b/src/System Application/Test/Satisfaction Survey/src/SatisfactionSurveyTests.Codeunit.al @@ -265,7 +265,7 @@ codeunit 138074 "Satisfaction Survey Tests" begin // Setup Initialize(); - EnvironmentInfoTestLibrary.SetIsSandbox(true); + EnvironmentInfoTestLibrary.SetTestabilitySandbox(true); SimulatePuidNotEmpty(); SimulateApiUrlNotEmpty(); PermissionsMock.Set('Satisfaction View'); @@ -305,7 +305,7 @@ codeunit 138074 "Satisfaction Survey Tests" begin // Setup Initialize(); - EnvironmentInfoTestLibrary.SetIsSaaS(false); + EnvironmentInfoTestLibrary.SetTestabilitySoftwareAsAService(false); SimulatePuidNotEmpty(); SimulateApiUrlNotEmpty(); PermissionsMock.Set('Satisfaction View'); @@ -527,8 +527,8 @@ codeunit 138074 "Satisfaction Survey Tests" local procedure Initialize() begin ClearLastError(); - EnvironmentInfoTestLibrary.SetIsSaaS(true); - EnvironmentInfoTestLibrary.SetIsSandbox(false); + EnvironmentInfoTestLibrary.SetTestabilitySoftwareAsAService(true); + EnvironmentInfoTestLibrary.SetTestabilitySandbox(false); SatisfactionSurveyMgt.ResetCache(); TestClientTypeSubscriber.SetClientType(ClientType::Web); SatisfactionSurveyMgt.ResetState();