public void Initialize()
 {
     fileSystemFixture = new FileSystemFixture();
     compositionFixture = new CompositionFixture();
     mockingFixture = new MockingFixture();
 }
 public void Cleanup()
 {
     mockingFixture = null;
     compositionFixture = null;
     fileSystemFixture = null;
 }
        public void GetChildItem_WherePathIsSubDirectoryAndForceIsSpecified_RefreshesResult()
        {
            var rootName = FileSystemFixture.GetRootName();
            var rootDirectoryItems = fileSystemFixture.RootDirectoryItems;
            var subDirectoryItems = fileSystemFixture.SubDirectoryItems;
            var subDirectoryItemsRefreshed = fileSystemFixture.SubDirectoryItems
                .Select(f => f is FileInfoContract
                    ? new FileInfoContract(f.Id.Value.Insert(f.Id.Value.IndexOf(".ext", StringComparison.Ordinal), "Refreshed"), f.Name.Insert(f.Name.IndexOf(".ext", StringComparison.Ordinal), "Refreshed"), f.Created, f.Updated, ((FileInfoContract)f).Size, ((FileInfoContract)f).Hash) as FileSystemInfoContract
                    : new DirectoryInfoContract(f.Id + "Refreshed", f.Name + "Refreshed", f.Created, f.Updated) as FileSystemInfoContract)
                .ToArray();

            var gatewayMock = new MockingFixture().InitializeGetChildItems(rootName, string.Empty, rootDirectoryItems);
            gatewayMock.SetupSequence(g => g.GetChildItem(rootName, new DirectoryId(@"\SubDir")))
                .Returns(subDirectoryItems)
                .Returns(subDirectoryItemsRefreshed)
                .Throws(new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, @"Redundant access to \SubDir")));
            compositionFixture.ExportGateway(gatewayMock.Object);

            var result = new PipelineFixture().Invoke(
                FileSystemFixture.NewDriveCommand,
                @"Get-ChildItem -Path X:\SubDir",
                @"Get-ChildItem -Path X:\SubDir -Force"
            );

            Assert.AreEqual(subDirectoryItemsRefreshed.Length, result.Count, "Unexpected number of results");
            CollectionAssert.AreEquivalent(subDirectoryItemsRefreshed, result.Select(p => p.BaseObject).Cast<FileSystemInfoContract>().ToList());
        }