Giter VIP home page Giter VIP logo

unittestevaluation's Introduction

UnitTestEvaluation

This is a project to test/evaluate the C# unit test, using MVVM

I've made a very stupid example program, a calculator. The program is designed using the MVVM pattern. There is a View, a ViewModel and a Model.

Of course the View is responsible for presenting the data. The Model is the one the does the actual calculations, and the ViewModel is what connects them.

First of all the program creates the View, which in turn creates an instance of the ViewModel (that would be the <wm:ViewModel x:key="ViewModel"> line in the View.xaml) The view then binds to Properties and Commands in the ViewModel.

The ViewModel extends the ViewModelBase which is more or less a helper class that implements the INotifyPropertyChanged interface. So all Properties that is expected to be used by the View will call the Notify(#propertyName#) function (located in the ViewModelBase class) that invokes the PropertyChanged event on the class. This will update the values in the View.

All Commands in the ViewModel are Properties of the type RelayCommand which also is just a helper class that helps creating the Commands. The contructor to the RelayCommand takes an Action (which is called when the Command is executed), and - optionally - a function that decides whether or not the command can be executed (sets the Enabled property on the bounded Control).

The ViewModel also creates an instance of the Model. In a project this small it would almost make more sence not to have any model at all and just add or subtract the numbers in the ViewModel. However, this project is created to evaluate how to work with the unit test in VS, so don't case about how stupid the model is.

!!! The project uses NUnit, which should be downloaded automatically of you have !!! NuGet installed.

unittestevaluation's People

Contributors

tb2johm avatar

Watchers

James Cloos avatar  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.