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 BasicPublic 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 BasicPublic 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
We are working on your question and will reply once we have any results. Thank you for your patience.
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…
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.