Automated testing

M# generates unit tests and regression tests automatically for the functionality that it has also generated using MBUnit open source framework. It also enables the developers to write unit tests for the custom business logic in an efficient way by doing half of the work. A world-snapshot approach is used for ensuring practical and full coverage of all scenarios and operational cases.


World class

As you continue building the Model side of your application (The part of Business Logic which also creates database schema for you) M# puts instances of an imaginary world into a test project. You can specify details and tailor it to your needs.



    public partial class World



        public static AdditionalServices AdditionalServices = new AdditionalServices();

        public static Cases Cases = new Cases();

        public static CaseDocuments CaseDocuments = new CaseDocuments();

        public static CompanyDocuments CompanyDocuments = new CompanyDocuments();

        public static CompanyReminders CompanyReminders = new CompanyReminders();

        public static CorporateEnquiries CorporateEnquiries = new CorporateEnquiries();

        public static ApplicantUsers ApplicantUsers = new ApplicantUsers();

        public static CompanyUsers CompanyUsers = new CompanyUsers();

        public static SSWUsers SSWUsers = new SSWUsers();

        public static ApplicantFAQs ApplicantFAQs = new ApplicantFAQs();

        public static ContentBlocks ContentBlocks = new ContentBlocks();

        public static EmailTemplates EmailTemplates = new EmailTemplates();

        public static FAQCategories FAQCategories = new FAQCategories();

        public static Countries Countries = new Countries();

        public static DocumentTypes DocumentTypes = new DocumentTypes();

        public static EnquiryChannels EnquiryChannels = new EnquiryChannels();

        public static EnquiryProgresses EnquiryProgresses = new EnquiryProgresses();

        public static EnquiryStatuses EnquiryStatuses = new EnquiryStatuses();

        public static FeeAdjustments FeeAdjustments = new FeeAdjustments();

        public static Genders Genders = new Genders();

        public static IndustrySectors IndustrySectors = new IndustrySectors();

        public static SponsorLicences SponsorLicences = new SponsorLicences();

        public static SponsorRatings SponsorRatings = new SponsorRatings();

        public static SSWFirstOffices SSWFirstOffices = new SSWFirstOffices();

        public static SSWRoles SSWRoles = new SSWRoles();

        public static SSWSecondOffices SSWSecondOffices = new SSWSecondOffices();

        public static SSWServices SSWServices = new SSWServices();



    public partial class FAQCategories : ResidentsContainer


        public App.FAQCategory FrequentlyAskedQuestions

                                              { get { return App.FAQCategory.FrequentlyAskedQuestions; } }

        public App.FAQCategory InsightUpdates { get { return App.FAQCategory.InsightUpdates; } }

        public App.FAQCategory UsefulResources { get { return App.FAQCategory.UsefulResources; } }



At the start of each Unit Test underlying test system creates this World and at the end destroys it, making sure each unit test starts with a valid and fresh instance of World. This allows writing:

  • Very short unit tests
  • No need to arrange and setup an environment for each unit test
  • Unit tests have no side effects
  • World’s state is very like a production environment with valid states and familiar concepts


 Here is a Unit Test that makes most of already present World state to make sure system will throw an exception if mandatory Category has not been set:



public void validate_Category()


    var instance = World.ApplicantFAQs.Document1.Clone();


    instance.Category = null;

    Should.Throw<ValidationException>(instance.Validate, "Validation exception isn't thrown by Validate() method for an invalid Category.");



« Back