Search Results

Search found 2240 results on 90 pages for 'assert redirected to'.

Page 7/90 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • Is It bad for SEO to have internal redirected links? [closed]

    - by Jonas Lindqvist
    I have a large number of pages having similar but not identical content. Example: site.com/dream_dictionary_flying and site.com/dream_interpretation_flying. The problem is that although not being identical, they are sometimes on the edge of being duplicate content. The solution via redirect 301 in htaccess is simple and can be done in a minute, BUT, changing all existing links on the whole site from "/something" to "/something_else" would take ages, it would be thousands of manual changes taking x hundreds of hours. My question is this; is it bad for SEO to have internal links that are redirected, or rather HOW bad is it? For the human user it would not matter at all but from what I have experienced, the search engines don't like it. Is there any rule of thumb here? Please come back with your thoughts and experience on this. Thanks!

    Read the article

  • When should assertions stay in production code?

    - by Carl Seleborg
    Hi all, There's a discussion going on over at comp.lang.c++.moderated about whether or not assertions, which in C++ only exist in debug builds by default, should be kept in production code or not. Obviously, each project is unique, so my question here is not so much whether assertions should be kept, but in which cases this is recommendable/not a good idea. By assertion, I mean: A run-time check that tests a condition which, when false, reveals a bug in the software. A mechanism by which the program is halted (maybe after really minimal clean-up work). I'm not necessarily talking about C or C++. My own opinion is that if you're the programmer, but don't own the data (which is the case with most commercial desktop applications), you should keep them on, because a failing asssertion shows a bug, and you should not go on with a bug, with the risk of corrupting the user's data. This forces you to test strongly before you ship, and makes bugs more visible, thus easier to spot and fix. What's your opinion/experience? Cheers, Carl See related question here

    Read the article

  • How to generate a stacktrace when my gcc C++ app crashes

    - by KPexEA
    When my c++ app crashes I would like to generate a stacktrace. I already asked this but I guess I needed to clarify my needs. My app is being run by many different users and it also runs on Linux, Windows and Macintosh ( all versions are compiled using gcc ). I would like my program to be able to generate a stack trace when it crashes and the next time the user run's it, it will ask them if it is ok to send the stack trace to me so I can track down the problem. I can handle the sending the info to me but I don't know how to generate the trace string. Any ideas?

    Read the article

  • [Zend] phpUnit - assertQuery fails with

    - by Rosina Bignall
    I am having trouble with an assertQuery(). In the html I have (verified by outputting the body) <input type="text" name="LASTNAME" id="LASTNAME" value="" maxlength="25" size="20" /> So I wrote a query for it to test to make sure this element exists and that the value is empty $this->assertQuery('input#LASTNAME[value=""]', 1); PhpUnit says the assertion fails Failed asserting node DENOTED BY input#LASTNAME[value=""] EXISTS Can you give me some insight into why this assertion fails and how to write it properly? Thanks in advance!

    Read the article

  • Roaming Profiles & Redirected Folders - storage consumption? offline files and caching?

    - by Ben Swinburne
    I understand the concepts of both roaming profiles and folder redirection and have used both separately before. I am about to set up a network from scratch and would ideally like to use both for the following reasons primarily Roaming profiles allow users to log on to any machine and have their profile Redirected profiles allow users to have their My Documents and Desktop etc backed up without the need to log off at the end of the day. The servers can run their backups overnight and there are no missing files due to the user not logging off. Redirected profiles largely alleviate the slow log in times caused by large profiles. My question is if some of the folders are redirected and therefore not part of the roaming profile what happens on machines which truly roam (i.e. laptops)? If there's offline files or a cache does this mean that the problem whereby a user has to log off comes back? By having them both enabled, is there any duplication i.e. if I have a users$ share and a profiles$ share would I have Desktop twice for example?

    Read the article

  • Test assertions for tuples with floats

    - by Space_C0wb0y
    I have a function that returns a tuple that, among others, contains a float value. Usually I use assertAlmostEquals to compare those, but this does not work with tuples. Also, the tuple contains other data-types as well. Currently I am asserting every element of the tuple individually, but that gets too much for a list of such tuples. Is there any good way to write assertions for such cases?

    Read the article

  • Another problem with decltype

    - by There is nothing we can do
    template<class IntT, IntT low = IntT(), IntT high = IntT()> struct X { static_assert(std::is_same<decltype(low),decltype(high)>::value,"Different types not allowed");//this should give error if types are different decltype(low) a; decltype(high) b; X():a(decltype(a)()),b(decltype(b)())//WHY THIS DOES NOT COMPILE? { cout << typeid(a).name() << '\n'; cout << typeid(b).name() << '\n'; } }; int _tmain(int argc, _TCHAR* argv[]) { X<char,1,'a'> x;//this according to static_assert shouldn't compile but it does return 0; } Using VS2010. Please see 3 comments in code above.

    Read the article

  • Debug.Assert has locked / hung my IIS6 site - how do I bring it back?

    - by George
    I'm running some C# / ASP.net code on an IIS6 server. The code has triggered a "Debug.Assert", and now my IIS6 server is not responding for this site — at least that's what I strongly suspect given that this was the cause the last time this happened. How do I bring the site back up? Stopping and then starting the site doesn't bring it back — I continue getting timeouts from the proxy, which I think is caused by the site itself crashing. How do I disable Debug.Assert permanently in production? Do I just edit the web.config: <compilation defaultLanguage="c#" debug="false"... — is there anything else I need to do?

    Read the article

  • Roaming Profile to act as a redirected folder? Dropbox in roaming profile is also causing slow login/logou

    - by user147069
    As title, what I'm wondering to know is .. if the roaming profile with Windows 2008 R2 Server (I'm talking about V2 profile - Windows7/Windows8) can work as a redirected folder (it can be done with the Desktop, Contacts, Download, AppData, My Documents). The roaming profile is copied at each login (server - client) and at each logout (client - server). This is causing slow login and logout for huge roaming profile. I can't stop the usage of roaming profile since the environment is a School with 1000 users. But I have big issues with users who populate the profile path (which is mapped on "User's File" under Windows7/8) with other stuff than the already redirected Desktop and My Document. A typical problem is given by the Dropbox folder... Any solution?

    Read the article

  • Selenium tests not building due to NUnit error (Mono+OS X)

    - by Jem
    I'm running Selenium RC on my Mac and driving my tests using NUnit in C#. My problem is that when I try and build a simple test in Mono I get the following error. Error CS0433: The imported type `NUnit.Framework.Assert' is defined multiple times (CS0433) (TestProject) When I comment out the Assert's it runs fine. The code I'm using currently is just a dump from the openqa site using System; using System.Text; using System.Text.RegularExpressions; using System.Threading; using NUnit.Framework; using Selenium; namespace SeleniumTests { [TestFixture] public class AllTests { private ISelenium selenium; private StringBuilder verificationErrors; [SetUp] public void SetupTest () { selenium = new DefaultSelenium ("localhost", 4444, "*safari", "http://www.google.co.uk"); selenium.Start (); verificationErrors = new StringBuilder (); } [TearDown] public void TeardownTest () { try { selenium.Stop (); } catch (Exception) { // Ignore errors if unable to close the browser } Assert.AreEqual ("", verificationErrors.ToString ()); } [Test] public void GoogleHomepageTests () { // Open Google search engine. selenium.Open ("http://www.google.com/"); // Assert Title of page. Assert.AreEqual ("Google", selenium.GetTitle ()); // Provide search term as "Selenium OpenQA" selenium.Type ("q", "Selenium OpenQA"); // Read the keyed search term and assert it. Assert.AreEqual ("Selenium OpenQA", selenium.GetValue ("q")); // Click on Search button. selenium.Click ("btnG"); // Wait for page to load. selenium.WaitForPageToLoad ("5000"); // Assert that "www.openqa.org" is available in search results. Assert.IsTrue (selenium.IsTextPresent ("www.openqa.org")); // Assert that page title is - "Selenium OpenQA - Google Search" Assert.AreEqual ("Selenium OpenQA - Google Search", selenium.GetTitle ()); } } } Any ideas? Is it a OSX/Mono thing?

    Read the article

  • What to do when using Contract.Assert(true) and the method must return something?

    - by devoured elysium
    I have a bit of code with the following logic: //pseudo-code foreach (element in elementList) { if (element is whatever) return element; } } In theory, there is always one element that is whatever, so this method should pose no problems. In any case, I've put an assertion on the end of the method just to be sure: //pseudo-code foreach (element in elementList) { if (element is whatever) return element; } } Contract.Assert(true, "Invalid state!"); The problem is that as this method has to return something, and the compiler doesn't understand that the assertion will break the program execution. Before using Contracts, in these kind of situations, I used to throw an Exception, which solved the problem. How would you handle this with Contract.Assert()? Returning null or default(element_type) after the Contract.Assert() call knowing it will never be called and shutting up the compiler? Or is there any other more elegant way of doing this? Thanks

    Read the article

  • How do i assert my exception message with JUNIT Test annotation ?

    - by Cshah
    i have written a few junits with @Test annotation. If my test method throws a checked exception and if i want to assert the message along with the exception, is there a way to do so with JUNIT @Test annotation.AFAIK, Junit 4.7 doesnt provide this feature but does any future versions provide it. I know in .NET you can assert the message and the exception class. Looking for similar feature in the java world. This is what i want @Test (expected = RuntimeException.class, message = "Employee ID is null") public void shouldThrowRuntimeExceptionWhenEmployeeIDisNull() { }

    Read the article

  • Exclamation mark used with assert method in its parameters.

    - by Maxsy
    Okay this has been lingering in my head for quite a while now. In ruby on rails unit testing there is an exclamation mark with the assert method. Here is an example test "No empty values to be inserted" do product = Produce.new assert !product.save end Let me know the function of the exclamation mark. Quick replies appreciated. Thanks.

    Read the article

  • Subdomain Is Redirected and Causing an Error Because www. is Added

    - by user532493
    On my site, say example.com, if I try to access test.example.com, Firefox automatically adds www. to test.example.com, making it www.test.example.com, which causes an error. However, if I visit a site like my.ebay.com, no www. is added so no error occurs. What's going on? Just in case, my .htaccess file is as follows: Options -Multiviews RewriteEngine On RewriteCond %{HTTP_HOST} ^example.com RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ $1.php I looked through Firebug and it seems like Firefox doesn't even make an attempt to reach test.example.com before reverting to www.test.example.com. One nuance I didn't realize until now. If I try to access the site using test.example.com/, the www. is added. If however that trailing slash is not there, then I am sent to the subdomain properly.

    Read the article

  • Java - How to find the redirected url of a url?

    - by Yatendra Goel
    I am accessing web pages through java as follows: URLConnection con = url.openConnection(); But in some cases, a url redirects to another url. So I want to know the url to which the previous url redirected. Below are the header fields that I got as a response: null-->[HTTP/1.1 200 OK] Cache-control-->[public,max-age=3600] last-modified-->[Sat, 17 Apr 2010 13:45:35 GMT] Transfer-Encoding-->[chunked] Date-->[Sat, 17 Apr 2010 13:45:35 GMT] Vary-->[Accept-Encoding] Expires-->[Sat, 17 Apr 2010 14:45:35 GMT] Set-Cookie-->[cl_def_hp=copenhagen; domain=.craigslist.org; path=/; expires=Sun, 17 Apr 2011 13:45:35 GMT, cl_def_lang=en; domain=.craigslist.org; path=/; expires=Sun, 17 Apr 2011 13:45:35 GMT] Connection-->[close] Content-Type-->[text/html; charset=iso-8859-1;] Server-->[Apache] So at present, I am constructing the redirected url from the value of the Set-Cookie header field. In the above case, the redirected url is copenhagen.craigslist.org Is there any standard way through which I can determine which url the particular url is going to redirect. I know that when a url redirects to other url, the server sends an intermediate response containing a header field that tells the url which it is going to redirect but I am not receiving that intermediate response through the url.openConnection(); method.

    Read the article

  • Symfony2 bindrequest error

    - by user1321109
    namespace Topxia\LiftBundle\Form; use Symfony\Component\Validator\Constraint as Assert; class AddUser { /** * @Assert\NotBlank(message="???????") */ public $username; /** * @Assert\NotBlank(message="????????") */ public $name; /** * @Assert\NotBlank(message="??????") * @Assert\MinLength(limit=4,message="?????") * @Assert\MaxLength(limit=24,message="?????") */ public $password; /** * @Assert\NotBlank(message="??????") */ public $rpassword; /** * @Assert\NotBlank(message="???????") * @Assert\Email(message="???????") */ public $email; /** * @Assert\NotBlank(message="k3????????") */ public $num; /** * @Assert\NotBlank() * @Assert\Choice({"0", "1", "2", "3", "4"}) */ public $roles; public $changePassword; } namespace Topxia\LiftBundle\Form; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilder; class AddUserType extends AbstractType{ public function buildForm(FormBuilder $builder, array $options){ $builder->add('username', 'text', array('label' => '????')); $builder->add('name', 'text', array('label' => '???')); $builder->add('password', 'password', array('label' => '??')); $builder->add('rpassword', 'password', array('label' => '????')); $builder->add('email', 'email', array('label' => '??')); $builder->add('num', 'text', array('label' => 'K3????')); $builder->add('roles', 'choice', array('label' => '???', 'multiple' => false, 'expanded' => true, 'choices' => array( '0' => '?????', '1' => '?????', '2' => '?????', '3' => '???', '4' => '???' ), )); $builder->add('changePassword', 'checkbox', array('label' => '??????', 'value' => '1')); } public function getName(){ return 'add_user'; } } when i use $form-bindRequest($request); in conctollor there is an error : [Semantical Error] The annotation "@Symfony\Component\Validator\Constraint\NotBlank" in property Topxia\LiftBundle\Form\AddUser::$username does not exist, or could not be auto-loaded. 500 Internal Server Error - AnnotationException I have no idea about this. Thanks

    Read the article

  • Redirected to piratenpartji.nl. What can I do?

    - by Luke
    a few hours ago, I found a link to Kickass Torrent, which is blocked in my country, Italy and went for it. The link worked just fine but wasn't able to save anything. I renounced and continued normal navigation. I then noticed that everytime I try to access some pages, for instance google.com (but not Google.it) I receive a warning from Chrome that I'm being redirected through piratenpartji.nl Since I found a similar topic here on 'superuser' I tried what was proposed in the solution, namely shutting down adblock and trying again or trying Incognito mode. Nevertheless, no result. I performed a search with both Avira and Spybot SD but except for a couple cookies from other origin nothing came up. What do you suggest I do? Thanks in advance, feel free to ask any info that might be necessary Luke

    Read the article

  • Why does a Remote Desktop Redirected Printer Doc appear every time I connect to Windows Server 2003 SBS?

    - by Jim Dagg
    I've run into a weird, persistent issue regarding a remote desktop connection. Every time I successfully log into a server running Windows Server 2003 SBS, without taking any further action, after a few seconds a print job spontaneously appears on my machine, titled "Remote Desktop Redirected Printer Doc". The document is 4K, datatype RAW, processor "WinPrint". I've heard of people running into this issue before, but can't seem to hunt down a coherent solution. It's a minor annoyance, but I get annoyed when Windows complains about a print job that, as far as I know, came from nowhere. Any thoughts on why this would occur and how I could prevent it from happening?

    Read the article

  • Why don't languages include implication as a logical operator?

    - by Maciej Piechotka
    It might be a strange question, but why there is no implication as a logical operator in many languages (Java, C, C++, Python Haskell - although as last one have user defined operators its trivial to add it)? I find logical implication much clearer to write (particularly in asserts or assert-like expressions) then negation with or: encrypt(buf, key, mode, iv = null) { assert (mode != ECB --> iv != null); assert (mode == ECB || iv != null); assert (implies(mode != ECB, iv != null)); // User-defined function }

    Read the article

  • Issue with a secure login - Why am I being redirected to the insecure login?

    - by mstrmrvls
    Im having some issues getting a website working at my place of work. The issue was rasised when a "double login" occurred from the secure login site. The second login was actually being prompted by the HTTP domain and not HTTPS. In essence the situation is like this: The user navigates to https://mysite.com/something The login prompt pops up Enter username and password The user is presented with ANOTHER login prompt (IE will say its insecure, and the address bar reflects that) If the user puts in their password the insecure one, they will login to the insecure site. if they hit cancel it will present them with a 401 page Navigating back to https://somesite.com/something will by pass the login prompt and log them in to the secure site automatically (cookie maybe) I'm a bit confused to why the user isnt being logged in properly the first time (redirected to non-ssl) but any consecutive login will be okay? I've been trying to use fiddler to see what is happening after the user puts in their password the first time and trying to get fiddler to automatically login to the site (with no luck) I believe the website in question is using Basic Digest authentication. Thanks for any help

    Read the article

  • Xunit: Perform all 'Assert'ions in one test method?

    - by Jörg Battermann
    Is it possible to tell xUnit.net to perform all e.g. Assert.True() in one test method? Basically in some of our use/testcases all assertions belong logically to one and the same 'scope' of tests and I have e.g. something like this: [Fact(DisplayName = "Tr-MissImpl")] public void MissingImplementationTest() { // parse export.xml file var exportXml = Libraries.Utilities.XML.GenericClassDeserializer.DeserializeXmlFile<Libraries.MedTrace.ExportXml>( ExportXmlFile); // compare parsed results with expected ones Assert.True(exportXml.ContainsRequirementKeyWithError("PERS_154163", "E0032A")); Assert.True(exportXml.ContainsRequirementKeyWithError("PERS_155763", "E0032A")); Assert.True(exportXml.ContainsRequirementKeyWithError("PERS_155931", "E0032A")); Assert.True(exportXml.ContainsRequirementKeyWithError("PERS_157145", "E0032A")); Assert.True(exportXml.ContainsRequirementKeyWithError("s_sw_ers_req_A", "E0032A")); Assert.True(exportXml.ContainsRequirementKeyWithError("s_sw_ers_req_C", "E0032A")); Assert.True(exportXml.ContainsRequirementKeyWithError("s_sw_ers_req_D", "E0032A")); } Now if e.g. the first Assert.True(...) fails, the other ones are not executed/checked. I'd rather not break these seven Assertions up into separate methods, since these really do belong together logically (the TC only is 'passed' entirely if all seven are passing all together).

    Read the article

  • Playing with aspx page cycle using JustMock

    - by mehfuzh
    In this post , I will cover a test code that will mock the various elements needed to complete a HTTP page request and  assert the expected page cycle steps. To begin, i have a simple enumeration that has my predefined page steps: public enum PageStep {     PreInit,     Load,     PreRender,     UnLoad } Once doing so, i  first created the page object [not mocking]. Page page = new Page(); Here, our target is to fire up the page process through ProcessRequest call, now if we take a look inside the method with reflector.net,  the call trace will go like : ProcessRequest –> ProcessRequestWithNoAssert –> SetInstrinsics –> Finallly ProcessRequest. Inside SetInstrinsics ,  it requires calls from HttpRequest, HttpResponse and HttpBrowserCababilities. Using this clue at hand, we can easily know the classes / calls  we need to mock in order to get through the expected call. Accordingly, for  HttpBrowserCapabilities our required mock code will look like: var browser = Mock.Create<HttpBrowserCapabilities>(); // Arrange Mock.Arrange(() => browser.PreferredRenderingMime).Returns("text/html"); Mock.Arrange(() => browser.PreferredResponseEncoding).Returns("UTF-8"); Mock.Arrange(() => browser.PreferredRequestEncoding).Returns("UTF-8"); Now, HttpBrowserCapabilities is get though [Instance]HttpRequest.Browser. Therefore, we create the HttpRequest mock: var request = Mock.Create<HttpRequest>(); Then , add the required get call : Mock.Arrange(() => request.Browser).Returns(browser); As, [instance]Browser.PerferrredResponseEncoding and [instance]Browser.PreferredResponseEncoding  are also set to the request object and to make that they are set properly, we can add the following lines as well [not required though]. bool requestContentEncodingSet = false; Mock.ArrangeSet(() => request.ContentEncoding = Encoding.GetEncoding("UTF-8")).DoInstead(() =>  requestContentEncodingSet = true); Similarly, for response we can write:  var response = Mock.Create<HttpResponse>();    bool responseContentEncodingSet = false;  Mock.ArrangeSet(() => response.ContentEncoding = Encoding.GetEncoding("UTF-8")).DoInstead(() => responseContentEncodingSet = true); Finally , I created a mock of HttpContext and set the Request and Response properties that will returns the mocked version. var context = Mock.Create<HttpContext>();   Mock.Arrange(() => context.Request).Returns(request); Mock.Arrange(() => context.Response).Returns(response); As, Page internally calls RenderControl method , we just need to replace that with our one and optionally we can check if  invoked properly: bool rendered = false; Mock.Arrange(() => page.RenderControl(Arg.Any<HtmlTextWriter>())).DoInstead(() => rendered = true); That’s  it, the rest of the code is simple,  where  i asserted the page cycle with the PageSteps that i defined earlier: var pageSteps = new Queue<PageStep>();   page.PreInit +=delegate { pageSteps.Enqueue(PageStep.PreInit); }; page.Load += delegate { pageSteps.Enqueue(PageStep.Load); }; page.PreRender += delegate { pageSteps.Enqueue(PageStep.PreRender);}; page.Unload +=delegate { pageSteps.Enqueue(PageStep.UnLoad);};   page.ProcessRequest(context);   Assert.True(requestContentEncodingSet); Assert.True(responseContentEncodingSet); Assert.True(rendered);   Assert.Equal(pageSteps.Dequeue(), PageStep.PreInit); Assert.Equal(pageSteps.Dequeue(), PageStep.Load); Assert.Equal(pageSteps.Dequeue(), PageStep.PreRender); Assert.Equal(pageSteps.Dequeue(), PageStep.UnLoad);   Mock.Assert(request); Mock.Assert(response); You can get the test class shown in this post here to give a try by yourself with of course JustMock :-). Enjoy!!

    Read the article

  • Mocking HttpContext with JustMock

    - by mehfuzh
    In post , i will show a test code that will mock the various elements needed to complete a HTTP page request and  assert the expected page cycle steps. To begin, i have a simple enumeration that has my predefined page steps: public enum PageStep {     PreInit,     Load,     PreRender,     UnLoad } Once doing so, i  first created the page object [not mocking]. Page page = new Page(); Here, our target is to fire up the page process though ProcessRequest call, now if we take a look inside method though reflector, we will find calls stack like : ProcessRequest –> ProcessRequestWithNoAssert –> SetInstrinsics –> Finallly ProcessRequest. Inside SetIntrinsics , where it requires calls from HttpRequest, HttpResponse and HttpBrowserCababilities. With this , we can easily know what are classes / calls  we need to mock in order to get though the expected call. Accordingly, for  HttpBrowserCapabilities our required test code will look like: Mock.Arrange(() => browser.PreferredRenderingMime).Returns("text/html"); Mock.Arrange(() => browser.PreferredResponseEncoding).Returns("UTF-8"); Mock.Arrange(() => browser.PreferredRequestEncoding).Returns("UTF-8"); Now, HttpBrowserCapabilities is get though [Instance]HttpRequest.Browser. Therefore, we create the HttpRequest mock: var request = Mock.Create<HttpRequest>(); Then , add the required get call : Mock.Arrange(() => request.Browser).Returns(browser); As, [instance]Browser.PerferrredResponseEncoding and [instance]Browser.PreferredResponseEncoding  are also set to the request object and to make that they are set properly, we can add the following lines as well [not required though]. bool requestContentEncodingSet = false; Mock.ArrangeSet(() => request.ContentEncoding = Encoding.GetEncoding("UTF-8")).DoInstead(() =>  requestContentEncodingSet = true); Similarly, for response we can write:  var response = Mock.Create<HttpResponse>();    bool responseContentEncodingSet = false;  Mock.ArrangeSet(() => response.ContentEncoding = Encoding.GetEncoding("UTF-8")).DoInstead(() => responseContentEncodingSet = true); Finally , I created a mock of HttpContext and set the Request and Response properties that will returns the mocked version. var context = Mock.Create<HttpContext>();   Mock.Arrange(() => context.Request).Returns(request); Mock.Arrange(() => context.Response).Returns(response); As, Page internally calls RenderControl method , we just need to replace that with our one and optionally we can check if  invoked properly: bool rendered = false; Mock.Arrange(() => page.RenderControl(Arg.Any<HtmlTextWriter>())).DoInstead(() => rendered = true); That’s  it, the rest of the code is simple,  where  i asserted the page cycle with the PageSteps that i defined earlier: var pageSteps = new Queue<PageStep>();    page.PreInit +=      delegate      {          pageSteps.Enqueue(PageStep.PreInit);      };  page.Load +=      delegate      {          pageSteps.Enqueue(PageStep.Load);      };    page.PreRender +=      delegate      {          pageSteps.Enqueue(PageStep.PreRender);      };    page.Unload +=      delegate      {          pageSteps.Enqueue(PageStep.UnLoad);      };    page.ProcessRequest(context);    Assert.True(requestContentEncodingSet);  Assert.True(responseContentEncodingSet);  Assert.True(rendered);    Assert.Equal(pageSteps.Dequeue(), PageStep.PreInit);  Assert.Equal(pageSteps.Dequeue(), PageStep.Load);  Assert.Equal(pageSteps.Dequeue(), PageStep.PreRender);  Assert.Equal(pageSteps.Dequeue(), PageStep.UnLoad);    Mock.Assert(request);  Mock.Assert(response);   You can get the test class shown in this post here to give a try by yourself with of course JustMock. Enjoy!!

    Read the article

  • Playing with http page cycle using JustMock

    - by mehfuzh
    In this post , I will cover a test code that will mock the various elements needed to complete a HTTP page request and  assert the expected page cycle steps. To begin, i have a simple enumeration that has my predefined page steps: public enum PageStep {     PreInit,     Load,     PreRender,     UnLoad } Once doing so, i  first created the page object [not mocking]. Page page = new Page(); Here, our target is to fire up the page process through ProcessRequest call, now if we take a look inside the method with reflector.net,  the call trace will go like : ProcessRequest –> ProcessRequestWithNoAssert –> SetInstrinsics –> Finallly ProcessRequest. Inside SetInstrinsics ,  it requires calls from HttpRequest, HttpResponse and HttpBrowserCababilities. With this clue at hand, we can easily know the classes / calls  we need to mock in order to get through the expected call. Accordingly, for  HttpBrowserCapabilities our required test code will look like: Mock.Arrange(() => browser.PreferredRenderingMime).Returns("text/html"); Mock.Arrange(() => browser.PreferredResponseEncoding).Returns("UTF-8"); Mock.Arrange(() => browser.PreferredRequestEncoding).Returns("UTF-8"); Now, HttpBrowserCapabilities is get though [Instance]HttpRequest.Browser. Therefore, we create the HttpRequest mock: var request = Mock.Create<HttpRequest>(); Then , add the required get call : Mock.Arrange(() => request.Browser).Returns(browser); As, [instance]Browser.PerferrredResponseEncoding and [instance]Browser.PreferredResponseEncoding  are also set to the request object and to make that they are set properly, we can add the following lines as well [not required though]. bool requestContentEncodingSet = false; Mock.ArrangeSet(() => request.ContentEncoding = Encoding.GetEncoding("UTF-8")).DoInstead(() =>  requestContentEncodingSet = true); Similarly, for response we can write:  var response = Mock.Create<HttpResponse>();    bool responseContentEncodingSet = false;  Mock.ArrangeSet(() => response.ContentEncoding = Encoding.GetEncoding("UTF-8")).DoInstead(() => responseContentEncodingSet = true); Finally , I created a mock of HttpContext and set the Request and Response properties that will returns the mocked version. var context = Mock.Create<HttpContext>();   Mock.Arrange(() => context.Request).Returns(request); Mock.Arrange(() => context.Response).Returns(response); As, Page internally calls RenderControl method , we just need to replace that with our one and optionally we can check if  invoked properly: bool rendered = false; Mock.Arrange(() => page.RenderControl(Arg.Any<HtmlTextWriter>())).DoInstead(() => rendered = true); That’s  it, the rest of the code is simple,  where  i asserted the page cycle with the PageSteps that i defined earlier: var pageSteps = new Queue<PageStep>();   page.PreInit +=      delegate      {          pageSteps.Enqueue(PageStep.PreInit);      }; page.Load +=      delegate      {          pageSteps.Enqueue(PageStep.Load);      };   page.PreRender +=      delegate      {          pageSteps.Enqueue(PageStep.PreRender);      };   page.Unload +=      delegate      {          pageSteps.Enqueue(PageStep.UnLoad);      };   page.ProcessRequest(context);    Assert.True(requestContentEncodingSet);  Assert.True(responseContentEncodingSet);  Assert.True(rendered);    Assert.Equal(pageSteps.Dequeue(), PageStep.PreInit);  Assert.Equal(pageSteps.Dequeue(), PageStep.Load);  Assert.Equal(pageSteps.Dequeue(), PageStep.PreRender);  Assert.Equal(pageSteps.Dequeue(), PageStep.UnLoad);    Mock.Assert(request);  Mock.Assert(response);   You can get the test class shown in this post here to give a try by yourself with of course JustMock :-).   Enjoy!!

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >