Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit344308d

Browse files
Add test for switching to writable stream
1 parent575b18f commit344308d

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

‎OpenMcdf.Tests/RootStorageTests.cs

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public void SwitchStream(Version version, int subStorageCount)
148148
[DataRow(Version.V4,1)]
149149
[DataRow(Version.V4,2)]
150150
[DataRow(Version.V4,32)]// Required 2 sectors including root
151-
publicvoidSwitchFile(Versionversion,intsubStorageCount)
151+
publicvoidSwitchToFile(Versionversion,intsubStorageCount)
152152
{
153153
stringfileName=Path.GetTempFileName();
154154

@@ -177,6 +177,52 @@ public void SwitchFile(Version version, int subStorageCount)
177177
}
178178
}
179179

180+
[TestMethod]
181+
[DataRow(Version.V3,0)]
182+
[DataRow(Version.V3,1)]
183+
[DataRow(Version.V3,2)]
184+
[DataRow(Version.V3,4)]
185+
[DataRow(Version.V4,0)]
186+
[DataRow(Version.V4,1)]
187+
[DataRow(Version.V4,2)]
188+
[DataRow(Version.V4,4)]
189+
publicvoidSwitchToWritableStream(Versionversion,intstreamCount)
190+
{
191+
stringfileName=Path.GetTempFileName();
192+
193+
vardata=TestData.CreateByteArray(1024);
194+
195+
try
196+
{
197+
using(varrootStorage=RootStorage.CreateInMemory(version))
198+
{
199+
for(inti=0;i<streamCount;i++)
200+
{
201+
usingCfbStreamstream=rootStorage.CreateStream($"Test{i}");
202+
stream.Write(data,0,data.Length);
203+
}
204+
205+
rootStorage.SwitchTo(fileName);
206+
}
207+
208+
usingMemoryStreammemoryStream=new();
209+
using(varrootStorage=RootStorage.OpenRead(fileName))
210+
{
211+
rootStorage.SwitchTo(memoryStream);
212+
213+
IEnumerable<EntryInfo>entries=rootStorage.EnumerateEntries();
214+
Assert.AreEqual(streamCount,entries.Count());
215+
216+
for(inti=0;i<streamCount;i++)
217+
rootStorage.Delete($"Test{i}");
218+
}
219+
}
220+
finally
221+
{
222+
try{File.Delete(fileName);}catch{}
223+
}
224+
}
225+
180226
[TestMethod]
181227
[DataRow(Version.V3,0)]
182228
[DataRow(Version.V3,1)]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp