本文整理汇总了C#中ReplaySubject.Buffer方法的典型用法代码示例。如果您正苦于以下问题:C# ReplaySubject.Buffer方法的具体用法?C# ReplaySubject.Buffer怎么用?C# ReplaySubject.Buffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReplaySubject
的用法示例。
在下文中一共展示了ReplaySubject.Buffer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyReleasesWithDeltaReleases
public void ApplyReleasesWithDeltaReleases()
{
string tempDir;
using (Utility.WithTempDirectory(out tempDir)) {
Directory.CreateDirectory(Path.Combine(tempDir, "theApp", "packages"));
new[] {
"Shimmer.Core.1.0.0.0-full.nupkg",
"Shimmer.Core.1.1.0.0-delta.nupkg",
"Shimmer.Core.1.1.0.0-full.nupkg",
}.ForEach(x => File.Copy(IntegrationTestHelper.GetPath("fixtures", x), Path.Combine(tempDir, "theApp", "packages", x)));
var fixture = new UpdateManager("http://lol", "theApp", FrameworkVersion.Net40, tempDir, null, new FakeUrlDownloader());
var baseEntry = ReleaseEntry.GenerateFromFile(Path.Combine(tempDir, "theApp", "packages", "Shimmer.Core.1.0.0.0-full.nupkg"));
var deltaEntry = ReleaseEntry.GenerateFromFile(Path.Combine(tempDir, "theApp", "packages", "Shimmer.Core.1.1.0.0-delta.nupkg"));
var latestFullEntry = ReleaseEntry.GenerateFromFile(Path.Combine(tempDir, "theApp", "packages", "Shimmer.Core.1.1.0.0-full.nupkg"));
var updateInfo = UpdateInfo.Create(baseEntry, new[] { deltaEntry, latestFullEntry }, "dontcare", FrameworkVersion.Net40);
updateInfo.ReleasesToApply.Contains(deltaEntry).ShouldBeTrue();
using (fixture) {
var progress = new ReplaySubject<int>();
fixture.ApplyReleases(updateInfo, progress).First();
this.Log().Info("Progress: [{0}]", String.Join(",", progress));
progress.Buffer(2,1).All(x => x.Count != 2 || x[1] > x[0]).First().ShouldBeTrue();
progress.Last().ShouldEqual(100);
}
var filesToFind = new[] {
new {Name = "NLog.dll", Version = new Version("2.0.0.0")},
new {Name = "NSync.Core.dll", Version = new Version("1.1.0.0")},
new {Name = "Ionic.Zip.dll", Version = new Version("1.9.1.8")},
};
filesToFind.ForEach(x => {
var path = Path.Combine(tempDir, "theApp", "app-1.1.0.0", x.Name);
this.Log().Info("Looking for {0}", path);
File.Exists(path).ShouldBeTrue();
var vi = FileVersionInfo.GetVersionInfo(path);
var verInfo = new Version(vi.FileVersion ?? "1.0.0.0");
x.Version.ShouldEqual(verInfo);
});
}
}
示例2: DownloadReleasesFromFileDirectoryIntegrationTest
public void DownloadReleasesFromFileDirectoryIntegrationTest()
{
string tempDir = null;
var updateDir = new DirectoryInfo(IntegrationTestHelper.GetPath("..", "SampleUpdatingApp", "SampleReleasesFolder"));
var entriesToDownload = updateDir.GetFiles("*.nupkg")
.Select(x => ReleaseEntry.GenerateFromFile(x.FullName))
.ToArray();
entriesToDownload.Count().ShouldBeGreaterThan(0);
using (Utility.WithTempDirectory(out tempDir)) {
// NB: This is normally done by CheckForUpdates, but since
// we're skipping that in the test we have to do it ourselves
Directory.CreateDirectory(Path.Combine(tempDir, "SampleUpdatingApp", "packages"));
var fixture = new UpdateManager(updateDir.FullName, "SampleUpdatingApp", FrameworkVersion.Net40, tempDir);
using (fixture) {
var progress = new ReplaySubject<int>();
fixture.DownloadReleases(entriesToDownload, progress).First();
this.Log().Info("Progress: [{0}]", String.Join(",", progress));
progress.Buffer(2,1).All(x => x.Count != 2 || x[1] > x[0]).First().ShouldBeTrue();
progress.Last().ShouldEqual(100);
}
entriesToDownload.ForEach(x => {
this.Log().Info("Looking for {0}", x.Filename);
var actualFile = Path.Combine(tempDir, "SampleUpdatingApp", "packages", x.Filename);
File.Exists(actualFile).ShouldBeTrue();
var actualEntry = ReleaseEntry.GenerateFromFile(actualFile);
actualEntry.SHA1.ShouldEqual(x.SHA1);
actualEntry.Version.ShouldEqual(x.Version);
});
}
}
示例3: DownloadReleasesFromHttpServerIntegrationTest
public void DownloadReleasesFromHttpServerIntegrationTest()
{
string tempDir = null;
var updateDir = new DirectoryInfo(IntegrationTestHelper.GetPath("..", "SampleUpdatingApp", "SampleReleasesFolder"));
IDisposable disp;
try {
var httpServer = new StaticHttpServer(30405, updateDir.FullName);
disp = httpServer.Start();
}
catch (HttpListenerException) {
Assert.False(true, @"Windows sucks, go run 'netsh http add urlacl url=http://+:30405/ user=MYMACHINE\MyUser");
return;
}
var entriesToDownload = updateDir.GetFiles("*.nupkg")
.Select(x => ReleaseEntry.GenerateFromFile(x.FullName))
.ToArray();
entriesToDownload.Count().ShouldBeGreaterThan(0);
using (disp)
using (Utility.WithTempDirectory(out tempDir)) {
// NB: This is normally done by CheckForUpdates, but since
// we're skipping that in the test we have to do it ourselves
Directory.CreateDirectory(Path.Combine(tempDir, "SampleUpdatingApp", "packages"));
var fixture = new UpdateManager("http://localhost:30405", "SampleUpdatingApp", FrameworkVersion.Net40, tempDir);
using (fixture) {
var progress = new ReplaySubject<int>();
fixture.DownloadReleases(entriesToDownload, progress).First();
this.Log().Info("Progress: [{0}]", String.Join(",", progress));
progress.Buffer(2,1).All(x => x.Count != 2 || x[1] > x[0]).First().ShouldBeTrue();
progress.Last().ShouldEqual(100);
}
entriesToDownload.ForEach(x => {
this.Log().Info("Looking for {0}", x.Filename);
var actualFile = Path.Combine(tempDir, "SampleUpdatingApp", "packages", x.Filename);
File.Exists(actualFile).ShouldBeTrue();
var actualEntry = ReleaseEntry.GenerateFromFile(actualFile);
actualEntry.SHA1.ShouldEqual(x.SHA1);
actualEntry.Version.ShouldEqual(x.Version);
});
}
}
示例4: ApplyReleaseWhichMovesAFileToADifferentDirectory
public void ApplyReleaseWhichMovesAFileToADifferentDirectory()
{
string tempDir;
using (Utility.WithTempDirectory(out tempDir))
{
string packagesDir = Path.Combine(tempDir, "theApp", "packages");
Directory.CreateDirectory(packagesDir);
new[] {
"Squirrel.Core.1.1.0.0-full.nupkg",
"Squirrel.Core.1.3.0.0-full.nupkg",
}.ForEach(x => File.Copy(IntegrationTestHelper.GetPath("fixtures", x), Path.Combine(packagesDir, x)));
var fixture = new UpdateManager("http://lol", "theApp", FrameworkVersion.Net40, tempDir, null, new FakeUrlDownloader());
var baseEntry = ReleaseEntry.GenerateFromFile(Path.Combine(packagesDir, "Squirrel.Core.1.1.0.0-full.nupkg"));
var latestFullEntry = ReleaseEntry.GenerateFromFile(Path.Combine(packagesDir, "Squirrel.Core.1.3.0.0-full.nupkg"));
var updateInfo = UpdateInfo.Create(baseEntry, new[] { latestFullEntry }, packagesDir, FrameworkVersion.Net40);
updateInfo.ReleasesToApply.Contains(latestFullEntry).ShouldBeTrue();
using (fixture) {
var progress = new ReplaySubject<int>();
fixture.ApplyReleases(updateInfo, progress).First();
this.Log().Info("Progress: [{0}]", String.Join(",", progress));
progress.Buffer(2, 1).All(x => x.Count != 2 || x[1] > x[0]).First().ShouldBeTrue();
progress.Last().ShouldEqual(100);
}
var rootDirectory = Path.Combine(tempDir, "theApp", "app-1.3.0.0");
new[] {
new {Name = "NLog.dll", Version = new Version("2.0.0.0")},
new {Name = "NSync.Core.dll", Version = new Version("1.1.0.0")},
}.ForEach(x =>
{
var path = Path.Combine(rootDirectory, x.Name);
this.Log().Info("Looking for {0}", path);
File.Exists(path).ShouldBeTrue();
});
var oldFile = Path.Combine(rootDirectory, "sub", "Ionic.Zip.dll");
File.Exists(oldFile).ShouldBeFalse();
var newFile = Path.Combine(rootDirectory, "other", "Ionic.Zip.dll");
File.Exists(newFile).ShouldBeTrue();
}
}