public void ReleaseRenamesDataFileAndReleaseClaimTokenFromDatabase()
        {
            var servantMock = new Mock <DataFileServant>();

            DataFileServant.Instance = servantMock.Object;

            const string filePath        = "201306158F341A2D6FD7416B87073A0132DD51AE.chk.20150627111406.gathered";
            var          sut             = new GatheredDataFile(filePath);
            var          messageBodyMock = new Mock <MessageBody>(sut);

            servantMock.Setup(s => s.TryReleaseToken(sut.ClaimStoreRelativePath)).Returns(true).Verifiable();
            servantMock.Setup(s => s.TryMoveFile(filePath, It.Is <string>(path => path.Tokenize().State == ReleasedDataFile.STATE_TOKEN))).Returns(true).Verifiable();

            sut.Release(messageBodyMock.Object);

            servantMock.VerifyAll();
        }
        public void ReleaseTransitionsToAwaitingRetryDataFileWhenOperationFails()
        {
            var servantMock = new Mock <DataFileServant>();

            DataFileServant.Instance = servantMock.Object;

            const string filePath        = "201306158F341A2D6FD7416B87073A0132DD51AE.chk.20150627111406.gathered";
            var          sut             = new GatheredDataFile(filePath);
            var          messageBodyMock = new Mock <MessageBody>(sut);

            messageBodyMock.SetupAllProperties();

            servantMock.Setup(s => s.TryReleaseToken(sut.ClaimStoreRelativePath)).Returns(true);
            servantMock.Setup(s => s.TryMoveFile(filePath, It.IsAny <string>())).Returns(false);

            sut.Release(messageBodyMock.Object);

            Assert.That(messageBodyMock.Object.DataFile, Is.TypeOf <AwaitingRetryDataFile>());
        }