Пример #1
0
        public async Task SaveSourceFiles_GivenSourceFiles_CompressesAndSaves()
        {
            //Arrange
            IEnumerable <SourceFile> sourceFiles = new[]
            {
                new SourceFile {
                    FileName = "project.vbproj", SourceCode = "<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><TargetFramework>netcoreapp2.0</TargetFramework></PropertyGroup></Project>"
                },
                new SourceFile {
                    FileName = "ExampleClass.vb", SourceCode = "Public Class ExampleClass\nPublic Property ProviderType() As String\nEnd Class"
                },
                new SourceFile {
                    FileName = "Calculation.vb", SourceCode = "code"
                }
            };

            ISourceFileRepository sourceFileRepository = CreateSourceFileRepository();

            SourceCodeService sourceCodeService = CreateSourceCodeService(sourceFileRepository);

            //Act
            await sourceCodeService.SaveSourceFiles(sourceFiles, specificationId, SourceCodeType.Release);

            //Assert
            await
            sourceFileRepository
            .Received(1)
            .SaveSourceFiles(Arg.Any <byte[]>(), Arg.Is(specificationId), Arg.Is("release"));
        }
Пример #2
0
        public async Task SaveSourceFiles_GivenEmptySourceFiles_LogsAndDoesNotSave()
        {
            //Arrange
            IEnumerable <SourceFile> sourceFiles = Enumerable.Empty <SourceFile>();

            ISourceFileRepository sourceFileRepository = CreateSourceFileRepository();

            ILogger logger = CreateLogger();

            SourceCodeService sourceCodeService = CreateSourceCodeService(sourceFileRepository, logger);

            //Act
            await sourceCodeService.SaveSourceFiles(sourceFiles, specificationId, SourceCodeType.Preview);

            //Assert
            await
            sourceFileRepository
            .DidNotReceive()
            .SaveSourceFiles(Arg.Any <byte[]>(), Arg.Is(specificationId), Arg.Is("preview"));

            logger
            .Received(1)
            .Error($"Failed to compress source files for specification id: '{specificationId}'");
        }