Search Results

Search found 22139 results on 886 pages for 'security testing'.

Page 49/886 | < Previous Page | 45 46 47 48 49 50 51 52 53 54 55 56  | Next Page >

  • .net mvc2 custom HtmlHelper extension unit testing

    - by alex
    My goal is to be able to unit test some custom HtmlHelper extensions - which use RenderPartial internally. http://ox.no/posts/mocking-htmlhelper-in-asp-net-mvc-2-and-3-using-moq I've tried using the method above to mock the HtmlHelper. However, I'm running into Null value exceptions. "Parameter name: view" Anyone have any idea?? Thanks. Below are the ideas of the code: [TestMethod] public void TestMethod1() { var helper = CreateHtmlHelper(new ViewDataDictionary()); helper.RenderPartial("Test"); // supposingly this line is within a method to be tested Assert.AreEqual("test", helper.ViewContext.Writer.ToString()); } public static HtmlHelper CreateHtmlHelper(ViewDataDictionary vd) { Mock<ViewContext> mockViewContext = new Mock<ViewContext>( new ControllerContext( new Mock<HttpContextBase>().Object, new RouteData(), new Mock<ControllerBase>().Object), new Mock<IView>().Object, vd, new TempDataDictionary(), new StringWriter()); var mockViewDataContainer = new Mock<IViewDataContainer>(); mockViewDataContainer.Setup(v => v.ViewData) .Returns(vd); return new HtmlHelper(mockViewContext.Object, mockViewDataContainer.Object); }

    Read the article

  • Unit Testing: hard dependency MessageBox.Show()

    - by Sean B
    What ways can the SampleConfirmationDialog be unit tested? The SampleConfirmationDialog would be exercised via acceptance tests, however how could we unit test it, seeing as MessageBox is not abstract and no matching interface? public interface IConfirmationDialog { /// <summary> /// Confirms the dialog with the user /// </summary> /// <returns>True if confirmed, false if not, null if cancelled</returns> bool? Confirm(); } /// <summary> /// Implementation of a confirmation dialog /// </summary> public class SampleConfirmationDialog : IConfirmationDialog { /// <summary> /// Confirms the dialog with the user /// </summary> /// <returns>True if confirmed, false if not, null if cancelled</returns> public bool? Confirm() { return MessageBox.Show("do operation x?", "title", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes; } }

    Read the article

  • Unit testing JSPs

    - by Avi Y
    Hi, I would like to ask you what technologies exist out there for creating unit tests for JSPs. I am already aware of the HtmlUnit/HttpUnit/JWebUnit/Selenium possibilities. Thank you!

    Read the article

  • Unit testing DTS packages

    - by fede
    Hi, does anybody have any experience writing unit tests for sql server 2000 DTS packages? I about to start working with DTS and jobs, so I want to be able to unit test as much as possible. I guess i could invoke dtsrun.exe via command line , but perhaps someone else has better ideas. Thanks Fede

    Read the article

  • Rails Testing Question

    - by Steve
    Hi, I am trying to test a functionality, which inserts few details into the DB. In the test.log, it shows the insert command that is generated and also the log messages that I have placed to show the progress and everything seems to be working fine except the actual data is not getting inserted into the DB. I am checking whether data is inserted in db/test.sqlite3. No exception is generated when the test cases are run. Is there a setting, which I have to set inorder to insert data into the test DB? or am i missing anything else Thanks

    Read the article

  • Android Unit Testing - Resolution & Verification Problems

    - by Bill
    I just switched the way my Android project is being built and non of my unit tests work any more...I get errors like WARN/dalvikvm(575): VFY: unable to resolve static field X in ..... WARN/dalvikvm(575): VFY: unable to find class referenced in signature These errors only come from my Unit Tests, where classes defined in it can't even see other classes defined in the unit test. Before each project had its own directory with copies of the 3rd party jar files. I've read around that Dex does weird things with references but haven't been able to figure out how to fix this problem. Is there a better way to do this? I would love to see an example of a large Android workspace where there are multiple projects, jar references, etc... Is it possible to fix this with an Order/Export tweak ? The project is structured like this: Eclipse Workspace (PROJECT_HOME classpath variable) lib 3rd-party jars android.jar Java Project A Looks in PROJECT_HOME Java Project B Looks in PROJECT_HOME Depends on project A Android Project Depends on A & B Looks in PROJECT_HOME Android Test Project Depends on A , B, Android Project Looks in PROJECT_HOME

    Read the article

  • Python: Time a code segment for testing performance (with timeit)

    - by Mestika
    Hi, I've a python script which works just as it should but I need to write the time for the execution. I've gooled that I should use timeit but I can't seem to get it to work. My Python script looks like this: import sys import getopt import timeit import random import os import re import ibm_db import time from string import maketrans myfile = open("results_update.txt", "a") for r in range(100): rannumber = random.randint(0, 100) update = "update TABLE set val = %i where MyCount >= '2010' and MyCount < '2012' and number = '250'" % rannumber #print rannumber conn = ibm_db.pconnect("dsn=myDB","usrname","secretPWD") for r in range(5): print "Run %s\n" % r ibm_db.execute(query_stmt) query_stmt = ibm_db.prepare(conn, update) myfile.close() ibm_db.close(conn) What I need it the time it takes the execution of the query and written to the file "results_update.txt". The purpose is to test an update statement for my database with different indexes and tuning mechanisms. Sincerely Mestika

    Read the article

  • Unit Testing VS 2008 Using Excel

    - by David
    When using Excel (2003) to provide data for my unit tests it seems to think that when a cell has TRUE / FALSE value that it is null when there has been no preceding cell values e.g. if (TestContext.DataRow["SatisfactionExtremelySatisfied"] != DBNull.Value) model.SatisfactionExtremelySatisfied = (bool)TestContext.DataRow ["SatisfactionExtremelySatisfied"]; Sample Excel Data DataRow SatisfactionExtremelySatisfied 0 1 2 TRUE 3 TRUE When reading the test data using OLEDB the cells with TRUE hold no value but when the preceding cells have the value FALSE entered it correctly gets the values TRUE. Am I missing something?

    Read the article

  • Problem with routes in functional testing

    - by Wishmaster
    Hi, I'm making a simple test project to prepare myself for my test. I'm fairly new to nested resources, in my example I have a newsitem and each newsitem has comments. The routing looks like this: resources :comments resources :newsitems do resources :comments end I'm setting up the functional tests for comments at the moment and I ran into some problems. This will get the index of the comments of a newsitem. @newsitem is declared in the setup ofc. test "should get index" do get :index,:newsitem_id => @newsitem assert_response :success assert_not_nil assigns(:newsitem) end But the problem lays here, in the "should get new". test "should get new" do get new_newsitem_comment_path(@newsitem) assert_response :success end I'm getting the following error. ActionController::RoutingError: No route matches {:controller=>"comments", :action=>"/newsitems/1/comments/new"} But when I look into the routes table, I see this: new_newsitem_comment GET /newsitems/:newsitem_id/comments/new(.:format) {:action=>"new", :controller=>"comments"} Can't I use the name path or what I'm doing wrong here? Thanks in advance.

    Read the article

  • Unit Testing Interfaces in Python

    - by Nicholas Mancuso
    I am currently learning python in preperation for a class over the summer and have gotten started by implementing different types of heaps and priority based data structures. I began to write a unit test suite for the project but ran into difficulties into creating a generic unit test that only tests the interface and is oblivious of the actual implementation. I am wondering if it is possible to do something like this.. suite = HeapTestSuite(BinaryHeap()) suite.run() suite = HeapTestSuite(BinomialHeap()) suite.run() What I am currently doing just feels... wrong (multiple inheritance? ACK!).. class TestHeap: def reset_heap(self): self.heap = None def test_insert(self): self.reset_heap() #test that insert doesnt throw an exception... for x in self.inseq: self.heap.insert(x) def test_delete(self): #assert we get the first value we put in self.reset_heap() self.heap.insert(5) self.assertEquals(5, self.heap.delete_min()) #harder test. put in sequence in and check that it comes out right self.reset_heap() for x in self.inseq: self.heap.insert(x) for x in xrange(len(self.inseq)): val = self.heap.delete_min() self.assertEquals(val, x) class BinaryHeapTest(TestHeap, unittest.TestCase): def setUp(self): self.inseq = range(99, -1, -1) self.heap = BinaryHeap() def reset_heap(self): self.heap = BinaryHeap() class BinomialHeapTest(TestHeap, unittest.TestCase): def setUp(self): self.inseq = range(99, -1, -1) self.heap = BinomialHeap() def reset_heap(self): self.heap = BinomialHeap() if __name__ == '__main__': unittest.main()

    Read the article

  • How can unit testing make parameter validation redundant?

    - by Johann Gerell
    We have a convention to validate all parameters of constructors and public functions/methods. For mandatory parameters of reference type, we mainly check for non-null and that's the chief validation in constructors, where we set up mandatory dependencies of the type. The number one reason why we do this is to catch that error early and not get a null reference exception a few hours down the line without knowing where or when the faulty parameter was introduced. As we start transitioning to more and more TDD, some team members feel the validation is redundant. Uncle Bob, who is a vocal advocate of TDD, strongly advices against doing parameter validation. His main argument seems to be "I have a suite of unit tests that makes sure everything works". But I can for the life of it just not see in what way unit tests can prevent our developers from calling these methods with bad parameters in production code. Please, unit testers out there, if you could explain this to me in a rational way with concrete examples, I'd be more than happy to seize this parameter validation!

    Read the article

  • Unit testing task queues in AppEngine

    - by Swizec Teller
    For a very long time now I've been using task queues on AppEngine to schedule tasks, just the way I'm supposed to. But what I've always been wondering is how does one write tests for that? Until now I've simply made tests to make sure an error doesn't occur on the API that queues a task and then wrote the more proper tests for the API executing the task. However lately I've started feeling a bit unsatisfied by this and I'm searching for a way to actually test that the correct task has been added to the correct queue. Hopefully this can be done better than simply by deploying the code and hoping for the best. I'm using django-nonrel, if that has any bearing on the answer. To recap: How can a unit test be written to confirm tasks have been queued?

    Read the article

  • Unit testing directory structure

    - by zachary
    Huge project tons of classes and directories. Do I make my unit test project mirror these directories or do I put them all at the root directory? Somewhat annoying to have to make directory changes and class name changes twice.

    Read the article

  • Unit-testing a directive with isolated scope and bidirectional value

    - by unludo
    I want to unit test a directive which looks like this: angular.module('myApp', []) .directive('myTest', function () { return { restrict: 'E', scope: { message: '='}, replace: true, template: '<div ng-if="message"><p>{{message}}</p></div>', link: function (scope, element, attrs) { } }; }); Here is my failing test: describe('myTest directive:', function () { var scope, compile, validHTML; validHTML = '<my-test message="message"></my-test>'; beforeEach(module('myApp')); beforeEach(inject(function($compile, $rootScope){ scope = $rootScope.$new(); compile = $compile; })); function create() { var elem, compiledElem; elem = angular.element(validHTML); compiledElem = compile(elem)(scope); scope.$digest(); return compiledElem; } it('should have a scope on root element', function () { scope.message = 'not empty'; var el = create(); console.log(el.text()); expect(el.text()).toBeDefined(); expect(el.text()).not.toBe(''); }); }); Can you spot why it's failing? The corresponding jsFiddle Thanks :)

    Read the article

  • Testing stored procedures

    - by giri
    Hi , How to test procedures with record type parameters.I have a procedure which takes test_ap ,basic and user_name as inputs.where test_ap is of record/row type,basic record array type and user_name charater varying. I need to test the procedure in pgadmin. test_client(test_ap test_base, basic test_base_detail[], user_name character varying) Any suggestions plz.

    Read the article

  • Unit testing nested subflows (subflows of subflows)

    - by snusmumrik
    I'm trying to write unit test for a flow, which has subflow, which, itself, has another subflow. I register first flow using FlowDefinitionResource getResource(FlowDefinitionResourceFactory resourceFactory). Then I register subflow definitions during test execution in FlowDefinitionRegistry before transitioning to them. Transitioning to "first level" subflow goes ok. The result of transitioning to subflow of current subflow - NoSuchFlowDefinitionException. The problem is that subflow definitions are all seem attached to the primary flow of the test and subflow can't be found within another subflow. Is there any way to attach subflow definition to another subflow in tests, which extend AbstractXmlFlowExecutionTests?

    Read the article

  • Grails unit testing and bootstrap

    - by tbruyelle
    I wrote an unit test for a controller. I have a Bootstrap file which alter the metaclass of domain classes by adding a method asPublicMap(). I use this method in the controller to return domain classes as json but only some selected public fields. My unit test failed because of MissingMethodException for asPublicMap(). As I understood, bootstrap classes are not loaded for unit tests, only for integration tests. That's why I got this error. My question is : Is there another place to put metaclass manipulation in order to take them into account during unit tests ?

    Read the article

  • Testing variable types in Python

    - by Jasper
    Hello, I'm creating an initialising function for the class 'Room', and found that the program wouldn't accept the tests I was doing on the input variables. Why is this? def __init__(self, code, name, type, size, description, objects, exits): self.code = code self.name = name self.type = type self.size = size self.description = description self.objects = objects self.exits = exits #Check for input errors: if type(self.code) != type(str()): print 'Error found in module rooms.py!' print 'Error number: 110' elif type(self.name) != type(str()): print 'Error found in module rooms.py!' print 'Error number: 111' elif type(self.type) != type(str()): print 'Error found in module rooms.py!' print 'Error number: 112' elif type(self.size) != type(int()): print 'Error found in module rooms.py!' print 'Error number: 113' elif type(self.description) != type(str()): print 'Error found in module rooms.py!' print 'Error number: 114' elif type(self.objects) != type(list()): print 'Error found in module rooms.py!' print 'Error number: 115' elif type(self.exits) != type(tuple()): print 'Error found in module rooms.py!' print 'Error number: 116' When I run this I get this error: Traceback (most recent call last): File "/Users/Jasper/Development/Programming/MyProjects/Game Making Challenge/Europa I/rooms.py", line 148, in <module> myRoom = Room(101, 'myRoom', 'Basic Room', 5, '<insert description>', myObjects, myExits) File "/Users/Jasper/Development/Programming/MyProjects/Game Making Challenge/Europa I/rooms.py", line 29, in __init__ if type(self.code) != type(str()): TypeError: 'str' object is not callable

    Read the article

  • Unit testing a functions whose purposes is side effects

    - by David
    How would you unit test do_int_to_string_conversion? #include <string> #include <iostream> void do_int_to_string_conversion(int i, std::string& s) { switch(i) { case 1: s="1"; break; case 2: s="2"; break; default: s ="Nix"; } std::cout << s << "\n"; } int main(int argc, char** argv){ std::string little_s; do_int_to_string_conversion(1, little_s); do_int_to_string_conversion(2, little_s); do_int_to_string_conversion(3, little_s); }

    Read the article

  • Strategies for testing reactive, asynchronous code

    - by Arne
    I am developing a data-flow oriented domain-specific language. To simplify, let's just look at Operations. Operations have a number of named parameters and can be asked to compute their result using their current state. To decide when an Operation should produce a result, it gets a Decision that is sensitive to which parameter got a value from who. When this Decision decides that it is fulfilled, it emits a Signal using an Observer. An Accessor listens for this Signal and in turn calls the Result method of the Operation in order to multiplex it to the parameters of other Operations. So far, so good, nicely decoupled design, composable and reusable and, depending on the specific Observer used, as asynchronous as you want it to be. Now here's my problem: I would love to start coding actual Tests against this design. But with an asynchronous Observer... how should I know that the whole signal-and-parameters-plumbing worked? Do I need to use time outs while waiting for a Signal in order to say that it was emitted successfully or not? How can I be, formally, sure that the Signal will not be emitted if I just wait a little longer (halting problem? ;-)) And, how can I be sure that the Signal was emitted because it was me who set a parameter, and not another Operation? It might well be that my test comes to early and sees a Signal that was emitted way before my setting a parameter caused a Decision to emit it. Currently, I guess the trivial cases are easy to test, but as soon as I want to test complex many-to-many - situations between operations I must resort to hoping that the design Just Works (tm)...

    Read the article

  • C# InternalsVisibleTo() attribute for VBNET 2.0 while testing?

    - by Will Marcouiller
    I'm building an Active Directory wrapper in VBNET 2.0 (can't use later .NET) in which I have the following: IUtilisateur IGroupe IUniteOrganisation These interfaces are implemented in internal classes (Friend in VBNET), so that I want to implement a façade in order to instiate each of the interfaces with their internal classes. This will allow the architecture a better flexibility, etc. Now, I want to test these classes (Utilisateur, Groupe, UniteOrganisation) in a different project within the same solution. However, these classes are internal. I would like to be able to instantiate them without going through my façade, but only for these tests, nothing more. Here's a piece of code to illustrate it: public static class DirectoryFacade { public static IGroupe CreerGroupe() { return new Groupe(); } } // Then in code, I would write something alike: public partial class MainForm : Form { public MainForm() { IGroupe g = DirectoryFacade.CreerGroupe(); // Doing stuff with instance here... } } // My sample interface: public interface IGroupe { string Domaine { get; set; } IList<IUtilisateur> Membres { get; } } internal class Groupe : IGroupe { private IList<IUtilisateur> _membres; internal Groupe() { _membres = new List<IUtilisateur>(); } public string Domaine { get; set; } public IList<IUtilisateur> Membres { get { return _membres; } } } I heard of InternalsVisibleTo() attribute, recently. I was wondering whether it is available in VBNET 2.0/VS2005 so that I could access the assmebly's internal classes for my tests? Otherwise, how could I achieve this?

    Read the article

< Previous Page | 45 46 47 48 49 50 51 52 53 54 55 56  | Next Page >