I've just started working with MVC in VS2012 and would like to develop unit tests while developing. What are the preferred standards or conventions for unit testing in this environment? I find that I prefer the 2010 environment for testing simply for the private accessor and easy test generation. My problem is I'm having a hard time deciding if I want to use mocking or constructor injection and which would lend to cleaner code. What are the preferences around here?
jchalfant
Posts
-
Starting unit testing with MVC -
Any book recomendations on Telerik?I just convinced the upper-ups to invest in the Telerik premium collection for its control toolkits. Does anyone have any recommendations for a book or set of books that cover the WPF controls for the current version?
-
Re-validating DataGrid after programmaticallychanging row sourceYou're right. I'm not using the validator as intended. There are plenty of things I can do in a cell data template to get my intended functionality. Thanks for the help. It didn't get me to my original goal, but illuminated the error of my ways and saved me time digging for an answer that doesn't exist.
-
Re-validating DataGrid after programmaticallychanging row sourceIt's an EF ComplexObject using the default auto generated code. It is derived from StructuralObject, which is derived from INotifyPropertyChanging and implements the INotifyPropertyChanged. I checked the Properties I'm changing and they all call the ReportPropertyChanged method after a change occurs. I think this has more to do with the way I'm updating the row source. I'm allowing the user to open a context menu through the ValidationErrorTemplate and select various options. The change occurs in the MenuItem click event. If I change focus to anything in the Window using the mouse, the row will validate.
-
Re-validating DataGrid after programmaticallychanging row sourceValidation in Windows Presentation Foundation[^] and http://msdn.microsoft.com/en-us/library/0c899ak8.aspx[^] were both good resources for custom validation rules on a DataGrid, but if I programmatically change values in the row source, the row doesn't re-validate. If I change a cell value by manually editing it, on the other hand, validation will fire. How can I force validation even when the user is not directly manipulating the cell? I have my custom validation rule ValidationStep set to CommittedValue and UpdatedValue. I've also tried BeginEdit and CommitEdit after changes are made. Any thoughts?
-
Sending email from ms Access using CDO , Problem ?CDO will work if you're only ever sending to a single address and you have your anti-virus/firewall configured to allow emails to be sent out originating from your computer; and if you allow spam from your origin address on the destination account. If you're looking to email end users with a non-static address, I recommend looking into other solutions.
-
Weird SQL Server 2005 Sybase interaction [modified]LOL! I've been saying the same thing for three years. Either I'll convince someone that we need to write our own application to replace this one, or hope the vendor moves away from this model.
-
Sending email from ms Access using CDO , Problem ?Mail sent using CDO is sent from the machine you're running it from. I believe there's a way to send the mail via a mail server by using server (I could be wrong); however, due to security concerns this isn't often done. Most firewall and anti-virus applications will also catch this sort of thing unless it's configured to allow mail to be sent out. I would recommend interop with outlook, since the libraries for this are available when outlook is installed. http://support.microsoft.com/kb/310263[^] Working in an exchange environment, I wound up using MAPI for one of my solutions. A quick search on CP for "MAPI" will yield several options for you.
-
Weird SQL Server 2005 Sybase interaction [modified]How's this for weird? One of my co-workers was attempting to develop an update trigger for an application that is developed using power-builder and (as far as I can tell) communicates to the database through a Sybase layer. The application is talking to a SQL Server 2005 server with a database set to SQL Server 2000 compatibility level. In the trigger, he is inserting into a table variable and running some logic based on that. The entire trigger runs just fine through all test cases in the DB; however it fails when the update is called from the application. With the error: Row changed between retrieve and update. Not having access to the application source, we couldn't debug very much through the app and Google was not our friend. Through debugging the trigger, we found the insert statement to be the culprit, but only when it insert 0 records into the table variable(we knew the logic below the trigger to be irrelevant as it was commented out). Being curious about the error message, I went ahead and printed
@@error
before and after the insert; then tested through Management Studio. I received no errors. Still curious, we ran the update through the app. We encountered no errors here either. Eventually we found that printing anything before the insert resolved the issue. In an attempt to figure out the problem, I even triedPRINT char(13)+'(0 row(s) affected)'
. It ran with no problem through the app. Happy to be rid of the error, my colleague continued his development; but we're still wondering: "WTF?" What do you guys think? Shall we chalk it up to Sybase oddities or is there a reasonable explanation for this?modified on Friday, August 27, 2010 9:47 PM
-
Using SQL as categorized tagging backendAwesome. Thanks for the input.
-
Using SQL as categorized tagging backendBackground: I've been requested to make an app that keeps track of complaint files that come in. These are non-standard and come in the form of PDF, doc, txt and xls. What needs to be tracked would be things like PO, Employee, Customer, etc. There can be multiple values to each of these or no value at all. Problem: Since I don't want to try to read from all of these files, I figure a categorized tagging system through SQL server might work. I'm somewhat reluctant to develop such a system, however, due to performance reasons. Possible solutions: The first solution I had in mind is using 3 tables. One table contains the file information. Another table contains the tag names. The third table relates to the file and tagname tables and holds the values of a tag associated with a file. I was thinking I could just index the column containing the tag values and query through it. The second solution involves one table containing the file name, delimited string of tag names and a delimited string of tag values. Issues: I'm not sure how costly the first solution will be on the server. I'm not wanting full text indexing, just an index on one varchar(30-ish) column. The second solution would be pretty simple to use regular expressions in my front-end to search through the values. But I wouldn't want to query against this since string comparisons are costly enough when they're straight 1-1. Which of these would be the better way to go? Would I absolutely be raping my server if I implementing my first solution? Any input is appreciated.
-
Using SQL Server 8.0 hashes to connect to SQL Server 9.0So here's the story. I was wrong about the hashes. But, 2005 uses case sensitive passwords by default. So when our vendor's application converts all passwords to upper before connecting, of course it'll do the same when it creates the users. So I have the misfortune of being an idiot and writing supplementary applications for badly designed software. Yay for me, and all I have to do now is edit a few libraries.
-
Using SQL Server 8.0 hashes to connect to SQL Server 9.0It's pretty obvious that password hashes for SQL Server 8.0 and 9.0 are different. So when migrating a server from SQL server 2000 to SQL Server 2005, everyone's password pretty much gets jacked. Is there a way to login to a SQL Server 2005 instance using SQL Server 200 credentials? I've tried specifying the provider and driver in my connection string for my ADO objects but get an error thrown back at me saying that the "provider" keyword is not recognized.
-
Wizard Control SuggestionsIndeed, a great article idea. If people wouldn't mind my writing style (that tends to get off topic and so interjected that it reminds me of a heavily nested, maybe a recursive algorithm) and vocabulary, or lack thereof. And don't get me started on tangents... which reminds me of one of my calculus profs for some reason. He always stopped to talk about his statistician friend who counts insects in the woods and looks like a sasquatch... anyway, that sounds like a great idea. But I'm not sure if I have time to re-invent the wheel. Which is why I wanted to know what people liked to use. Now that you got me thinking about it though, I'm getting some design thoughts running through my head. It'd be a fun project to do in my off time after I finish my wife's joint story authoring web-app (she's writing a story in conjunction with her friends and one of them is going crazy with her character so she asked me to make something that forced a kind of co-author approval before it can be appended to the main story). My only problem would be coding for the designer. It's not something I've done before. Fortunately, I've got a lot of sample code to go off of and a great community on CP.
-
Wizard Control SuggestionsI think I'll need to do some wizard controls in the future to accommodate for the short-comings of certain users. I'd need something that supports some databinding, or at least makes it simple to perform databinding actions myself. I did a quick search on CP and found a good deal of Wizard controls, most of them somewhat dated. Does anyone have any suggestions for a wizard control that's flexible and easy to implement? Any that are packed with features but a pain to implement?
-
Connection String Security ConcernsIn the DB, the user credentials are stored in the syslogins table, so there's at least that bit of security. In most of my user side applications, I've been known to use a 1-1 and onto encryption to store credentials. I've been known to be lazy at times, however. Fortunately, no one at this company is familiar with memory editors much less CLR reflection. Thanks for the input.
-
Connection String Security Concerns<sarcasm>HAHAHA!! Of COURSE all users have very as-needed access to the DB! Our software vendor's thought of that!</sarcasm> Of course, with any of my tables I try to keep things restricted to stored procs that certain users have access to. Thanks for pointing this out, though. I appreciate any response.
-
Connection String Security ConcernsI've written a series of ASP and winform applications for a database my one of my company's software vendors built. The vendor puts user login credentials in the sql connection strings in order to authenticate users. Since the same database is to be used, I have to use the same authentication method to keep users from being confused with additional usernames/passwords to remember. Other than an attacker appending
Integrated Security=True
to the end of the connection string. What security issues should I be concerned about with this method? -
Saving/Loading settings from Windows ServiceI decided to serialize the object i was using to keep my configuration settings and save it to a static xml file. This seems like the simplest method to me. To reiterate my original question: Does anyone have any tips on the best practice for setting up a configuration tool for another application? I did some digging and can't quite find anything. Although... an idea just struck me. What if I call the config tool from the same executable that the service is run through? I'll have to try this out later since I've already got this working.
-
Saving/Loading settings from Windows ServiceI'm new to writing services and I'm having some trouble figuring out a way to write configuration settings so the service would be able to read it. I decided to write a separate configuration application with its own namespace. I tried loading the setting by declaring and assigning a new instance of the settings from the other project. Problem is... it doesn't load from the other project, it loads a new instance of those settings for the current project (which makes sense, really -wouldn't want other applications accessing my settings). My question is, how should I get past this security feature. Is there something built into the
ApplicationSettingsBase
type that I'm not aware of? Should I save to and load from a static config file? Should I use an INI instead? Any thoughts would be appreciated.