Esempio n. 1
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>();

            document = new Document(file.Name, file.Content, DateTime.Now, "4.0");
            A.CallTo(() => recognizer.TryRecognize(file, out document))
            .WithAnyArguments().Returns(true).AssignsOutAndRefParametersLazily(x => new[] { document });
            A.CallTo(() => cryptographer.Sign(document.Content, certificate))
            .WithAnyArguments()
            .Returns(signedContent);
            A.CallTo(() => sender.TrySend(signedContent))
            .WithAnyArguments()
            .Returns(true);

            fileSender = new FileSender(cryptographer, sender, recognizer);
        }
Esempio n. 2
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. 3
0
        public void 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);
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
        public void SetUp()
        {
            fileName = "temp.file";
            now      = DateTime.Now;
            random   = new Random();

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

            A.CallTo(() => cryptographer.Sign(A <byte[]> ._, certificate))
            .Returns(GetFileContent());

            A.CallTo(() => sender.TrySend(A <byte[]> ._))
            .Returns(true);
        }
Esempio n. 6
0
        public void SetUp()
        {
            random = new Random();

            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);

            A.CallTo(() => cryptographer.Sign(A <byte[]> .Ignored, certificate))
            .Returns(GenerateFileContent());
            A.CallTo(() => sender.TrySend(A <byte[]> .Ignored))
            .Returns(true);
        }
Esempio n. 7
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);

            document = new Document(file.Name, file.Content, DateTime.Now, "4.0");
            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);


            invalidFile          = new File("invalidFile", new byte[] { 1, 2, 3 });
            invalidSignedContent = new byte[] { 1, 7 };
            invalidDocument      = new Document(invalidFile.Name, invalidFile.Content, DateTime.Now, "111.222");

            A.CallTo(() => recognizer.TryRecognize(invalidFile, out invalidDocument))
            .Returns(true);
            A.CallTo(() => cryptographer.Sign(invalidDocument.Content, certificate))
            .Returns(invalidSignedContent);
            A.CallTo(() => sender.TrySend(invalidSignedContent))
            .Returns(true);


            couldNotSendFile          = new File("invalidFile", new byte[] { 1, 2, 3 });
            couldNotSendSignedContent = new byte[] { 1, 7 };
            couldNotSendDocument      = new Document(couldNotSendFile.Name, couldNotSendFile.Content, DateTime.Now, "4.0");

            A.CallTo(() => recognizer.TryRecognize(couldNotSendFile, out couldNotSendDocument))
            .Returns(true);
            A.CallTo(() => cryptographer.Sign(couldNotSendDocument.Content, certificate))
            .Returns(couldNotSendSignedContent);
            A.CallTo(() => sender.TrySend(couldNotSendSignedContent))
            .Returns(false);
        }
Esempio n. 8
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);
            var goodDocument = new Document(file.Name, file.Content, DateTime.Now, "4.0");

            A.CallTo(() => recognizer.TryRecognize(A <File> .Ignored, out goodDocument))
            .Returns(true);
            A.CallTo(() => cryptographer.Sign(A <byte[]> .Ignored, A <X509Certificate> .Ignored))
            .Returns(signedContent);
            A.CallTo(() => sender.TrySend(A <byte[]> .Ignored))
            .Returns(true);
        }