ExpectationValueTests.cs :  » Testing » MockObjects » DotNetMock » Tests » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Testing » MockObjects 
MockObjects » DotNetMock » Tests » ExpectationValueTests.cs
using System;
using NUnit.Framework;
using DotNetMock;

namespace DotNetMock.Tests{
  [TestFixture]
  public class ExpectationValueTests
  {
    private ExpectationValue _expectationValue;

    [SetUp]
    public void SetUp() {
      _expectationValue = new ExpectationValue("ExpectationValue");
    }
    
    [TearDown]
    public void TearDown() {
      _expectationValue = null;
    }
    
    [Test]
    public void SetActual() {  
      Object object1 = new Object();

      Assert.IsNull(_expectationValue.Actual);
      _expectationValue.Actual = object1;
      Assert.AreEqual(object1, _expectationValue.Actual);
      
      object1 = null;
    }

    [Test]
    public void SetExpected() {
      Object object2 = new Object();

      Assert.IsNull(_expectationValue.Expected);
      _expectationValue.Expected = object2;
      Assert.AreEqual(object2, _expectationValue.Expected);
      
      object2 = null;
    }
    
    [Test]
    public void HasExpectations() {
      Object object3 = new Object();
      
      _expectationValue.Expected = object3;
      Assert.IsTrue(_expectationValue.HasExpectations);
      
      object3 = null;
    }

    [Test]
    [ExpectedException(typeof(DotNetMock.AssertionException))]
    public void Verify()
    {
      int int1 = 3;
      int int2 = 5;
      int int3 = 3;

      _expectationValue.Actual = int1 ;
      _expectationValue.Expected = int2 ;
      _expectationValue.Verify();
        
      _expectationValue.Expected = int3 ;
      _expectationValue.Verify();

    }
    
    [Test]
    public void FailureMode()
    {
      Object object4 = new Object();

      _expectationValue.Expected = object4;

      Assert.IsTrue(_expectationValue.HasExpectations);
      Assert.IsTrue(!(_expectationValue.ShouldCheckImmediate));
      _expectationValue.VerifyImmediate = true;
      Assert.IsTrue(_expectationValue.ShouldCheckImmediate);
      
      object4 = null;
    }

    [Test]
    public void ClearActual()
    {
      Object object5 = new Object();

      Assert.IsNull(_expectationValue.Actual);
      _expectationValue.Actual = object5;
      Assert.IsNotNull(_expectationValue.Actual);
      _expectationValue.ClearActual();
      Assert.IsNull(_expectationValue.Actual);
      
      object5 = null;
    }
    
    [Test]
    public void ClearExpected()
    {
      Object object6 = new Object();

      Assert.IsNull(_expectationValue.Expected);
      _expectationValue.Expected = object6;
      Assert.IsNotNull(_expectationValue.Expected);
      Assert.IsTrue(_expectationValue.HasExpectations);
      _expectationValue.ClearExpected();
      Assert.IsNull(_expectationValue.Expected);
      
      object6 = null;
    }
    [Test]
      public void ShouldCheckImmediate()
    {
      object object7 = new object();
      _expectationValue.Expected = object7;
      _expectationValue.VerifyImmediate = true;
      _expectationValue.Actual = object7;
    }
    [Test]
    public void NullValues()
    {
      _expectationValue.ExpectNothing();
      _expectationValue.ClearActual();
      _expectationValue.Verify();
    }
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.