Skip to content

Instantly share code, notes, and snippets.

@testautomationtribe

testautomationtribe/caculatorSteps.cs Secret

Last active Oct 15, 2017
Embed
What would you like to do?
Calculator Feature Implementation
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TechTalk.SpecFlow;
namespace TatAuto.Tests.Steps
{
    [Binding]
    public class CalculatorSteps
    {
        private readonly List<int> _numbers = new List<int>();
        private int _total;
        [Given(@"I have entered (.*) into the calculator")]
        public void GivenIHaveEnteredIntoTheCalculator(int p0)
        {
            _numbers.Add(p0);
        }
        
        [When(@"I press add")]
        public void WhenIPressAdd()
        {
            _total = _numbers.Sum();
        }
        
        [Then(@"the result should be (.*) on the screen")]
        public void ThenTheResultShouldBeOnTheScreen(int p0)
        {
            Assert.AreEqual(p0_total);
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.