Ejemplo n.º 1
0
        public static void Develop()
        {
            String fileNameString = "in.txt";
            {
                FileIOPermission f = new FileIOPermission(PermissionState.None);

                f.AllFiles = FileIOPermissionAccess.Write;
                f.Demand();
            }
            {
                if (File.Exists(fileNameString))
                {
                    File.Delete(fileNameString);
                }
            }
            Stream stream = new FileStream(fileNameString, FileMode.CreateNew, FileAccess.ReadWrite);

            if (true)
            {
                IBeepingWriter writer = new BeepingWriter(stream);

                for (int i = 1; i < 10; i++)
                {
                    writer.WriteBeep(new Beep((ushort)(3144 - 3100 / i), 100));
                }
            }
            if (true)
            {
                IBeepingReader reader = new BeepingReader(stream);
                var            beeps  = reader.ReadBeeps();
            }
        }
Ejemplo n.º 2
0
        public void WriteBeep_WriteNullBeep_ThrowNullReferenceException()
        {
            Stream            stream       = new MemoryStream();
            IBeeper           beeper       = new StubConsoleBeeper();
            IBeepStreamWriter streamWriter = new BeepStreamWriter();
            IBeepingWriter    writer       = new BeepingWriter(
                stream,
                beeper,
                streamWriter
                );

            Assert.ThrowsException <NullReferenceException>(
                () => {
                writer.WriteBeep(null);
            }
                );
        }
Ejemplo n.º 3
0
        public void WriteBeep_WriteSomeBeep_PositionAreEqualTo4()
        {
            Stream            stream       = new MemoryStream();
            IBeeper           beeper       = new StubConsoleBeeper();
            IBeepStreamWriter streamWriter = new BeepStreamWriter();
            IBeepingWriter    writer       = new BeepingWriter(
                stream,
                beeper,
                streamWriter
                );

            writer.WriteBeep(
                new Beep(
                    40,
                    200
                    )
                );

            Assert.AreEqual(
                4,
                stream.Position
                );
        }