public void UnlockDoesNotTransitionToNewStateWhenOperationSucceeds()
        {
            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.TryDeleteFile(filePath)).Returns(true);

            sut.Unlock(messageBodyMock.Object);

            Assert.That(messageBodyMock.Object.DataFile, Is.SameAs(sut));
        }
        public void UnlockTransitionsToAwaitingRetryDataFileWhenOperationFails()
        {
            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.TryDeleteFile(filePath)).Returns(false);

            sut.Unlock(messageBodyMock.Object);

            Assert.That(messageBodyMock.Object.DataFile, Is.TypeOf <AwaitingRetryDataFile>());
        }
        public void UnlockDeletesDataFile()
        {
            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.TryDeleteFile(filePath)).Returns(true).Verifiable();

            sut.Unlock(messageBodyMock.Object);

            servantMock.VerifyAll();
        }