Esempio n. 1
0
        public void Send_WhenGoodFormat(string format)
        {
            document.Format = format;

            fileSender.SendFiles(new[] { file }, certificate)
            .SkippedFiles.Should().BeEmpty();
        }
Esempio n. 2
0
 public void Send_WhenGoodFormat(string format)
 {
     document = new Document("Doc", new byte[] { 1, 2, 3 }, DateTime.Now, format);
     fileSender.SendFiles(new[] { file }, certificate)
     .SkippedFiles.Should().BeEmpty();
     A.CallTo(() => sender.TrySend(A <byte[]> .Ignored))
     .MustHaveHappened(Repeated.Exactly.Once);
 }
Esempio n. 3
0
        public void SetUp()
        {
            // Постарайтесь вынести в SetUp всё неспецифическое конфигурирование так,
            // чтобы в конкретных тестах осталась только специфика теста,
            // без конфигурирования "обычного" сценария работы

            file          = new File("someFile", new byte[] { 1, 2, 3 });
            signedContent = new byte[] { 1, 7 };

            cryptographer = A.Fake <ICryptographer>();
            sender        = A.Fake <ISender>();
            recognizer    = A.Fake <IRecognizer>();
            fileSender    = new FileSender(cryptographer, sender, recognizer);


            idealDocument = new Document(idealFile.Name, idealFile.Content, idealDate, idealFormat);

            A.CallTo(() => recognizer.TryRecognize(idealFile, out idealDocument))
            .Returns(true);
            A.CallTo(() => cryptographer.Sign(idealDocument.Content, certificate))
            .Returns(idealSignedContent);
            A.CallTo(() => sender.TrySend(idealSignedContent))
            .Returns(true);


            fileSender.SendFiles(new[] { idealFile }, certificate)
            .SkippedFiles.Should().BeEmpty();
        }
Esempio n. 4
0
        public void Send_WhenGoodFormat(string format)
        {
            var document = new Document(file.Name, file.Content, DateTime.Now, format);

            A.CallTo(() => recognizer.TryRecognize(A <File> .Ignored, out document))
            .Returns(true);

            fileSender.SendFiles(new[] { file }, certificate)
            .SkippedFiles.Should().BeEmpty();
        }
Esempio n. 5
0
        public void Send_WhenGoodFormat(string format)
        {
            var document = new Document(file.Name, file.Content, DateTime.Now, format);

            A.CallTo(() => recognizer.TryRecognize(file, out document)).Returns(true);
            A.CallTo(() => cryptographer.Sign(document.Content, certificate)).Returns(signedContent);
            A.CallTo(() => sender.TrySend(signedContent)).Returns(true);

            fileSender.SendFiles(new[] { file }, certificate).SkippedFiles.Should().BeEmpty();
        }
Esempio n. 6
0
        public void Send_WhenGoodFormat(string format)
        {
            document = new Document(document.Name, document.Content,
                                    document.Created, format);

            fileSender.SendFiles(new[] { file }, certificate)
            .SkippedFiles.Should().BeEmpty();
        }
Esempio n. 7
0
        public void Skip_WhenBadFormat()
        {
            var document = new Document(file.Name, file.Content, DateTime.Now, "");

            A.CallTo(() => recognizer.TryRecognize(file, out document))
            .Returns(true);
            var result = fileSender.SendFiles(new[] { file }, certificate)
                         .SkippedFiles;

            result.Length.Should().Be(1);
            result.Should().Contain(file);
        }
Esempio n. 8
0
        public void Send_WhenGoodFormat(string format)
        {
            var document = new Document(fileName, GetFileContent(), now, format);
            var file     = GetFileRecognized(document);
            var signed   = GetSigned(document);

            A.CallTo(() => recognizer.TryRecognize(file, out document))
            .Returns(true);

            A.CallTo(() => sender.TrySend(signed))
            .Returns(true);

            var sendingResult = fileSender.SendFiles(new[] { file }, certificate);

            sendingResult.SkippedFiles.Should().BeEmpty();
            A.CallTo(() => sender.TrySend(signed)).MustHaveHappened();
        }