Esempio n. 1
0
        public void Test3()
        {
            List <string>         events    = new List <string>();
            DummyConnection       c1        = new DummyConnection(events);
            DummyConnection       c2        = new DummyConnection(events);
            DummyConnection       c3        = new DummyConnection(events);
            DummyConnection       c4        = new DummyConnection(events);
            List <ActiveRequest>  requests  = new List <ActiveRequest>();
            List <SingleDownload> downloads = new List <SingleDownload>();

            requests.Add(new ActiveRequest(0, 0, 2));

            DummyNormalSingleDownload ad1            = new DummyNormalSingleDownload(c1, false, true, new bool[] { true }, requests);
            DummyNormalSingleDownload ad2            = new DummyNormalSingleDownload(c2, false, true, new bool[] { true }, new List <ActiveRequest>());
            DummyNormalSingleDownload ad3            = new DummyNormalSingleDownload(c3, false, false, new bool[] { false }, new List <ActiveRequest>());
            DummyNormalSingleDownload ad4            = new DummyNormalSingleDownload(c4, true, true, new bool[] { true }, new List <ActiveRequest>());
            DummyStorageWrapper       storageWrapper = new DummyStorageWrapper(events);

            List <InactiveRequest> inactiveRequests = new List <InactiveRequest>();

            inactiveRequests.Add(new InactiveRequest(0, 4));
            storageWrapper.ExpectFlunk = inactiveRequests;

            downloads.Add(ad1);
            downloads.Add(ad2);
            downloads.Add(ad3);
            downloads.Add(ad4);

            DummyNormalDownloader downloader        = new DummyNormalDownloader(storageWrapper, 1, downloads);
            EndGameDownloader     endgameDownloader = new EndGameDownloader(downloader);
            EndGameSingleDownload endgameDownload1  = (EndGameSingleDownload)c1.Download;
            EndGameSingleDownload endgameDownload2  = (EndGameSingleDownload)c2.Download;
            EndGameSingleDownload endgameDownload3  = (EndGameSingleDownload)c3.Download;
            EndGameSingleDownload endgameDownload4  = (EndGameSingleDownload)c4.Download;

            //assert events = [(c2, 'request', 0, 0, 2)]
            events.Clear();
            Assert.AreEqual(false, endgameDownload1.GetPiece(0, 0, new byte[] { 0, 0 }));

            //assert events = [(s, 'came in', 0, 0, 'aa'),(c2, 'request', 0, 0, 4)]

            events.Clear();
            endgameDownload4.GetUnchoke();
            //assert events = [(c4, 'request', 0,0,4)]
        }