コード例 #1
0
        public void PullTest()
        {
            ReadResponseMessage readResponse = new ReadResponseMessage();

            readResponse.IsPasswordCorrect    = true;
            readResponse.CurrentServerTimeUtc = new DateTime(2012, 1, 23);
            readResponse.Data = new byte[] { 0xaa, 0xbb };

            MockFolderUnpacker folderUnpacker = new MockFolderUnpacker();

            using (Stream responseStream = ServerResponseToStream(readResponse))
            {
                FilePuller filePuller = new FilePuller(folderUnpacker, "the_r1ght_passw0rd");

                const string destinationFolderExpected = @"c:\pulledfiles\";

                filePuller.Pull(responseStream, destinationFolderExpected);

                Assert.AreEqual(destinationFolderExpected, folderUnpacker.LastDestinationFolder);

                Assert.AreEqual(readResponse.CurrentServerTimeUtc, filePuller.LastPullTime);

                Assert.IsTrue(Util.ArraysEqual <byte>(new byte[] { 0xaa, 0xbb }, folderUnpacker.LastPackedData));
            }
        }
コード例 #2
0
        public void InvalidPasswordPullTest()
        {
            ReadResponseMessage serverResponseMessage = new ReadResponseMessage();

            serverResponseMessage.IsPasswordCorrect = false;

            using (Stream responseStream = ServerResponseToStream(serverResponseMessage))
            {
                MockFolderUnpacker folderUnpacker = new MockFolderUnpacker();

                FilePuller filePuller = new FilePuller(folderUnpacker, "the_wr0ng_passw0rd");

                filePuller.Pull(responseStream, @"c:\fakedestination");

                //
                // Verify that client gracefully handles rejected passwords and does not try to download more data
                //

                Assert.IsNull(folderUnpacker.LastDestinationFolder);
                Assert.IsNull(folderUnpacker.LastPackedData);
            }
        }