Search Results

Search found 3 results on 1 pages for 'theomax'.

Page 1/1 | 1 

  • Unit testing and Test Driven Development questions

    - by Theomax
    I'm working on an ASP.NET MVC website which performs relatively complex calculations as one of its functions. This functionality was developed some time ago (before I started working on the website) and defects have occurred whereby the calculations are not being calculated properly (basically these calculations are applied to each user which has certain flags on their record etc). Note; these defects have only been observed by users thus far, and not yet investigated in code while debugging. My questions are: Because the existing unit tests all pass and therefore do not indicate that the defects that have been reported exist; does this suggest the original code that was implemented is incorrect? i.e either the requirements were incorrect and were coded accordingly or just not coded as they were supposed to be coded? If I use the TDD approach, would I disgregard the existing unit tests as they don't show there are any problems with the calculations functionality - and I start by making some failing unit tests which test/prove there are these problems occuring, and then add code to make them pass? Note; if it's simply a bug that is occurring that can be found while debugging the code, do the unit tests need to be updated since they are already passing?

    Read the article

  • Need help understanding Mocks and Stubs

    - by Theomax
    I'm new to use mocking frameworks and I have a few questions on the things that I am not clear on. I'm using Rhinomocks to generate mock objects in my unit tests. I understand that mocks can be created to verify interactions between methods and they record the interactions etc and stubs allow you to setup data and entities required by the test but you do not verify expectations on stubs. Looking at the recent unit tests I have created, I appear to be creating mocks literally for the purpose of stubbing and allowing for data to be setup. Is this a correct usage of mocks or is it incorrect if you're not actually calling verify on them? For example: user = MockRepository.GenerateMock<User>(); user.Stub(x => x.Id = Guid.NewGuid()); user.Stub(x => x.Name = "User1"); In the above code I generate a new user mock object, but I use a mock so I can stub the properties of the user because in some cases if the properties do not have a setter and I need to set them it seems the only way is to stub the property values. Is this a correct usage of stubbing and mocking? Also, I am not completely clear on what the difference between the following lines is: user.Stub(x => x.Id).Return(new Guid()); user.Stub(x => x.Id = Guid.NewGuid());

    Read the article

  • Is passing the Model around in this way considered bad practice?

    - by Theomax
    If I have a view called, for example, ViewDetails that displays user information in labels and has a Model called ViewDetailsModel and if I want to allow the user to click a button to edit some of these details, is it considered bad practice is I pass the entire Model in the markup to a controller method which then assigns the values for another model, using the values stored in the Model that was passed in as a parameter to that action method? If so, should there instead be a service method that gets the data required for the edit view? For example: In the ViewDetails view, the user clicks the edit button which calls an action method in the controller (and passes in the Model object). The action method then uses the data in the Model object to populate another model which will be used for the EditDetails view that will be returned.

    Read the article

1