Esempio n. 1
0
        public void GatherCopiesDataFileToCentralClaimStoreAndRenamesLocalDataFile()
        {
            var servantMock = new Mock <DataFileServant>();

            DataFileServant.Instance = servantMock.Object;

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

            servantMock.Setup(s => s.TryCreateDirectory(Path.Combine(Path.GetTempPath(), sut.ClaimStoreRelativePath))).Returns(true).Verifiable();
            servantMock.Setup(s => s.TryCopyFile(filePath, It.Is <string>(path => path == Path.Combine(Path.GetTempPath(), sut.ClaimStoreRelativePath)))).Returns(true).Verifiable();
            servantMock.Setup(s => s.TryMoveFile(filePath, It.Is <string>(path => path.Tokenize().State == GatheredDataFile.STATE_TOKEN))).Returns(true).Verifiable();

            sut.Gather(messageBodyMock.Object, Path.GetTempPath());

            servantMock.VerifyAll();
        }
Esempio n. 2
0
        public void GatherTransitionsToGatheredDataFileWhenOperationSucceeds()
        {
            var servantMock = new Mock <DataFileServant>();

            DataFileServant.Instance = servantMock.Object;

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

            messageBodyMock.SetupAllProperties();

            servantMock.Setup(s => s.TryCreateDirectory(Path.Combine(Path.GetTempPath(), sut.ClaimStoreRelativePath))).Returns(true);
            servantMock.Setup(s => s.TryCopyFile(filePath, It.Is <string>(path => path == Path.Combine(Path.GetTempPath(), sut.ClaimStoreRelativePath)))).Returns(true);
            servantMock.Setup(s => s.TryMoveFile(filePath, It.Is <string>(path => path.Tokenize().State == GatheredDataFile.STATE_TOKEN))).Returns(true);

            sut.Gather(messageBodyMock.Object, Path.GetTempPath());

            messageBodyMock.Object.DataFile.Should().BeOfType <GatheredDataFile>();
        }