Ejemplo n.º 1
0
        private void VerifyPasswordResult(string correctPassword, string suppliedPassword, bool expectPasswordIsCorrect)
        {
            ReadRequestMessage readRequest = new ReadRequestMessage(new DateTime(0), suppliedPassword);

            using (BookmarkableStream clientStream = ClientRequestToStream(readRequest))
            {
                MockNetworkConnection networkConnection  = new MockNetworkConnection(clientStream);
                MockFolderPackager    mockFolderPackager = new MockFolderPackager();
                MockClock             serverClock        = new MockClock(new DateTime(2007, 5, 25, 15, 27, 03));

                RequestListener folderMonitor = new RequestListener(networkConnection, mockFolderPackager, serverClock, @"c:\fakepath\fakedir", correctPassword);
                folderMonitor.ProcessNextRequest();

                clientStream.ResetToBookmark();
                FarmerMessageSerializer deserializer = new FarmerMessageSerializer();
                ReadResponseMessage     readResponse = (ReadResponseMessage)deserializer.Deserialize(clientStream);

                Assert.AreEqual(expectPasswordIsCorrect, readResponse.IsPasswordCorrect);

                if (expectPasswordIsCorrect)
                {
                    Assert.AreEqual(serverClock.GetCurrentTimeUtc(), readResponse.CurrentServerTimeUtc);
                    Assert.IsNotNull(readResponse.Data);
                }
                else
                {
                    Assert.IsNull(readResponse.Data);
                }
            }
        }
Ejemplo n.º 2
0
        private void VerifyMonitoring(DateTime startTimestampExpected, byte[] folderDataExpected)
        {
            MockFolderPackager mockFolderPackager = new MockFolderPackager();
            MockClock          serverClock        = new MockClock(new DateTime(2007, 5, 25, 15, 27, 03));

            ReadRequestMessage readRequest = new ReadRequestMessage(startTimestampExpected, CorrectPassword);

            using (BookmarkableStream clientStream = ClientRequestToStream(readRequest))
            {
                MockNetworkConnection networkConnection = new MockNetworkConnection(clientStream);
                RequestListener       folderMonitor     = new RequestListener(networkConnection, mockFolderPackager, serverClock, @"c:\fakepath\fakedir", CorrectPassword);
                folderMonitor.ProcessNextRequest();
                Assert.AreEqual(@"c:\fakepath\fakedir", mockFolderPackager.LastFolderPacked);
                Assert.AreEqual(startTimestampExpected, mockFolderPackager.LastModifiedMinimumRequested);

                clientStream.ResetToBookmark();
                FarmerMessageSerializer deserializer = new FarmerMessageSerializer();
                ReadResponseMessage     response     = (ReadResponseMessage)deserializer.Deserialize(clientStream);

                Assert.AreEqual(serverClock.GetCurrentTimeUtc(), response.CurrentServerTimeUtc);
                Assert.IsTrue(Util.ArraysEqual <byte>(folderDataExpected, response.Data));
            }
        }