Click here to Skip to main content
15,885,278 members
Articles / Web Development / CSS

15 Steps to Develop a Product Management System in Only a Day

Rate me:
Please Sign up or sign in to vote.
4.83/5 (51 votes)
23 Mar 2010GPL34 min read 247.8K   4.8K   163  
The article introduces how to easily develop business solutions in RapidWebDev through developing a product management system with the special requirement step by step.
/****************************************************************************************************
	Copyright (C) 2010 RapidWebDev Organization (http://rapidwebdev.org)
	Author: Tim, Legal Name: Long Yi, Email: tim.yi@RapidWebDev.org

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 2 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ****************************************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using BaoJianSoft.Common;
using BaoJianSoft.Common.Data;
using BaoJianSoft.Platform;
using BaoJianSoft.Platform.Linq;
using NBehave.Narrator.Framework;
using NBehave.Spec.NUnit;
using NUnit.Framework;


namespace BaoJianSoft.Tests.BehaveTest.Stories.Organization
{
    [TestFixture, Theme]
    public class SaveOrganizationStory : SetupFixture
    {
        private Story _story;

        private OrganizationObject _OrganObject1;

        private IOrganizationApi _organizationApi;

        List<Guid> createdOrganizationIds;
        List<Guid> createdOrganizationTypeIds;

        private BehaveOrganizationUtils _utils;

        [SetUp]
        public void Setup()
        {
            createdOrganizationIds = new List<Guid>();
            createdOrganizationTypeIds = new List<Guid>();

            base.GlobalSetup();

            _utils = new BehaveOrganizationUtils();

            _organizationApi = SpringContext.Current.GetObject<IOrganizationApi>();
        }

        public SaveOrganizationStory()
        {
            Console.WriteLine("=================Setup===================");

            createdOrganizationIds = new List<Guid>();
            createdOrganizationTypeIds = new List<Guid>();

            base.GlobalSetup();

            _utils = new BehaveOrganizationUtils();

            _organizationApi = SpringContext.Current.GetObject<IOrganizationApi>();

            Console.WriteLine("============Ending Setup===================");
        }
        [TearDown]
        public void CleanUp()
        {
           Console.WriteLine("============Clean Up====================");
           try
           {
               using (MembershipDataContext ctx = DataContextFactory.Create<MembershipDataContext>())
               {
                   var organizationsToDelete = ctx.Organizations.Where(org => createdOrganizationIds.ToArray().Contains(org.OrganizationId));
                   var organizationTypesToDelete = ctx.OrganizationTypes.Where(orgType => createdOrganizationTypeIds.ToArray().Contains(orgType.OrganizationTypeId));

                   ctx.OrganizationTypes.DeleteAllOnSubmit(organizationTypesToDelete);
                   ctx.Organizations.DeleteAllOnSubmit(organizationsToDelete);
                   
                   ctx.SubmitChanges();
                   createdOrganizationIds.Clear();
                   createdOrganizationTypeIds.Clear();
               }
           }
           catch (Exception e)
           {
               Console.WriteLine(e.Message);
               throw e;
           }
           
            Console.WriteLine("========Ending Clean Up====================");
        }

        [Story, Test]
        public void SaveANewOrganizationWithEmptyProperties()
        {
            _story = new Story("Save a Organization By IOrganizationApi");

            _story.AsA("User")
              .IWant("to be able to create a new Organization, but I don't assign value to it")
              .SoThat("I can get specific exception");

            _story.WithScenario("Save a new Organization which have no value")
                .Given("the new member with nothing", () => 
                { 
                    _OrganObject1 = new OrganizationObject(); 
                })
                .When("I save this Organization", () => { })
                .Then("I Get an ArgumentNullException from IOrganizationApi.Save()", () => typeof(ArgumentNullException).ShouldBeThrownBy(() => _organizationApi.Save(_OrganObject1)));

            this.CleanUp();
        }

        //[Story, Test]
     
        //public void SaveANewOrganizationrWithValues()

        //{
        //    _story = new Story("Save a Organization By IOrganizationApi");

        //    _story.AsA("User")
        //      .IWant("to be able to create a new Organization")
        //      .SoThat("I can get specific exception");

        //    _story.WithScenario("Save a new Organization")
        //        .Given("the new Organization ", () => 
        //        {
        //            _OrganTypeObject1 = _utils.CreateOrganizationTypeOject("Type1", "Inc");

        //            _organizationApi.Save(_OrganTypeObject1);

        //            createdOrganizationTypeIds.Add(_OrganTypeObject1.OrganizationTypeId);

        //            _OrganObject1 = _utils.CreateOrganizationObject(_OrganTypeObject1.OrganizationTypeId, "hangzhou2", "wuhan1");

        //            createdOrganizationIds.Add(_OrganObject1.OrganizationId);

        //        })
        //        .When("I save this Organization", () => 
        //        {
        //            _organizationApi.Save(_OrganObject1); 
        //        })
        //        .Then("I Get an new Organization Object from IOrganizationApi.Save()", 
        //        () => 
        //            _OrganObject1.OrganizationId.ShouldNotBeNull()
        //            );

        //    this.CleanUp();
        //}

        //[Story, Test]
        
        //public void UpdateOldOrganization()
        //{
        //    _story = new Story("Update a Organization By IOrganizationApi");

        //    _story.AsA("User")
        //      .IWant("to be able to update a old Organization")
        //      .SoThat("I can get specific exception");

        //    _story.WithScenario("Save a new Organization which have no value")
        //        .Given("the new member with nothing", () =>
        //        {
        //            _OrganTypeObject1 = _utils.CreateOrganizationTypeOject("Type3", "Inc");

        //            _organizationApi.Save(_OrganTypeObject1);

                   

        //            createdOrganizationTypeIds.Add(_OrganTypeObject1.OrganizationTypeId);

        //            _OrganObject1 = _utils.CreateOrganizationObject(_OrganTypeObject1.OrganizationTypeId, "wuhan1", "wuhan1");

        //            _organizationApi.Save(_OrganObject1);

        //            Console.Error.WriteLine("_OrganObject1's OrganizationTypeId : " + _OrganObject1.OrganizationTypeId);

        //            createdOrganizationIds.Add(_OrganObject1.OrganizationId);

        //            _OrganTypeObject2 = _utils.CreateOrganizationTypeOject("Type2", "Inc");

        //            _organizationApi.Save(_OrganTypeObject2);

        //            Console.Error.WriteLine("_OrganTypeObject2's OrganizationTypeId : " + _OrganTypeObject2.OrganizationTypeId);

        //            createdOrganizationTypeIds.Add(_OrganTypeObject2.OrganizationTypeId);

        //        })
        //        .When("I change the value of this Organization", () => 
        //        {
        //            _OrganObject1.OrganizationTypeId = _OrganTypeObject2.OrganizationTypeId; 
        //        })
        //        .Then("I Get an new Organization Object from IOrganizationApi.Save()", () => 
        //        {
        //            _organizationApi.Save(_OrganObject1);

        //            Console.Error.WriteLine("_OrganObject1's OrganizationTypeId : " + _OrganObject1.OrganizationTypeId);

        //            _OrganObject1.OrganizationTypeId.ShouldEqual(_OrganTypeObject2.OrganizationTypeId); 
        //        });
        //    this.CleanUp();
        
        //}

    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
President TCWH
China China
I've worked as a software architect and developer based on Microsoft .NET framework and web technology since 2002, having rich experience on SaaS, multiple-tier web system and website development. I've devoted into open source project development since 2003, and have created 3 main projects including DataQuicker (ORM), ExcelQuicker (Excel Report Generator), and RapidWebDev (Enterprise-level CMS)

I worked in BenQ (8 mo), Bleum (4 mo), Newegg (1 mo), Microsoft (3 yr) and Autodesk (5 yr) before 2012. Now I own a startup company in Shanghai China to deliver the exceptional results to global internet users by leveraging the power of Internet and the local excellence.

Comments and Discussions