Search all in memory objects .NET - visual-studio-2010

Is there a tool built into Visual Studio or a third-party add-on that would allow you to search all of the objects in memory for a certain string?
Here is a simple example to give an idea of what I'm trying to accomplish:
Dim myClass as New Foo()
myClass.someVar = "Test"
I would like to be able to search all in-memory objects for the string 'Test' and see which objects have this value. I don't want to manually look through Quick Watch but have a tool that would do that kind of manual searching.

Related

Using Page Objects vs Config Files in Selenium

I've been using Ruby Selenium-Webdriver for one of the automation scripts I'm developing and I'm being asked to use Page Objects, we use page objects a lot however for this application I am using CSV file instead, I have defined all the xpaths that I'm using in my application in a CSV file and I'm parsing that CSV file in my script to refer to those objects, I would like to know is there much of a difference in using a class for defining Page Objects or using a CSV file instead apart from performance concern? I believe using a CSV file will be an addon for us from configuration standpoint and will make it much easier to maintain, any suggestions on this?
Edit - In our use case, we're actually automating applications built on a cloud based tool, so basically all the applications share same design structure from HTML standpoint so we define xpath patterns in CSV and then we pass certain parameters to some custom methods that we've developed to generate xpath's automatically using the CSV instead of finding those manually as its overhead for us because we already know that all the applications will share similar xpath pattern for all elements.
Thanks
I think, POM is better than CSV approach. In POM, you put elements for a page in a separate class file. So, if any change is to make then it's easier to find where to change/maintain. Moreover, it won't get too messy as CSV file and you don't need to use extra utility function to parse those.
There is also a pageobjects gem that provides a set of libraries over and above webdriver/watir, simplifying the code.
Plus, why xpaths? Its one of the last recommended ways to identify an element.
As for the frameork aspect, csv should be more of a maintenance problem than PageObjects. Its the basic difference between text and code. You enforce Object oriented approach on your elements in PageObjects but that is not possible with csv.
In the best case scenario, you have created a column/separate sheets defining which page that element xpath belongs to. That sounds like an overhead. As your application / suite grows there can be thousands of elements. Imagine parsing/ manually updating a csv with that kind of data.
Instead in PageObjects, your elements will be restricted to the Page. Any changes to the app will also specify which elements may get impacted. Now, when define your element as an object in PageObject, rather than css, you also dont need to explicitly create your elements by reading the csv.
It completely depends on the application and the type of test you might perform.
Since it is an automated test script, you do not have to really worry about the performance of the script (it might take few more milli seconds to parse, which should be OK).
Maintaining all the elements identification properties & corresponding actions in a CSV file will make the maintenance easier and make the framework application independent which are nice. But maintaining your framework is bit difficult to make it more robust. Both approaches have its own pros and cons.
Refer to below posts [examples are in java - but you will get the idea]:
Keyword driven framework
Advanced Page Objects
Update:
If you like both, you can comeup with your implementation to easily integrate these too.
#ObjectRepository(src="/login.csv")
public class LoginPage{
private Map<String, WebElement> elements;
public void login(){
elements.get("username").sendKeys('');
elements.get("password").sendKeys('');
elements.get("signin").click();
}
}
Ie, define all the elements in a config file like csv/json etc. Let the page object refer to the class for the page elements. All the methods will be part of the page class.

Visual Studio: capture object state in debug mode and use it in unit test

Is there an easy and elegant way to capture objects in debug mode and just dump them in the unit tests?
I am using some very large object (like 30+ fields) and i would need that as data in my unit tests.
I don't know of any quick-and-easy way of doing this and, in fact, I suspect that the whole issue with field/properties, nesting, private-public prevents VS from providing a general-purpose solution for this.
You could certainly use serialization, for example calling some {{MyHelper.ToInitExpression()}} in the Immediate window while debugging and then taking the clipboard data and putting it into your unit tests. To make the initialization expression you would need to use reflection to find out what properties/fields there are and what their current values are. If you have nested objects, you'll need to take care of those too.
An alternative, if you go the ReSharper route, is to generate some sort of ToInit() method. You would need to make these individually for each of the classes you need. This is rather easy using ReSharper's generator infrastructure. Feel free to ping me (skype:dmitri.nesteruk) if you need help with this.
The other alternative is to simply hand-craft such methods, for example:
public static string ToAssemblyCode(this DateTime self)
{
var sb = new StringBuilder("new System.DateTime(");
sb.AppendFormat("{0},{1},{2}", self.Year, self.Month, self.Day);
if (self.Hour != 0 || self.Minute != 0 || self.Second != 0)
sb.AppendFormat(",{0},{1},{2}", self.Hour, self.Minute, self.Second);
if (self.Millisecond != 0)
sb.AppendFormat(",{0}", self.Millisecond);
sb.Append(")");
return sb.ToString();
}
You can try use IntelliDebugger plugin for Visaul Studio to create snapshot of any variable during debugging. The IntelliDebugger allows you to save and then to compare object with other objects of same type.
Desired object is stored in XML-format on disk (<YourSolution>\_IntelliDebugger.<YourSolution>\ExpressionSnapshots folder). I designed this feature to compare the state of objects during debugging. Perhaps it will be useful for writing unit-test or we can improve it for this case.
Note: IntelliDebugger is currently in beta and have limitations. We are open to any questions and feature requests to make it more effective for you.

