SubtextDirectoryTests.cs :  » Bloggers » SubText » SubtextUpgraderTests » 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 » Bloggers » SubText 
SubText » SubtextUpgraderTests » SubtextDirectoryTests.cs
using System;
using System.IO;
using MbUnit.Framework;
using Moq;
using SubtextUpgrader;

namespace SubtextUpgraderTests{
    [TestFixture]
    public class SubtextDirectoryTests
    {
        [Test]
        public void CopyTo_WithDestinationDirectory_CopiesFiles()
        {
            // arrange
            var source = new SubtextDirectory(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()));
            source.Create();
            
            var destination = new SubtextDirectory(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()));
            destination.Create();

            var file1 = source.CombineFile(Guid.NewGuid().ToString());
            using (var sw = new StreamWriter(file1.OpenWrite()))
                sw.WriteLine(@"Lorem ipsum dolor sit amet, consectetur adipiscing elit.");

            var file2 = source.CombineFile(Guid.NewGuid().ToString());
            using (var sw = new StreamWriter(file2.OpenWrite()))
                sw.WriteLine(@"Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
            
            // act
            source.CopyTo(destination);

            // assert
            FileAssert.Exists(destination.CombineFile(file1.Name).Path);
            FileAssert.Exists(destination.CombineFile(file2.Name).Path);

        }

        [Test]
        public void CopyTo_WithDestinationDirectory_CopiesSubfolders()
        {
            // arrange
            var source = new Mock<SubtextDirectory>(new DirectoryInfo("."));
            var destination = new Mock<IDirectory>();
            var destDir1 = new Mock<IDirectory>();
            destination.Setup(d => d.Combine("Dir1")).Returns(destDir1.Object);
            var destDir2 = new Mock<IDirectory>();
            destination.Setup(d => d.Combine("Dir2")).Returns(destDir2.Object);
            var dir1 = new Mock<IDirectory>();
            dir1.Setup(d => d.Name).Returns("Dir1");
            var dir2 = new Mock<IDirectory>();
            dir2.Setup(d => d.Name).Returns("Dir2");
            var directories = new[] { dir1.Object, dir2.Object };
            source.Setup(d => d.GetDirectories()).Returns(directories);

            // act
            source.Object.CopyTo(destination.Object);

            // assert
            dir1.Verify(d => d.CopyTo(destDir1.Object));
            dir2.Verify(d => d.CopyTo(destDir2.Object));
        }
    }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.