public SmartphoneOutputStream(FileFactory fileFactory, string fileName) { var guid = Guid.NewGuid().ToString(); file = fileFactory.Create(fileName); fileTemp1 = fileFactory.Create(string.Format(TEMP_NAME, fileName, 1, guid)); fileTemp2 = fileFactory.Create(string.Format(TEMP_NAME, fileName, 2, guid)); fileTemp3 = fileFactory.Create(string.Format(TEMP_NAME, fileName, 3, guid)); Stream = fileTemp1.GetWritingStream(); }
public void TestInitialize() { fileFactory = Substitute.For<FileFactory>(); foo = Substitute.For<File>(); fileFactory.Create("foo").Returns(foo); fooTemp1 = Substitute.For<File>(); fileFactory.Create(Arg.Is<string>(arg => arg.StartsWith("foo_temp1_"))).Returns(fooTemp1); fooTemp2 = Substitute.For<File>(); fileFactory.Create(Arg.Is<string>(arg => arg.StartsWith("foo_temp2_"))).Returns(fooTemp2); fooTemp3 = Substitute.For<File>(); fileFactory.Create(Arg.Is<string>(arg => arg.StartsWith("foo_temp3_"))).Returns(fooTemp3); fooTemp1WritingStream = Substitute.For<System.IO.Stream>(); fooTemp1.GetWritingStream().Returns(fooTemp1WritingStream); fooTemp1ReadingStream = Substitute.For<System.IO.Stream>(); fooTemp1.GetReadingStream().Returns(fooTemp1ReadingStream); foo.Exists.Returns(true); fooTemp1ReadingStream.Length.Returns(1000); sut = new SmartphoneOutputStream(fileFactory, "foo"); }