How to use IProjectionBuffer in MEF without creating editor instance?

I am trying to create a Visual Studio extension which handles a multi-language content type. Much like some mvc-templates and Django or ASP.NET which a certain part of the code is in another language.
I know that I should use Projection and I already checked Django for Visual Studio extension but the solution there includes creating a Language Service and going to the trouble of creating all bits and pieces related to a code editor. Here I am trying to achieve the same goal just by using MEF.
I know that you can use IProjectionBuffer CreateProjectionBuffer() to create a projection but the question is how to replace the current TextBuffer with the created one and when is the best time to do it.
Also one may expect that if he specifies a base definition of type "projection" like this:
[Export]
[Name("Whatever")]
[BaseDefinition("code")]
[BaseDefinition("projection")]
internal static ContentTypeDefinition WhateverContentType = null;
the received TextBuffer in providers to be of type IProjectionBuffer (after all IProjectionBuffer is inherited from ITextBuffer). Which are not and it seems that a projection base definition has no effect what so ever.
So if I want to rephrase my question in a tldr version:
How and when do you apply an IProjectionBuffer to current view (using MEF and without creating an editor instance)?
So if I understand your question correctly, the answer is "you don't." A IWpfTextView is bound to a implementation of ITextBuffer (or a derived type, like IProjectionBuffer) at creation time, and can't be changed. Even if you could, many other extensions and language services would be most surprised by this and would probably crash.
To address your second question about content types: simply declaring you have a base content type of "projection" doesn't make you a projection buffer. All that really states is you might be creating projection buffers of that type, and when you do you want some extra ITagger support so taggers project through to the source buffers as you might expect them to.

Changing workflow IF-conditions from a string runtime

I want to be able to change the condition statement of a WF4 Workflow If-Activtity runtime, where the input comes from some sort of user interface as a string. I have read up on how to change a Workflow dynamically, or how to create Activites from code - the problem comes when I get to the point of assigning the Condition-property to the If-activity class. My source is a string. The constructor does not take a string.
Do I have to convert the string to an Expression<bool> first? How do I do that?
This is the string I want to expose
Note: I realize there may be other ways to accomplish what I want, like (1) create code that alters the XAML of the Workflow instead of the objects, or (2) exposing the entire Workflow editor to the end user. Before I go down that road, I want to know if it is possible to do it my way.
You can use a expression like
new VisualBasicValue<bool>("Person.Gender = \"Male\"")
A warning: The Apply Workflow Changes to Workflows you are pointing to is about WF3 and has no bearing in WF4 whatsoever. With WF4 there is no possibility to dynamically change a running workflow instance. That capability is going to be added in the .NET 4.5 framework.

How can I build a friendly nosql ORM without polluting the global scope?

For a while, I've been working on building a little Ruby library to interface with CouchDB, a neat little document database with a HTTP interface. Key features are:
document objects are glorified hashes
the JavaScript Map/Reduce functions are written in native Ruby, and parsed into JavaScript using S Expressions
you can interface with multiple Couch databases
it should integrate well with micro-frameworks like Camping
I want to be able to do something like this:
#recipes = Recipes.all
Where "Recipes" is a class defining a couple of required keys that the document has (the class name is automatically used as a "kind" key).
But then in tough times I might want to do something like this:
#recipes.each do |recipe|
recipe.cost = "too much!!"
recipe.push!
end
Now, obviously to be able to "push" like that, I either need the database to be.. somewhere in scope.. or for the document object itself to hold a reference to the database object? How is this done in well-established ORMs like ActiveRecord?
I don't want to have to do, you know, recipe.push!(#couch_database_object), or whatever, because that's yucky! But I don't wan to be some scope-polluting scumbag.
Any advice?

Resources