Esempio n. 1
0
        public void ThenUserCanOnlyCreateAssetsIfHavingAssetsOrTrusteeRole()
        {
            CaseDetailPage caseDetailPage = ((CaseDetailPage)GetSharedPageObjectFromContext("Case Detail"));
            List <String>  roles          = ScenarioContext.Current.Get <List <string> >("Roles");

            AssetsDetailTab assetsTab = caseDetailPage.GoToAssetsDetail();

            if (roles.Contains("Assets") || roles.Contains("Trustee Role"))
            {
                //New Asset button
                assetsTab.IsNewAssetButtonActive.Should().BeTrue("User has roles " + this.PrintableRoles(roles) + ", so New Asset button is active");
                assetsTab.ClickNewAssetButton();
                assetsTab.IsNewAssetFormVisible.Should().BeTrue("User has roles " + this.PrintableRoles(roles) + ", so New Asset button opens New Asset Form");
                assetsTab.CancelNewAsset();
                //Quick Edit button
                assetsTab.AllQuickEditButtonsActive.Should().BeTrue("User has roles " + this.PrintableRoles(roles) + "User has roles " + this.PrintableRoles(roles) + ", so Quick Edit button is active");
                assetsTab.ClickQuickEditButtonOnFirstAsset();
                assetsTab.IsEditAssetFormVisible.Should().BeTrue("User has roles " + this.PrintableRoles(roles) + ", so Quick Edit button opens Edit Asset Form");
            }
            else
            {
                //New Asset button
                assetsTab.IsNewAssetButtonActive.Should().BeFalse("User does not have assets role, so New Asset button is inactive");
                try
                {
                    assetsTab.ClickNewAssetButton();
                    assetsTab.IsNewAssetFormVisible.Should().BeFalse("User does not have assets role, so New Asset button doesn't work");
                    assetsTab.CancelNewAsset();
                }
                catch (Exception)
                {
                    //do nothing, if not clickeable test passes
                }

                //Quick Edit button
                assetsTab.AllQuickEditButtonsInactive.Should().BeTrue("User does not have assets role, so Quick Edit button is inactive");
                try
                {
                    assetsTab.ClickQuickEditButtonOnFirstAsset();
                    assetsTab.IsEditAssetFormVisible.Should().BeFalse("User does not have assets role, so New Asset button doesn't work");
                }
                catch (Exception)
                {
                    //do nothing, if not clickeable test passes
                }
            }
        }