All the features are enumerated at TpFeature enum:
public enum TpFeature
{
None = 0,
NewPopEmailIntegration,
TestCaseLibrary,
Solution,
...
}
Features are toggled on/off in web.config
<TpFeatures>
<add Feature="NewPopEmailIntegration" />
<!--<add Feature="Solution" />-->
<!--<add Feature="TestCaseLibrary" />-->
<!--<add Feature="UserStoriesCountReport" />-->
<!--<add Feature="BugCountReport" />-->
</TpFeatures>
Here are some use cases with samples.
1. I want to ignore some unit tests failed because I turned off the feature they're testing.
[Test]
[ToggleFeatureOff(TpFeature.Solution)]
public virtual void AttachToSolution()
{
...
}
It seems that attribute toggles tests on or off depending on feature configuration but unfortunately it’s not so clever. The attribute inherits nUnit IgnoreAttribute and is just descriptive to make the reason of ignorance more clear. This also will cause compile time errors when I'll be removing TpFeature member to fully remove or integrate feature. So, I won't forget about them.
2. I want to exclude some part of markup from page if feature is toggled off and include it when toggled on.
<tp:Toggle runat="server" Feature="Solution">
<tp:EditLink ID="lnkAttach" runat="server" TypeOfEntity="Request" Text="Attach To Solution" ClientAction='<%#string.Format("ShowSolutionFinder({0},{1})", Eval("RequestID"), Eval("ProjectID"))%>' />
<asp:Literal ID="separator3" runat="server">|</asp:Literal>
</tp:Toggle>
3.I want to include some part of markup to page when feature is toggled on and include another part of markup when feature is toggled off.
<tp:Toggle ID="newEmailIntegration" Feature="NewPopEmailIntegration" TurnedOn="true" runat="server">
<p class="defaultLabel pb-5">
Inbound Email Integration
</p>
<tp:InboundMailReplyEmail ID="tpInboundMailReplyEmailNew" runat="server" />
</tp:Toggle>
...
<tp:Toggle ID="oldEmailIntegration" Feature="NewPopEmailIntegration" TurnedOn="false" runat="server">
...
</tp:Toggle>
4. I want to hide some help steps (from Library.xml) when feature is toggled off.
<Step Key="BugsByState" Dependency="Project" Practice="BugTracking" Action="List" EntityType="Bug" Feature="BugCountReport">
<ActionItem ActionID="seeBugsDistributionByState" />
</Step>
<Step Key="BugsBySeverity" Dependency="Project" Practice="BugTracking" Action="List" EntityType="Bug" />
<Step Key="BugsProgress" Dependency="Project" Practice="BugTracking" Action="List" EntityType="Bug" Feature="BugCountReport"/>
5. I want to exclude some sitemap nodes when feature is toggled off
<siteMapNode title="Test Case Library" url="~/..." action="List" entity="TestCase" key="TestCaseLibrary" feature="TestCaseLibrary">
<siteMapNode title="Add/Edit Test Case" url="~/..." action="Edit" entity="TestCase" key="TestCaseLibrary" />
</siteMapNode>
6. I want to check if feature is enabled at any place in source code.
if (ObjectFactory.GetInstance<ITpFeatureList>().IsEnabled(TpFeature.Solution))
{
yield return GetDescription(EmailTemplateName.RequestToSolutionAttached);
}
Комментариев нет:
Отправить комментарий