[This is preliminary documentation and is subject to change.]

Verifies that the actual value matches the expected value

Namespace:  Firefly.Box.Testing
Assembly:  Firefly.Box (in Firefly.Box.dll) Version: 3.4.23.6473 (3.4.23.6473)

Syntax

C#
public static void ShouldBe(
	this Bool value,
	bool expectedValue
)
Visual Basic (Declaration)
<ExtensionAttribute> _
Public Shared Sub ShouldBe ( _
	value As Bool, _
	expectedValue As Boolean _
)
Visual C++
[ExtensionAttribute]
public:
static void ShouldBe(
	Bool^ value, 
	bool expectedValue
)

Parameters

value
Type: Firefly.Box..::.Bool
the value to check
expectedValue
Type: System..::.Boolean
the expected value

Remarks

Used mainly for Unit Testing.
If the value doesn't match the expected value, an exception is thrown

Examples

This example demonstrates the usage of DemoBusinessProcess
This example is in the form of Unit Tests. It references the NUnit framework. This framework can be downloaded from www.NUnit.org. For more information about unit testing visit: www.NUnit.org.
This example is based on test data. The code for the entities included in this test data can be found in the documentation of Entity
CopyC#
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using Firefly.Box;
using Firefly.Box.Testing;

namespace TestFirefly.Box.Documentation
{
    [TestFixture]
    public class DemoBusinessProcess
    {
        [Test]
        public void IterateAllRows()
        {
            var employees = new Pubs.Employees();
            employees.InitializeWithTestData();// Insert test data to the table

            var bp = new BusinessProcess
                         {
                             From = employees,
                             Activity = Activities.Update // The default activity
                         };
            int numberOfEmployeesWithoutMiddleInitials = 0;
            bp.ForEachRow(() =>
                              {
                                  if (employees.MiddleInitial == "")
                                      numberOfEmployeesWithoutMiddleInitials++;
                              });
            numberOfEmployeesWithoutMiddleInitials.ShouldBe(10);//Checks that there are 10 employees in the test data without a middle initial
        }
        [Test]
        public void DeleteEmployeesWithJob5()
        {

            var employees = new Pubs.Employees();
            employees.InitializeWithTestData();// Insert test data to the table
            employees.CountRows().ShouldBe(43);// Verifies that the test data has 43 rows

            var bp = new BusinessProcess
                         {
                             From = employees,
                             Activity = Activities.Delete
                         };
            bp.Where.Add(employees.JobId.IsEqualTo(5));
            bp.Run();

            employees.CountRows().ShouldBe(36);// Verifies that after the delete, only 36 rows remain
        }
        [Test]
        public void InsertAnEmployee()
        {
            var employees = new Pubs.Employees();
            employees.InitializeWithTestData();// Insert test data to the table
            employees.CountRows().ShouldBe(43); // Verifies that the test data has 43 rows

            var bp = new BusinessProcess
                         {
                             From = employees,
                             Activity = Activities.Insert
                         };
            bp.ForFirstRow(() =>
                               {
                                   employees.Id.Value = "ID-1234";
                                   employees.FirstName.Value = "John";
                                   employees.LastName.Value = "Doe";
                               });
            employees.CountRows().ShouldBe(44);// Verifies that after the insert, there are 44 rows in the test data
        }
    }
}

See Also