Git Product home page Git Product logo

bdd's Introduction

#Overview

How do we enable using Visual Studio and nUnit/SpecFlow to test VFP code?

##Problems

  • .NET can't natively talk with VFP
  • VFP can't natively call .NET

##Solutions

.NET classes can be exposed to COM so object references can be passed from .NET into VFP i.e. read and assign from classes created in .NET from inside a VFP object. Similarly, VFP can be COM-enabled to allow access from a .NET solution.

##Gotchas

VFP COM objects that will work with .NET do not have visual elements, so we can't tests forms directly through this approach.

##Visual FoxPro Example

The staff form has a button that is executing some behaviour (changing the form caption). Historically the code for this would be in the button event-handling method as a component of the form. All we do is separate this out to another object (the behaviour object). The behaviour object is attached to the form on Init. This is all standard separation of concerns stuff.

The behaviour class has been marked as a COM class, internally to our VFP apps we can use the non-com interface as usual, and the COM interface can be used from .NET. The behaviour class is passed a reference to the form object to be manipulated, as VFP is dynamic this can be any object as long as it has the basic properties we are touching.

##.NET Example

A simple mock object has been constructed to wrap the basic form details, we can pass in this mock form to the VFP behaviour class and effectively exercise VFP behaviour using a .NET construct.

The examples include a test project using nUnit specifically and also a SpecFlow example.

##Getting Started

  • Grab the code
git clone https://github.com/cmcguff/bdd.git		
```

- Build the VFP project as a single=thread DLL and register the dll (should happen by default, make sure you are running VFP as Administrator)

```
build dll vfp_automation.dll from vfp_automation.pjx
```

- Run the tests from .NET

bdd's People

Contributors

cmcguff avatar cmcguff-myob avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

vbossekat vfp9

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.