<commit_before>'use strict';

var es = require('event-stream'),
    file = require('vinyl'),
    assemblyinfo = require('./index'),
    _ = require('lodash');

describe('gulp-assemblyinfo', function() {
    describe('outputFile', function() {
        describe('when no output file is set', function() {
            var asm;
            beforeEach(function() {
                asm = assemblyinfo({});
            });

            it('should throw an exception', function(cb) {
                var error;
                asm.on('error', function(err) {
                    expect(err.message).toEqual('outputFile is required');
                    cb();
                });
                asm.write();
            })
        });

        describe('when the outputFile is set', function() {
            var asm;
            beforeEach(function() {
                asm = assemblyinfo({
                    outputFile: 'info.cs'
                });
            });

            it('should set the file name', function(cb) {
                var error;
                asm.on('data', function(file) {
                    expect(file.path).toEqual('info.cs');
                    cb();
                });
                asm.write();
            })
        })
    });

    describe('when an unknown language is set', function() {
        var asm;
        beforeEach(function() {
            asm = assemblyinfo({
                outputFile: 'info.cs',
                language: 'foo'
            });
        });

        it('should throw an exception', function(cb) {
            var error;
            asm.on('error', function(err) {
                expect(err.message).toEqual('language "foo" is not recognised');
                cb();
            });
            asm.write();
        })
    });

    describe('namespaces', function() {
        var asm, lines;
        describe('when calling with no additional namespaces', function() {
            beforeEach(function(cb) {
                asm = assemblyinfo({
                    outputFile: 'info.cs'
                });

                asm.once('data', function(file){
                    lines = file.contents.toString().split('\n');
                });
                asm.write();
                cb();
            });

            it('should write default namespaces', function() {
                expect(lines[0]).toEqual('using System.Reflection;');
                expect(lines[1]).toEqual('using System.Runtime.InteropServices;');
            })
        });

        describe('when calling with additional namespaces', function(){
            beforeEach(function(cb) {
                asm = assemblyinfo({
                    outputFile: 'info.cs',
                    namespaces: ['test', 'test2', 'test']
                });

                asm.once('data', function(file){
                    console.log(file.contents.toString());
                    lines = _.where(file.contents.toString().split('\n'), function(x) {return x;});
                });
                asm.write();
                cb();
            });

            it('should filter duplicates', function() {
                expect(lines.length).toEqual(4);
            });

            it('should add additional namespaces', function(){
                expect(lines[2]).toEqual('using test;');
                expect(lines[3]).toEqual('using test2;');
            })
        });
    });

    describe('options', function() {
        var asm, lines;
        describe('when all options are set', function() {
            beforeEach(function(cb) {
                asm = assemblyinfo({
                    outputFile: 'info.cs',

                    title: 'title',
                    description: 'description',
                    companyName: 'companyName',
                    productName: 'productName',
                    copyright: 'copyright',
                    trademark: 'trademark',
                    comVisible: true,
                    comGuid: "comGuid",
                    version: "version",
                    fileVersion: "fileVersion",
                    customAttributes: {
                        'test': 'empty',
                        'test2': "value"
                    }
                });

                asm.once('data', function(file){
                    console.log(file.contents.toString());
                    lines = _.where(file.contents.toString().split('\n'), function(x) {return x;});
                });
                asm.write();
                cb();
            });

            it('should set AssemblyTitle', function() {
                assertLine('[assembly: AssemblyTitle("title")]');
            });

            it('should set AssemblyDescription', function() {
                assertLine('[assembly: AssemblyDescription("description")]');
            });<commit_msg>Removes console.log calls from test<commit_after>'use strict';

var es = require('event-stream'),
    file = require('vinyl'),
    assemblyinfo = require('./index'),
    _ = require('lodash');

describe('gulp-assemblyinfo', function() {
    describe('outputFile', function() {
        describe('when no output file is set', function() {
            var asm;
            beforeEach(function() {
                asm = assemblyinfo({});
            });

            it('should throw an exception', function(cb) {
                var error;
                asm.on('error', function(err) {
                    expect(err.message).toEqual('outputFile is required');
                    cb();
                });
                asm.write();
            })
        });

        describe('when the outputFile is set', function() {
            var asm;
            beforeEach(function() {
                asm = assemblyinfo({
                    outputFile: 'info.cs'
                });
            });

            it('should set the file name', function(cb) {
                var error;
                asm.on('data', function(file) {
                    expect(file.path).toEqual('info.cs');
                    cb();
                });
                asm.write();
            })
        })
    });

    describe('when an unknown language is set', function() {
        var asm;
        beforeEach(function() {
            asm = assemblyinfo({
                outputFile: 'info.cs',
                language: 'foo'
            });
        });

        it('should throw an exception', function(cb) {
            var error;
            asm.on('error', function(err) {
                expect(err.message).toEqual('language "foo" is not recognised');
                cb();
            });
            asm.write();
        })
    });

    describe('namespaces', function() {
        var asm, lines;
        describe('when calling with no additional namespaces', function() {
            beforeEach(function(cb) {
                asm = assemblyinfo({
                    outputFile: 'info.cs'
                });

                asm.once('data', function(file){
                    lines = file.contents.toString().split('\n');
                });
                asm.write();
                cb();
            });

            it('should write default namespaces', function() {
                expect(lines[0]).toEqual('using System.Reflection;');
                expect(lines[1]).toEqual('using System.Runtime.InteropServices;');
            })
        });

        describe('when calling with additional namespaces', function(){
            beforeEach(function(cb) {
                asm = assemblyinfo({
                    outputFile: 'info.cs',
                    namespaces: ['test', 'test2', 'test']
                });

                asm.once('data', function(file){
                    lines = _.where(file.contents.toString().split('\n'), function(x) {return x;});
                });
                asm.write();
                cb();
            });

            it('should filter duplicates', function() {
                expect(lines.length).toEqual(4);
            });

            it('should add additional namespaces', function(){
                expect(lines[2]).toEqual('using test;');
                expect(lines[3]).toEqual('using test2;');
            })
        });
    });

    describe('options', function() {
        var asm, lines;
        describe('when all options are set', function() {
            beforeEach(function(cb) {
                asm = assemblyinfo({
                    outputFile: 'info.cs',

                    title: 'title',
                    description: 'description',
                    companyName: 'companyName',
                    productName: 'productName',
                    copyright: 'copyright',
                    trademark: 'trademark',
                    comVisible: true,
                    comGuid: "comGuid",
                    version: "version",
                    fileVersion: "fileVersion",
                    customAttributes: {
                        'test': 'empty',
                        'test2': "value"
                    }
                });

                asm.once('data', function(file){
                    lines = _.where(file.contents.toString().split('\n'), function(x) {return x;});
                });
                asm.write();
                cb();
            });

            it('should set AssemblyTitle', function() {
                assertLine('[assembly: AssemblyTitle("title")]');
            });

            it('should set AssemblyDescription', function() {
                assertLine('[assembly: AssemblyDescription("description")]');
            });
{'fraction_non_alphanumeric': 0.13609898107714702, 'fraction_numerical': 0.0016635475150758993, 'mean_word_length': 1.2697026899480888, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3444364', 'n_tokens_mistral': 2346, 'n_tokens_neox': 2155, 'n_words': 466}