Go Beyond Lorem Ipsum with AngelaSmith

Lorem Ipsum is commonly used to fill a UI prototype with random data. This can be useful for validating a design quickly, while not getting bogged down in the details of populating a database or objects with data. Microsoft uses this approach with its Windows Phone and Windows 8 app templates. Today, I am introducing a package that can help you go beyond Lorem Ipsum.

AngelaSmith

AngelaSmith is package that can fill your .NET objects with random, but meaningful data. Need a Person? She can give you one. Need a 1000? She can do that too. Here’s how it works:

Let’s assume we have the following class:

public class Person
{
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public string Email { get; set; }
    public string PhoneNumber { get; set; }
    public int Age { get; set; }
}

To generate some random Person instances, do this:

Person person = Angie.Make<Person>(); 
List<Person> peeps = Angie.FastList<Person>(10); 

 

Here is an example of what the populated Person objects look like:

 

How does she know? Well…Angie is pretty smart. She can inspect your object and make some intelligent guesses at what kind of data you would expect to see in those properties. Of course, Angie can’t figure it all out on her own. If you name your properties something different than she was expecting, she might not recognize it. For example if you had a property called FirNam which is intended to contain a person’s FirstName, Angie will not recognize that property as being a FirstName. That’s why we introduced a powerful fluent API to help configure how Angie generates objects for a specific type.

Person person = Angie.Configure<Person>()
                     .Fill(p => p.FirNam).AsFirstName()
                     .Make(); 
List<Person> peeps = Angie.FastList<Person>(10); 

 

Once you have configured Angie once, you can continue to ask for objects of that type without reconfiguring it (Angie has a good memory too).

The fluent API is pretty straight forward. Use the Fill method to select a particular property, then use one of the many built in methods to specify how you would like that property to be filled. You can even chain them together to keep specifying how to fill multiple properties:

List<Person> oldPeople = Angie.Configure<Person>()
                              .Fill(p => p.FirName).AsFirstName()
                              .Fill(p => p.PreferredEmail).AsEmailAddress()
                              .Fill(p => p.Age).WithinRange(55,98)
                              .MakeList(100); 

 

So far, we have seen how AngelaSmith can initialize text, numeric, and date properties, but what about properties that reference other objects? By default, AngelaSmith will leave those properties null. Luckily, with the fluent API, you can tell AngelaSmith how to fill those properties too.

 

Let’s say we class BlogPost with a property called Author of type Person. Here’s what you can do:

List<Person> authors = Angie.MakeList<Person>(10); 
List<BlogPost> posts = Angie.Configure<BlogPost>()
                  .Fill(e => e.Author).WithRandom(authors)
                  .MakeList(100); 

 

Awesome! Now we have 100 blog posts, each randomly assigned author from our list of 10 authors. As Staples would say: “That was easy!”.

More Info

AngelaSmith is a project that was started by James Chambers, and I was recently asked to join the project. You can find AngelaSmith on GitHub and of course on Nuget.

Install-Package AngelaSmith

Next time you need some random data (or next time you see Lorem Ipsum), give AngleSmith a try. Let us know what you think.


      
    

Windows 8 App Downloads Increasing + Over 5,000 Apps Available

Windows 8 will be unleashed on the general public tomorrow and I thought it would be a good time to review some of the numbers I have been tracking over the last month.

Downloads of Windows 8 Apps have been steadily increasing over the last month.  Below is screenshot from the App Summary page for my Windows 8 app.  The blue line is my app, while the orange line is average for the top 5 apps in that subcategory.  Considering the large gap between the 2, I think it is safe to assume that my app is NOT in the top 5 in the subcategory.

The spike in the last couple of days is fairly dramatic and I am a little surprised by that.  I would have expected that kind of spike on the days following the official release as opposed to the days leading up to the release.  

Finally, the all important App count.  There have been some stories floating around that the Window 8 Store is a ghost town and that there are no apps available.  I think these might be exaggerating the situation a little.  As of this morning, in the US store there are over 5000 apps available for download. 

Obviously a far cry from the hundreds of thousands available in other app stores, but we are seeing solid growth in this number. Less than a month ago, that number was 2000. That means the store more than doubled in less than a month. If the growth continues, it won’t be long before the Widows 8 Store is filled with all the apps you need (and a whole lot you don’t need).

Listing Desktop Apps in the Windows 8 Store

So it looks like Microsoft will be allowing publishers to list their desktop apps in the Windows 8 Store.  As per the developer agreement:

b. Desktop App Submission. You may submit an app description for one or more desktop apps to the Windows Store. Notwithstanding anything else in this agreement, you understand that Microsoft will not offer any desktop apps through the Store and only Windows Store apps are made available through the Windows Store. Microsoft may, but is not required to, list the desktop app in the Windows Store together with a link you provide, to a website where users can acquire the app. You are solely responsible and agree to maintain that website and provide an updated link to Microsoft if the url changes. Desktop apps are any apps built using APIs other than the APIs for Windows Store apps that run on Windows 8.

As the agreement states, Microsoft will not distribute desktop apps through the store, but they will provide a link to a website where users can download your desktop app.  If nothing else, it is a great way to advertise your app.  Hopefully this doesn’t cause any confusion with consumers.  Will end users understand why some apps install automatically while others just send you to a website?

Executing NUnit Tests using the Visual Studio 2012 Test Runner

At a recent Visual Studio 2012 event at the Calgary .NET User Group, I was told that I could run my NUnit tests directly in the Visual Studio 2012 without any special plugins.  Naturally, I was very excited and I immediately tried running my NUnit tests. I was somewhat disappointed to see that the Test Runner did not discover any of my NUnit tests. 

Apparently, you do still need to install an extension that supports NUnit.  Microsoft has completely re-written the Test Runner in Visual Studio 2012 and opened it up for anyone to write Test Adapters for any unit test framework (not just MSTest).  Once the correct test adapters are installed, everything works great.  Luckily, there are a good number of adapters already written.

Here are some Test Adapters that you might find useful:

Overall, I still prefer the unit test runner in ReSharper, but this is a great new feature for those who might not have a ReSharper license.