What really make DevMagicFake is a Valuable Framework???



There are 2 main points that make DevMagicFake really a valuable framework

  • It came and used in real life Enterprise Solutions
  • It developed using TDD for Development and Design
  • It came and used in a real life Enterprise Solutions

The Idea came from my previous project for Enterprise Project, its from about 1.5 years ago, and it will be used in real Enterprise Project, I am now working on real Enterprise Solution that will use MVC3, JQuery, EF 4.1 and many other new technologies

At the beginning of the current project development I decide to finish and publish DevMagicFake on CodePlex so I can really get feedback to enhance its usage in my real current project

When I start the first phase of my current Enterprise Project, I found using DevMagicFake wast amazing not because I am the one that create it of-course :-) , but because it really gives me what I expect, I will keep improve it as needed to my real life development and this also will give DevMagicFake a real value for me an for it’s users

  • It developed using TDD for Development and Design

From the beginning the goal of DevMagicFake drives me to design and develop it using TDD so in most cases I start creating unit Test firsts and then generate the code from the usages of the unit test and then start code the body of the methods, so it’s really pure TDD, and to be honest not in all it’s actions but in most of them,  because sometimes I don’t know what exactly to do unless I create the unit test

Also the existing of unit testing making me be able to ongoing refactor the code without loosing the integration or corrupting the features so it’s always improved in design and code with fair level of confidence of it’s features

I hope to get more feedback form it’s users so we can always improve it for our real life development and be more productive .

Believe me you will be more productive, accurate, stronger, confidence, … when you really start using DevMagicFake

Thanks

DevMagicFake become very easy by using Repository Pattern



One of the best pattern I used is Repository Pattern, for more information see this link, it helps me to apply the PI of the DDD and it fit in Layered architecture of DDD, I made a big research against using Generic Repository as my previous project or vs.Specific Repository?  as I saw too much in the community, and after details research I decide to use combine of both for many reasons,  this will help me reuse the code but with  more control than just only Generic Repository, any way I will not dig more about Repository Pattern I just need to clue my idea so you can get my point of the next explanation I will provide about DevMagicFake

Now DevMagicFake implement the Repository Pattern and this will help us very well in to reduce the thrown or maintenance code with DevMagicFake as we do before, because in real development we really call the method that we need from our real repository

By using IRepository interface which will be implemented by DevMagicFake and real repository, so no need to throw all faking code that used by DevMagicFake, unless some code like generating object with data that of course will not  existing in IRepository interface

Here is the IRepository interface

using System;
using System.Collections.Generic;
using System.Linq.Expressions;

public interface IRepository<T> where T : class
{

    T Add(T entity);
    T Get(Expression<Func<T, bool>> where);
    IEnumerable<T> GetAll();
    T GetByCode(string code);
    T GetById(long id);
    IEnumerable<T> GetMany(Expression<Func<T, bool>> where);
    void Remove(T entity);
    void Remove(Expression<Func<T, bool>> where);

}

Here how we will use it in our controller, as we can see the controller will take a prameter of type IVendorRepository which is Specific Repository that implment IRepository interface

