示例#1
0
        public void FindRequest_NonExistingRequest_ShouldReturnCorrectRequestEntry ()
        {
            var sut = new TitanicFileIO (Path.GetTempPath ());

            for (var i = 0; i < 10; i++)
                sut.SaveNewRequestEntry (Guid.NewGuid ()); // -> fill titanic.queue

            sut.GetRequestEntry (Guid.NewGuid ()).Should ().Be (default (RequestEntry));

            var titanicQueue = sut.TitanicQueue;
            File.Delete (titanicQueue);
        }
示例#2
0
        public void CloseRequest_ProcessedRequest_ShouldMarkRequestAppropriate ()
        {
            var path = Path.Combine (Path.GetTempPath (), ".titanic", "Close_1");
            var sut = new TitanicFileIO (path);

            for (var i = 0; i < 10; i++)
                sut.SaveNewRequestEntry (Guid.NewGuid ()); // -> fill titanic.queue

            var req = sut.GetRequestEntries (null).Skip (3).First ();

            sut.SaveProcessedRequestEntry (req);

            sut.CloseRequest (req.RequestId);

            sut.GetRequestEntries (null)
                     .Count (re => re.State == RequestEntry.Is_Closed)
                     .Should ()
                     .Be (1, "because only one request has been processed.");

            sut.GetRequestEntry (req.RequestId).State.Should ().Be (RequestEntry.Is_Closed);

            Directory.Delete (sut.TitanicDirectory, true);
        }
示例#3
0
        public void FindRequest_ExistingRequest_ShouldReturnCorrectRequestEntry ()
        {
            var sut = new TitanicFileIO (Path.GetTempPath ());

            for (var i = 0; i < 10; i++)
                sut.SaveNewRequestEntry (Guid.NewGuid ()); // -> fill titanic.queue

            var requests = sut.GetRequestEntries (null).ToArray ();

            var req = requests.Skip (3).First ();

            sut.GetRequestEntry (req.RequestId).Should ().Be (req, "because it was searched.");

            var titanicQueue = sut.TitanicQueue;
            File.Delete (titanicQueue);
        }