How do i instantiate a UIMap in Class file that i have created - coded-ui-tests

I"m trying to instantiate a UIMAp (the reason i need this is currenly i'm having an error thats occuring and i think its because i need to instantiate it). I've read online about how to do it but my UI maps are named the same as my cs files that are created. and i cant seem to see if i'm actually instantiating it correctly since its just a class. I have reference in the file
which is
using Microsoft.VisualStudio.TestTools.UITest.Common.UIMap;
But i dont think i'm accessing it or am i and just dont know
I tried this code HomePage MyNewUIMap = new HomePage();
but i don't believe its correct here is my folder structure
For example my folder and file structure is
--> Home (folder)
---->HomePage.uiTest(UIfile)
------->HomePage.cs (file)
----------->HomePage.Designer.cs (file)

I normally keep a utility class that does nothing but instantiate my maps. Then, I can just call MyUtility.HomePage.objectOnHomePage when I need to interact with that object, and I don't need to instantiate each map on each test class. However, the actual method for instantiating my maps is done below:
public HomePage myHomePageMap
{
get
{
if (_homePage == null)
_homePage = new HomePage();
return _homePage;
}
}
private HomePage _homePage;
I do it this way to make sure that, if I've already instantiated the map, I don't create a duplicate instance of it.

Related

codeigniter4 - How do I shorten the path to the view folder for modules?

Based on a video with Codeigniter4, I created the Modules folder on the ROOTPATH and the Controllers, Views..etc folders in the Modules folder. It works fine, but when I want to call my view file inside the module
<?php
namespace Modules\Giris\Controllers;
use App\Controllers\BaseController;
class IndexController extends BaseController
{
public function index(){
return view('Modules\Giris\Views\index');
}
}
I need to specify a very long path like How can I make it just like view('index') and call the file from the Views folder in that module if I write it in a module? I don't want to write "Modules\Login\Views" in short is this possible?
Thanks in advance for all the kind replies.
Because view requires a string you couldn't provide a namespaced reference as you might think you should. Furthermore the code adds a .php extension and the "view path" (defined in your config\paths file) as part of its process (see system/View/View.php and render()). Therefore without modifying Codeigniter (which could be done but would affect all your code) the easiest way is to simply declare a public property or constant and make reference to that instead. Also helps if you need to change the path at any point.
I.e. protected $path = 'Modules\Giris\Views\' and then view($this->path.'index'); is probably the easiest way.

FakeItEasy in C# on a servicereference

I have a servicereference with a method I need to use in a test.
The servicereference class is defined as:
public class MyServiceReference : Clientbase<IMyServiceReference>, IMyServiceReference
{
public MyServiceReference()
{
}
..... methods is then defined
}
From my testmethod I have tried both
private MyServiceReference myServiceReferenceFake = A.Fake<MyServiceReference>();
// And
private MyServiceReference myServiceReference = new MyServiceReference();
For both of these is crashes in the constructor with the message:
System.InvalidOperationException: Could not find default endpoint element that references contract.
All I need is to have a callto definition from a method in that class.
How can this be solved?
I've no experience with Clientbase, which I assume to be a System.ServiceModel.ClientBase<TChannel>,but I can make some general comments.
Since you tried first to fake a MyServiceReference, I'll assume that you're not testing that class, and you want to use it as a collaborator for the system under test. In that case, your best bet is to try faking IMyServiceReference. interfaces are very easy to fake, since they don't bring along any behaviour or baggage like faking a class does.
If you feel you really need to fake a MyServiceReference, then we have to contend with the fact that FakeItEasy will eventually call MyServiceReference(), which will call ClientBase<IMyServiceReference>(), whose documentation says
Initializes a new instance of the ClientBase<TChannel> class using the default target endpoint from the application configuration file.
Based on the error you reported, I assume that the application configuration file is not found or does not include the configuration required to create a MyServiceReference. The fact that you get the same error when you just try to instantiate a MyServiceReference directly strengthens my belief.
So I think your paths forward are either to try faking IMyServiceReference or to provide the configuration that ClientBase<IMyServiceReference> needs.

Custom addon component not found

