Git Product home page Git Product logo

webforms-autofac-mstest-yaml-pipeline's Introduction

Introduction

Sample .NET Framework project using ASP.NET WebForms, Autofac IOC Container, MSTest and YAML Pipeline...

Getting Started

  1. Setup database

    • Download SQL Server 2022 Express
    • Login the SQL Server Instance and create a database name Northwind
    • Run scripts below to to setup the BankAccount table
    CREATE TABLE [dbo].[BankAccount](
    [AccountId] [int] IDENTITY(1,1) NOT NULL,
    [AccountNumber] [nchar](10) NOT NULL,
    [Balance] [decimal](18, 2) NOT NULL,
    [Frozen] [tinyint] NOT NULL,
     CONSTRAINT [PK_BankAccount] PRIMARY KEY CLUSTERED 
    (
    	[AccountId] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
    ) ON [PRIMARY]
    GO
    
    ALTER TABLE [dbo].[BankAccount] ADD  CONSTRAINT [DF_BankAccount_Frozen]  DEFAULT ((0)) FOR [Frozen]
    GO
    
    INSERT INTO BankAccount(AccountNumber, Balance) VALUES('01-12344',10.00);
    GO
    SELECT * FROM BankAccount
  2. Install Visual Studio Community Edition and create a new Solution

  3. Create Repository project

Install Nuget package:

  • EntityFramework

Create the following files:

  • ADO.NET Entity Data Model: EntityDataModel.edmx
  • Interface file: IBankAccountRepository.cs
  • Implementation file: BankAccountRepository.cs
    • Note: Implementation class has constructor "depends" on Entities Data Model class.

Note for App.Config file:

  • Has connection string point to the SQL Server database
  1. Create a Service project

    Create the following files:

    • Interface file: IBankAccountService.cs
    • Implementation file: BankAccountService.cs
      • Note: Implementation class has constructor "depends" on Repository interface.
  2. Create WebForms project

    Install Nuget packages:

    • Autofac 6.4.0 (IMPORTANT: don't install the latest version)
    • Autofac.Web 6.1.0
    • EntityFramework

    Add reference to Repository and Service projects.

    Update web.config to enable Property Injection Autofac for WebForms

  3. Create MSTest.Test project

    Install Nuget packages:

Downloads:

  1. Visual Studio Community Edition
  2. MSTest Cheat Sheet
  3. SQL Server 2022 Express

webforms-autofac-mstest-yaml-pipeline's People

Contributors

365nguyen avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.