Bug Report T717925
Visible to All Users

Unit Testing - Unit test executed in Test Runner crashes for conditional appearance in code coverage mode

created 6 years ago

Hi,

when we use the Testrunner from CodeRush (18.2.3 VS extension) to execute our unit tests, anything works fine.
But the execution with code coverage of the same unit test thows an execption after checking conditional appearance (Method RefreshItemAppearance).

Do you have any advice how to test conditional appearance together with code coverage?

Best

Thomas

Some code snipplet of an unit test:

Visual Basic
Public Sub testImportAppearanceNew() Dim oImport As FakeImportTDG = mObjectSpace.CreateObject(Of FakeImportTDG) Dim appearanceController = New AppearanceController() Dim target = New FakeAppearanceTarget() Dim detailView As DetailView = mApplication.CreateDetailView(objectSpace:=mObjectSpace, obj:=oImport) detailView.ViewEditMode = Editors.ViewEditMode.Edit appearanceController.SetView(detailView) appearanceController.RefreshItemAppearance(detailView, "ViewItem", "File", target, oImport) ...

Exception:
System.TypeInitializationException : Der Typeninitialisierer für "DevExpress.ExpressApp.Utils.ErrorMessages" hat eine Ausnahme verursacht.
  ----> DevExpress.ExpressApp.Utils.ImageLoadException : An exception occurs while loading 'Error' image (IsEnabled = True): Die Zeichenfolge kann keine Länge von 0 (null) haben… See inner exception for details.
  ----> System.ArgumentException : Die Zeichenfolge kann keine Länge von 0 (null) haben.

DevExpress.ExpressApp.Utils.ErrorMessages…ctor()
DevExpress.ExpressApp.View…ctor(Boolean isRoot)
DevExpress.ExpressApp.CompositeView…ctor(IObjectSpace objectSpace, XafApplication application, Boolean isRoot)
DevExpress.ExpressApp.ObjectView…ctor(XafApplication application, IObjectSpace objectSpace, Boolean isRoot)
DevExpress.ExpressApp.DetailView…ctor(IModelDetailView info, IObjectSpace objectSpace, Object obj, XafApplication application, Boolean isRoot)
DevExpress.ExpressApp.DetailView…ctor(IObjectSpace objectSpace, Object obj, XafApplication application, Boolean isRoot)
DevExpress.ExpressApp.XafApplication.CreateDetailView(IObjectSpace objectSpace, String detailViewID, Boolean isRoot, Object obj, Boolean isDelayedObjectLoading)
DevExpress.ExpressApp.XafApplication.CreateDetailView(IObjectSpace objectSpace, String detailViewID, Boolean isRoot, Object obj)
DevExpress.ExpressApp.XafApplication.CreateDetailView(IObjectSpace objectSpace, Object obj, View sourceView)
DevExpress.ExpressApp.XafApplication.CreateDetailView(IObjectSpace objectSpace, Object obj)
Parma.Module.Test.ImportTDGTests.testImportAppearanceNew() in ImportTDGTests.vb
–ImageLoadExceptionDevExpress.ExpressApp.Utils.ImageSource.FindImageInfo(String imageName, Boolean isEnabled, Boolean findSmallWhenLargeIsNotFound, String imageFolder)
DevExpress.ExpressApp.Utils.ImageSource.FindImageInfo(String imageName, Boolean isEnabled, String imageFolder)
DevExpress.ExpressApp.Utils.ImageLoader.GetImageInfo(String imageName, Boolean isEnabled, String imageFolder)
DevExpress.ExpressApp.Utils.ImageLoader.GetImageInfo(String imageName, Boolean isEnabled)
DevExpress.ExpressApp.Utils.ImageLoader.GetImageInfo(String imageName)
DevExpress.ExpressApp.Utils.ErrorMessages…cctor()
–ArgumentExceptionSystem.Reflection.AssemblyName…ctor(String assemblyName)
DevExpress.Persistent.Base.ReflectionHelper.InternalLoadAssembly(String assemblyName, String assembliesPath)
DevExpress.Persistent.Base.ReflectionHelper.LoadAssembly(String assemblyName, String assembliesPath)
DevExpress.ExpressApp.Utils.AssemblyResourceImageSource.Initialize()
DevExpress.ExpressApp.Utils.AssemblyResourceImageSource.FindImageStream(String imageName, String imageUrl, Stream imageStream, String resourceName, String customImagesFolder)
DevExpress.ExpressApp.Utils.ImageSource.FindImageInfo(String imageName, Boolean isEnabled, Boolean findSmallWhenLargeIsNotFound, String imageFolder)

And the FakeAppearanceTarget:

Visual Basic
Public Class FakeAppearanceTarget Implements IAppearanceEnabled, IAppearanceVisibility Private _enabled As Boolean Public Property Enabled() As Boolean Implements IAppearanceEnabled.Enabled Get Return _enabled End Get Set(ByVal value As Boolean) _enabled = value End Set End Property Public Sub ResetEnabled() Implements IAppearanceEnabled.ResetEnabled Enabled = True End Sub Private _visibilty As ViewItemVisibility Public Property Visibility As ViewItemVisibility Implements IAppearanceVisibility.Visibility Get Return _visibilty End Get Set(value As ViewItemVisibility) _visibilty = value End Set End Property Public Sub ResetVisibility() Implements IAppearanceVisibility.ResetVisibility Visibility = ViewItemVisibility.Show End Sub Public Sub ResetAll() ResetEnabled() ResetVisibility() End Sub End Class
Show previous comments (1)
DevExpress Support Team 6 years ago

    Hello, Thomas.

    Since the code snippets you showed look similar to what is suggested in the How to: Test Conditional Appearance Rules article, I tried to reproduce the issue with our code. Everything seems to work fine on my side when I run tests with coverage. According to your error message, the assembly image source used in your test has an invalid name. I recommend that you try to debug this test on your side. Refer to the How can I debug DevExpress .NET source code using PDB files article.
    If this doesn't help, feel free to send a small sample project demonstrating the issue to us. We'll do our best to help you.

      Hello Michael,

      pls find attached a sample project (move InfiniteRecursionException.mdb to c:/temp).
      By stripping down the test the exception is thrown after CreateDetailView. Therefore it seems not to be the conditional appearance which makes problems.
      Pls notice that we use devExpress 17.2.8 together with the Code-Rush Visual Studio extension 18.2.3…

      DevExpress Support Team 6 years ago

        Hi Thomas,

        Thank you for the provided project. I've reproduced the issue using it. I've passed this ticket to our CodeRush team so that they will look into the issue. We will reply in this thread once we have any news.

        Answers approved by DevExpress Support

        created 6 years ago

        We have fixed the issue described in this ticket and will include the fix in our next maintenance update. To apply this solution before the official update, request a hotfix by clicking the corresponding link for product versions you require.

        Note: Hotfixes may be unavailable for beta versions and updates that are about to be released.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.