One such example could be when you map a network drive on your computer. The network layer integrates into the file system by creating a virtual drive, while the file system integrates into the network layer by reading network paths. The actual network location is integrated into your file system and displayed as a drive icon under My Computer. Even though the networking layer and file system layer are both tested in isolation, there is no guarantee that the two components will work together once they are connected to each other. A ton of problems could occur in this integration! Integration testing is all about finding such issues.
Model
Let’s start by modeling a file system. We model the following:
static class FileSystem
{
...
[Rule(Action = "CreateDirectory()")]
static void CreateDirectory()
{
...
}
[Rule(Action = "ChangeDirectory(directory)")]
static void ChangeDirectory(int directory)
{
...
}
[Rule(Action = "CreateFile()")]
static void CreateFile()
{
...
}
[Rule(Action = "CreateDrive()")]
static void CreateDrive()
{
...
}
[Rule(Action = "FilesOnDrive(drive)/result")]
static int FilesOnDrive(int drive)
{
...
}
}
The idea here is of course that we have a file system, with a default drive (say “C:\”). We can create new directories and in these we can create files, we also have a validation function that counts the number of files on a drive.