Fixed and closed #494: PluginPack now compiled as separate assemblies. Also implemented Updater plugin to silently replace PluginPack.dll with new DLLs.

This commit is contained in:
Dario Solera 2010-05-02 09:13:57 +00:00
parent 0a54e553cc
commit c89e576368
26 changed files with 905 additions and 936 deletions

View file

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{DEA4E4AA-7452-4598-8277-A7F5D6DE4985}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DownloadCounterPlugin_Tests</RootNamespace>
<AssemblyName>DownloadCounterPlugin-Tests</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="nunit.framework, Version=2.5.2.9222, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\References\Tools\NUnit\framework\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="Rhino.Mocks, Version=3.5.0.1337, Culture=neutral, PublicKeyToken=0b3305902db7183f, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\References\Tools\Rhino.Mocks\Rhino.Mocks.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="DownloadCounterTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DownloadCounterPlugin\DownloadCounterPlugin.csproj">
<Project>{C2F2722A-0B44-4E98-965C-CC1AD1DA511C}</Project>
<Name>DownloadCounterPlugin</Name>
</ProjectReference>
<ProjectReference Include="..\PluginFramework\PluginFramework.csproj">
<Project>{531A83D6-76F9-4014-91C5-295818E2D948}</Project>
<Name>PluginFramework</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View file

@ -0,0 +1,100 @@

using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using Rhino.Mocks;
using RMC = Rhino.Mocks.Constraints;
using ScrewTurn.Wiki.PluginFramework;
namespace ScrewTurn.Wiki.Plugins.PluginPack.Tests {
[TestFixture]
public class DownloadCounterTests {
[Test]
public void Format() {
MockRepository mocks = new MockRepository();
IFilesStorageProviderV30 prov = mocks.StrictMock<IFilesStorageProviderV30>();
string content = string.Format(
@"This is a test page.
<countDownloads pattern=""#CoUnT#-#DaIlY#-#WeEkLy#-#MoNtHlY#"" startDate=""{0:yyyy'/'MM'/'dd}"">
<file name=""/my/file.zip"" provider=""{1}"" />
<file name=""/my/other/file.zip"" />
<file name=""/my/inexistent-file.zip"" provider=""{1}"" />
<file name=""/my/other/inexistent-file.zip"" />
<attachment name=""attn.zip"" page=""page"" provider=""{1}"" />
<attachment name=""attn.zip"" page=""page"" />
<attachment name=""inexistent-attn.zip"" page=""page"" provider=""{1}"" />
<attachment name=""inexistent-attn.zip"" page=""page"" />
<attachment name=""attn.zip"" page=""inexistent-page"" provider=""{1}"" />
<attachment name=""attn.zip"" page=""inexistent-page"" />
</countDownloads>", DateTime.Today.AddDays(-60), prov.GetType().FullName);
// */file.zip was downloaded 13 times
// attn.zip was downloaded 56 times
// Expected output: 138-2-16-68
IHostV30 host = mocks.StrictMock<IHostV30>();
host.LogEntry(null, LogEntryType.Warning, null, null);
LastCall.On(host).IgnoreArguments().Repeat.Any();
Expect.Call(host.GetSettingValue(SettingName.DefaultFilesStorageProvider)).Return(
prov.GetType().FullName).Repeat.Times(4);
Expect.Call(host.GetFilesStorageProviders(true)).Return(
new IFilesStorageProviderV30[] { prov }).Repeat.Times(8);
StFileInfo[] myFiles = new StFileInfo[] {
new StFileInfo(1000, DateTime.Now, 13, "/my/File.zip", prov),
new StFileInfo(10000, DateTime.Now, 1000, "/my/other-file.zip", prov)
};
StFileInfo[] myOtherFiles = new StFileInfo[] {
new StFileInfo(1000, DateTime.Now, 13, "/my/OTHER/file.zip", prov),
new StFileInfo(10000, DateTime.Now, 2000, "/my/OTHER/other-file.zip", prov)
};
StFileInfo[] attachments = new StFileInfo[] {
new StFileInfo(2000, DateTime.Now, 56, "aTTn.zip", prov),
new StFileInfo(20000, DateTime.Now, 1000, "other-attn.zip", prov)
};
// /my/*
Expect.Call(host.ListFiles(null)).IgnoreArguments().Constraints(
RMC.Is.Matching(
delegate(StDirectoryInfo dir) {
return dir.FullPath == "/my/";
})).Return(myFiles).Repeat.Times(2);
// /my/other/*
Expect.Call(host.ListFiles(null)).IgnoreArguments().Constraints(
RMC.Is.Matching(
delegate(StDirectoryInfo dir) {
return dir.FullPath == "/my/other/";
})).Return(myOtherFiles).Repeat.Times(2);
PageInfo page = new PageInfo("page", null, DateTime.Now);
Expect.Call(host.FindPage("page")).Return(page).Repeat.Times(4);
Expect.Call(host.FindPage("inexistent-page")).Return(null).Repeat.Twice();
Expect.Call(host.ListPageAttachments(page)).Return(attachments).Repeat.Times(4);
mocks.ReplayAll();
DownloadCounter counter = new DownloadCounter();
counter.Init(host, "");
string output = counter.Format(content, null, FormattingPhase.Phase3);
Assert.IsTrue(output == @"This is a test page.
138-2-16-68" || output == @"This is a test page.
138-2-16-69", "Wrong output");
mocks.VerifyAll();
}
}
}

View file

@ -0,0 +1,18 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ScrewTurn Wiki Download Counter Plugin Tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("acebd2f0-5ca9-4898-92f5-b9a523d10aa5")]