Should.ShouldBe(Number, Int64) Method
Verifies that the actual value matches the expected value
Namespace: Firefly.Box.TestingAssembly: Firefly.Box (in Firefly.Box.dll) Version: debug-master-v:33791
public static void ShouldBe(
this Number value,
long expectedValue
)
<ExtensionAttribute>
Public Shared Sub ShouldBe (
value As Number,
expectedValue As Long
)
[<ExtensionAttribute>]
static member ShouldBe :
value : Number *
expectedValue : int64 -> unit
- value Number
- the value to check
- expectedValue Int64
- the expected value
In Visual Basic and C#, you can call this method as an instance method on any object of type
Number. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).
Used mainly for Unit Testing.
If the value doesn't match the expected value, an exception is thrown
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
Entityusing 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();
var bp = new BusinessProcess
{
From = employees,
Activity = Activities.Update
};
int numberOfEmployeesWithoutMiddleInitials = 0;
bp.ForEachRow(() =>
{
if (employees.MiddleInitial == "")
numberOfEmployeesWithoutMiddleInitials++;
});
numberOfEmployeesWithoutMiddleInitials.ShouldBe(10);
}
[Test]
public void DeleteEmployeesWithJob5()
{
var employees = new Pubs.Employees();
employees.InitializeWithTestData();
employees.CountRows().ShouldBe(43);
var bp = new BusinessProcess
{
From = employees,
Activity = Activities.Delete
};
bp.Where.Add(employees.JobId.IsEqualTo(5));
bp.Run();
employees.CountRows().ShouldBe(36);
}
[Test]
public void InsertAnEmployee()
{
var employees = new Pubs.Employees();
employees.InitializeWithTestData();
employees.CountRows().ShouldBe(43);
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);
}
}
}