public class VendorController: Controller
    {
        private IVendorRepository  vendorRepository;

        public VendorController (IVendorRepository  vendorRepository)
        {
            this. vendorRepository = vendorRepository;
        }

 public ActionResult List(VendorListModel vendorListModel)
        {
            var vendors = this.repository.GetAll();
	        var vendors2 = this.repository.GetMany(v=>v.Code > 50)
            .ToList();

            // REMOVEFAKE:FakeNote
            // Begin Faking
 	        var generatedVendors = ((FakeRepository<Vendor>)
             vendorRepository).Create(10);

            // End Faking
        }

Note: this feature not released yet, so if anyone need to use it, he will need to download the latest reversion of the project from CodePlex and just make a local build on his machine.

Remember, we will use any IoC or Dependency Injection to inject DevMagicFake or real repository or Mocking at the run time, this depend on the working stage, if its Faking, Testing, Development or Real stage

So now we are not only reduce the faking code that produced by DevMagicFake but we also transform this faking code into real development code which will enhance our productivity , we also control the faking code by using the faking snippet  so we can track and trace any faking or debts code at anytime!

Thanks

Did you really need DevMagicFake ????



Till now I didn’t get the feedback that I expected from publishing my project DevMagicFake on CodePlex, I believe that DevMagicFake will really make different change of the programming life style, quality and productivity for software development.

But to do this, it just need to be understood very well first, because most of the people who give me feedback didn’t get the whole point of DevMagicFake.

I will keep explaining why and why you will really need to use DevMagicFake, let’s see the following scenario:

Suppose we are working on a feature that require our system to have 1000 products, 100 customers and each customer has made 50 orders and each order has 20 line items and each line of item should belong to one product of the 1000 products.

WOW to Design, Develop and Test this feature we will need to develop the feature and use the completed UI features to enter all these data (if the UI is complete?) and even if the UI is complete this will take too much time specially I always change object model and data structure of my classes or my DB, I can’t even make any automation to enter the data through the UI, this because also the changing that always happen :-(

Even if we have DB and we start generate data, the generated data will not belong to each other and will not give us the consistence data that we really want to work on our feature to DesignDevelopment and Test it.

Just think how many times we change the structure of the objects and the DB???  So how we can do this in no time…..????

DevMagicFake can do this with one line of code, so we can start working and testing and make a real good design for our feature as we already enter all these data even with any change happen every time

Think of

  • Develop by feature
  • Test Driven Development
  • Test Driven Design
  • I didn’t complete the whole database
  • I always change my object model and always need to be existing data related to each other with the new modification of the object model classes I have made

What is the solution??????

DevMagicFake will help us do this with no effort at all.

Thanks

DevMagicFake Code Snippet now available



I just create 2 snippets not only for DevMagicFake but for any faking code that may I write throughout the project life cycle, I also will add rule to my development rules guidance that it’s prohibited to write any faking code outside the faking area, this will allow us to track back all faking code.

There is also a workaround snippet that will surround all workarounds that approved as workarounds and they have reference to the issue that recorded on the issue system, it will be add also to my rules guidance as well.

At any point of time you can look at technology depts as workarounds and surround it with workaround snippet to be re-factor and paid later in the nearest chance, we can download the snippet installer (msi)  just go to the CodePlex download page and download it for click on the following link: download

// REMOVEFAKE:FakeNote
// Begin Faking
// My fake code here
// End Faking
// REMOVEWORKAROUND:IssueNumber 250
// Begin workaround
// My workaround here
// End workaround

To make these snippets effective we will need to add 2 task tokens to the task list in Visual Studio as the following:

Add Task Tokens

Now we can go to any faking or workaround code,  and we are sure that all our debts are recorded in a manner that we can very easily and quickly track them back :-)

New configuration API for DevMagicFake



I create a new way for configuring DevMagicFake using fluent interface instead of the Configuration file but the framework still support the file configuration and it load it’s default settings from it, the file configuration has little change than before

Here the methods

  • Configure( )
  • RestToDefaultConfiguration( )

ConfigurationForDevMagicFake

For any farther information please don’t hesitate to contact me.

Thanks

New Feature to generate test data with fluent API in DevMagicFake



Hello,

I received very good suggestions and feedback from Maatren Balliauw, really thanks Maarten for your valuable opinions and ideas  :-) the most important suggestion was about making a fluent interface for my framework (DevMagicFake), of course there are data generation but with file configuration only, I planned to support better way but really Maatern give me very good opinions,  And now I complete this feature and here how it will work

When we work we need test data for testing our application, we need generator for our classes so we can perform the desired business scenarios, now we can use DevMagicFake for data generation in our domain model using fluent API instead of file configuration.

Note: this feature not released yet, so if anyone need to use it, he will need to download the latest reversion of the project from CodePlex and just make a local build on his machine.

So if we write the following code

FluentCode

So this will generate data as the following:

DataGenerated

The rules can be set using the following methods:

DataGenerationMethods

Now there are 3 methods for putting rules for your data generation

  • RuleUsesClassProperty( )
  • RuleUsesDataType( )
  • RuleUsesPropertyOnly( )

Each method can use one of the 4 types of generation of the following

  • GeneratFromList()
  • GenerateFromRange( )
  • GenerateFromValue( )
  • GenerateFromRandom( )

Finally you can controller the null percentage if needed

  • NullPercentage( )

And remember the data generation is a secondary goal of DevMagicFake , the main goal is to provide a way of real repository for your business classes in memory with all the methods that you may need to stop writing any faking code and be productive and working real TDD (Test Driven Development ) and (Test Driven Design)

I hope to get more feedback for improvement and new feature that will really help.

Thanks

DevMagicFake Published on NuGet



Now you can install DevMagicFake from NuGet server

DevMagicFake on NuGet

DevMagicFake on NuGet

To install the package you just open tool-> Library Package Manager->Package Manager Console as the following:

Open Package Console

Open Package Console

Now in the NuGet Package Manager console write the following

PM>Install-Package DevMagicFake -Project MyMVCProject

This will install DevMagicFake Library and add reference to it in your MVC project, this also will add the configuration file needed in the web.config

You can install it by another way, right click on the project you want to install the library to, choose Manage NuGet Packages, the NuGet Management window will appear, just search for DevMagicFake and install it

Open NuGet Package Manager

Open NuGet Package Manager

Install DevMagicFake from NuGet

Install DevMagicFake from NuGet

DevMagicFake step by step tutorial


Here, we can find a step-by-step tutorial on how to use DevMagicFake

DevMagicFake mainly created to work with ASP MVC to help implementing TDD (Test Driven Development),  TDD  needs the behaviors that will build the test,  DevMagicFake simulate data model and it is working like mock objects and unit testing framework

DevMagicFake on CodePlex

DevMagicFake on NuGet

Step-by-Step Tutorial

Some snapshots of the tutorial document

Introduction to Dev Magic Fake framework presentation



Hear is the first presentation of Dev Magic Fake, I will introduce Dev Magic Fake to all team members of Ocean Soft, actually we working on Enterprise project and we will use Dev Magic Fake

Dev Magic Fake Video tutorial



The following tutorial for a very simple scenario, Dev Magic Fake produced to provide complex scenarios, but this tutorial just a beginning and introduction in how to use Dev Magic Fake, for complex scenarios you can see the the following post and download the step by step guide ( Dev Magic Fake step by step tutorial)

DevMagicFake on CodePlex

DevMagicFake on NuGet