eXpandFramework / eXpand

DevExpress XAF (eXpressApp) extension framework. 𝗹𝗶𝗻𝗸𝗲𝗱𝗶𝗻.𝗲𝘅𝗽𝗮𝗻𝗱𝗳𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸.𝗰𝗼𝗺, 𝘆𝗼𝘂𝘁𝘂𝗯𝗲.𝗲𝘅𝗽𝗮𝗻𝗱𝗳𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸.𝗰𝗼𝗺 and 𝘁𝘄𝗶𝘁𝘁𝗲𝗿 @𝗲𝘅𝗽𝗮𝗻𝗱𝗳𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸 and or simply 𝗦𝘁𝗮𝗿/𝘄𝗮𝘁𝗰𝗵 this repository and get notified from 𝗚𝗶𝘁𝗛𝘂𝗯
http://expand.expandframework.com
Microsoft Public License
220 stars 114 forks source link

How to create application model for testing #1015

Closed Kagandaj closed 1 year ago

Kagandaj commented 1 year ago

I Have this helper method for testing projects that works well without expand

public static IModelApplication LoadApplicationModel(this ModuleBase module) { var manager = new ApplicationModulesManager(); manager.AddModule(module); manager.Load(XafTypesInfo.Instance, true); return new DesignerModelFactory().CreateApplicationModel(module, manager, ModelStoreBase.Empty); } However it fails when i add expand modules to the application. is there a way to create IModelApplication when using rx.xaf modules

exception System.NullReferenceException: 'Object reference not set to an instance of an object.'

callstack at Xpand.Persistent.Base.General.ModuleBaseExtensions.GetConnectionString(ModuleBase moduleBase) in E:\proj\eXpandFramework\eXpand\Xpand\Xpand.Persistent\Xpand.Persistent.Base\General\XpandModuleBase.cs:line 802

apobekiaris commented 1 year ago

Object reference not set to an instance of an object

the line that fails actually says that the module.Application is null, so it looks like your test setup is not appropriate.

eXpand constructs a XafApplication and then adds the module u can find examples in all the tests e.g. https://github.com/eXpandFramework/Reactive.XAF/blob/42582751eb4e447a59bac05324bb741ae9f9c255/src/Tests/AutoCommit/AutoCommitTests.cs#L42

you can use the same packages Xpand.TestsLib* and desing similar tests

Kagandaj commented 1 year ago

Thanks for this work