Skip to main content

Posts

Showing posts from February, 2008

Unit Test Object Properties

Unit testing of entities is something that never gets done very well for a number of reasons, the objects are pretty simplistic, developers get board righting that type of code, etc. It seems that one area unit tests of this type of business object fails is in testing their properties. The test covers setting and retrieving the properties but what about Business Objects with CRUD behavior? What about testing Data Access layer save functionality. Just because the save method does not error on you does not mean the save works. To really have a good unit test you need to save the object and then get the object again and compare all the properties to make sure each property was saved as expected. To test each property I often see developers writing code that does a one to one compare on the two objects (the object they tried to save and the object that was saved). This gets boring really quickly and can explain why a lot of the time you do not see full code coverage. To help make this ea

WPF Improvements on the way

Found this information today on Scott Gu's blog . All great news about WPF improvements that are on their way. WPF Performance Improvements This summer we are also planning to release a servicing update to WPF that includes a bunch of performance optimizations that improve its text, graphics, media and data stack. These include: - Moving the DropShadow and Blur bitmap effects, which are currently software rendered, to be hardware accelerated (making them many times faster). The APIs for these effects will stay the same as they are today (which means you do not need to change any code nor recompile your apps to take advantage of these improvements). - Text scenarios, especially when used in Visual and DrawingBrush scenarios, will be substantially faster. The APIs for these scenarios also stay the same (which means you do not need to change any code nor recompile to take advantage of the performance improvements). - Media and video performance scenarios will also be much fa

WPF Validation

I recently had to build out a validation solution for a WPF project I was working on. For those of you that have not worked with WPF (you are missing out) validation works differently. At first I was unsure about the way validation works in WPF and it seemed a little incomplete. I still believe it is incomplete, mainly because there is no built in way to do complete form validation unless you implement a custom solutions. This brings us to the point of this post. I recently wrote up an example of a few different ways to do complete form validation using WPF. I created a Validation manager that allows me to do this. The validation manager utilizes the creation of custom validation rules. You can download the whole paper and the example solution here . The paper includes validation approaches other developers have done as well. The validation manager that is used in this approach allows you to handle validation at the form level and allows you to have your validation logic separated from

CollectionView Filter

For those of you who have worked with data collections in WPF if you have probably learned how helpful a CollectionView can be. CollectionViews let you filter, group and sort a collection of data without any requiring of the data. Setting a CollectionView up to filter or group data is actually pretty easy. Here is an example of how you would setup a Collection into a CollectionView to be filtered. ListCollectionView _view; public Window1() { InitializeComponent(); string[] myValues = new string[] { "Red Car", "Red Truck", "Blue Car", "Yellow Truck" }; _view = new ListCollectionView(myValues); this.DataContext = _view; } private void FilterTrucks(Object sender, RoutedEventArgs args) { if (_view.CanFilter && (ShowTrucks.IsChecked == true)) _view.Filter = new Predicate<object>(IsValueTruck); else { // Remove the filter _view.Filter = null; } } public bool IsValueTruck(Obje

New Code Site

I have been creating a lot of coding examples on my personal live spaces account. I have recently come to the realization that spaces just does not give me enough flexibility to really create good examples. It is also mixed in with all my other thoughts on life. Because of that I have decided to create a new blog dedicated to thoughts on code. I plan on uploading different code samples here that will be on different topics such as WPF, Silverlight, LINQ and more. It is really for my own enjoyment and to give me a place to store examples I create on how to do things. Hopefully it will benefit others out there as well. I will be spending time porting previous examples from my spaces account to here. Part of this port will include layout the examples as well as including links to the source code for all projects. I hope you all enjoy!