I'm trying to create a component within an addon. Everything works fine during impex process (contentslot, pagetemplate etc.) but it doesn't get rendered when accessing the page.
I've followed these steps but my controller isn't even get called.
#Controller("ConfirmationComponentController")
#RequestMapping(value = ControllerConstants.Actions.Cms.ConfirmationComponent)
public class ConfirmationComponentController extends AbstractCMSAddOnComponentController<ConfirmationComponentModel> {
#Override
protected void fillModel(HttpServletRequest request, Model model, ConfirmationComponentModel component) {
}
}
I've added the component's jsp in "WEB-INF/views/responsive/cms/.." from the addon module but I keep getting this error:
File [/WEB-INF/views/addons/trainingcore/responsive/cms/confirmationcomponent.jsp] not found
P.S.: I've managed to get the component controller to be called, but the getView() is returning a wrong path and that's why the component is not getting called. Any help? Thank you very much:)
Should this component to be created in addon *-items.xml?
What you need to know first
Using addons is a complicated endeavor in hybris. You need to know, that the resources are not used in the addon, but they are copied (during build process) to your storefront, where they are used.
All classes in
myaddon/acceleratoraddon/web/src/
will be copied to:
mystorefront/web/addonsrc/myaddon/
All resources in
myaddon/acceleratoraddon/web/webroot/
will be copied to corresponding folders:
mystorefront/web/webroot/WEB-INF/_ui-src/addons/myaddon
mystorefront/web/webroot/WEB-INF/tld/addons/myaddon
mystorefront/web/webroot/WEB-INF/messages/addons/myaddon
mystorefront/web/webroot/WEB-INF/tags/addons/myaddon
mystorefront/web/webroot/WEB-INF/views/addons/myaddon
That means
That means, that the effective path to your component jsp will not be something like:
/WEB-INF/views/cms/...
but will be something like:
/WEB-INF/views/myaddon/cms/...
The path myaddon will depend on the extension your component is declared in. So if you declare it in trainingcore-items.xml it will be
/WEB-INF/views/trainingcore/...
If you declare it in myaddon-items.xml it will be
/WEB-INF/views/myaddon/...

Can't get SharePoint fields with Java lib msgraph-sdk-java-dev for drive item with parenthesis in name

I am trying to access the fields associated with a file in my Office 365 root directory (https://www.office.com/) named (1).docx The left paren in the URL is causing some troubles when accessing from Java library, where something works fine from Graph Explorer.
With Microsoft Graph Explorer, I can access it by passing the filename as an argument into children like so:
https://graph.microsoft.com/v1.0/me/drive/root/children('(1).docx')
From the msgraph-sdk-java-dev, IDriveItemRequestBuilder has a children method that accepts a String argument.
This instead doesn't try to pass it as an argument to children(), but instead appends a slash, following by the name like
...drive/root/children/%281%29.doc
Actually.. I encoded the ()s. It doesn't work either way.
Is there some way to have IDriveItemRequestBuilder use the other form of accessing children? Or is there another way I should be accessing the item?
Ultimately.... I need to access the fields associated with the item as such:
https://graph.microsoft.com/v1.0/me/drive/root/children('(1).docx')/listitem/fields
I was able to solve this by subclassing DriveItemRequestBuilder and overriding children(String id)
driveItemReqBldr = new DriveItemRequestBuilder(driveItemReqBldr.getRequestUrl(), driveItemReqBldr.getClient(), null) {
public IDriveItemRequestBuilder children(String id) {
return new DriveItemRequestBuilder(getRequestUrlWithAdditionalSegment("children") + "('" + id +"')", getClient(), null);
}
};
Not sure if best way, but it worked.

Overriding CDocument OnFileSave()

How do I do this? If you could please kindly include the code for message map and the function itself, that would be greatly appreciated.
EDIT:
More specifically I am wondering how OnFileSave() links to OnSaveDocument(LPCSTR lpszPathName)
How does OnFileSave get lpszPathName?
You don't need to do anything special to override OnSaveDocument(...) it's already a virtual function in CDocument, so your derived class can just declare virtual BOOL OnSaveDocument(LPCTSTR lpszPathName); in it's header, then implement it in the document. Nothing is needed in the message map. OnSaveDocument will be called by the framework as part of OnFileSave which is a handler in the base class for ID_FILE_SAVE. The lpszPathName refers to m_strPathName when called by OnFileSafe, which is set when opening a file or by calling SetPathName. If it's empty when saving, the user is prompted for a file name.
CDocument::OnFileSave is the message handler for the Save menu command. To handle it yourself put this in your document class message map:
ON_COMMAND(ID_FILE_SAVE, OnFileSave)
and add your function:
void CYOURDOCUMENT::OnFileSave()
{
CDocument::OnFileSave();
}
To see everything it does put a breakpoint in your function and start single-stepping.

Resources