Ejemplo n.º 1
0
        public void GetSizeOfBloomdFile_Works()
        {
            // Setup
            WebSocketServerSpy spy;
            var progress         = CreateWebSocketProgress(out spy);
            var testUsbPublisher = new MockUsbPublisher(progress, _bookServer);

            testUsbPublisher.SetExceptionToThrow(MockUsbPublisher.ExceptionToThrow.HandleDeviceFull);

            var book       = CreateBookWithPhysicalFile(ThreePageHtml);
            var bloomdPath = MakeFakeBloomdFile(book);

            testUsbPublisher.SetLastBloomdFileSize(bloomdPath);

            // SUT
            var size = testUsbPublisher.GetStoredBloomdFileSize();

            Assert.AreEqual("0.1", size);
        }
Ejemplo n.º 2
0
        public void SendBookAsync_HandlesDeviceHungException()
        {
            // Setup
            WebSocketServerSpy spy;
            var progress         = CreateWebSocketProgress(out spy);
            var testUsbPublisher = new MockUsbPublisher(progress, _bookServer);

            testUsbPublisher.SetExceptionToThrow(MockUsbPublisher.ExceptionToThrow.DeviceHung);

            // SUT
            testUsbPublisher.SendBookAsync(s_bookSelection.CurrentSelection, Color.Aqua);

            // Allow async method to complete
            HangoutAwhile();

            // Unfortunately, using the MockUsbPublisher to throw our exception in SendBookDoWork also
            // means we aren't testing the code that figures out the size of the book. At least it's predictable!
            const string message =
                "<span style='color:red'>The device reported that it does not have enough space for this book. The book is of unknown MB.</span>";

            Assert.AreEqual(message, spy.Events.First().Value.Item1);
        }