Sha256: 8495f116625c721da63f519d365358be63c8a1d63486892afea2ac45f40f488a

Contents?: true

Size: 1.9 KB

Versions: 8

Compression:

Stored size: 1.9 KB

Contents

# MdTranslator - minitest of
# reader / mdJson / module_additionalDocumentation

# History:
# Stan Smith 2014-12-30 original script

#set globals used in testing
#set globals used by mdJson_reader.rb before requiring module
$response = {
    readerVersionUsed: '1.0'
}

require 'minitest/autorun'
require 'json'
require 'adiwg/mdtranslator/internal/internal_metadata_obj'
require 'adiwg/mdtranslator/readers/mdJson/mdJson_reader'
$ReaderNS = ADIWG::Mdtranslator::Readers::MdJson
require 'adiwg/mdtranslator/readers/mdJson/modules_1.0/module_additionalDocumentation'

class TestReaderMdJsonAdditionalDocumentation_v1_0 < MiniTest::Test

    # get json test example
    file = File.open('test/schemas/v1_0/examples/additionalDocumentation.json', 'r')
    jsonFile = file.read
    file.close
    aIn = JSON.parse(jsonFile)
    @@hIn = aIn[0]

    # set namespace
    @@NameSpace = ADIWG::Mdtranslator::Readers::MdJson::AdditionalDocumentation

    def test_complete_additionalDocumentation_object

        hIn = @@hIn.clone
        hIn.delete('citation')

        intObj = {
            resourceType: 'resourceType',
            citation: {}
        }

        assert_equal intObj, @@NameSpace.unpack(hIn)

    end

    def test_empty_additionalDocumentation_elements

        hIn = @@hIn.clone
        hIn['resourceType'] = ''
        hIn['citation'] = {}

        intObj = {
            resourceType: nil,
            citation: {}
        }

        assert_equal intObj, @@NameSpace.unpack(hIn)

    end

    def test_missing_additionalDocumentation_citation

        # note: except for resourceType

        hIn = @@hIn.clone
        hIn.delete('citation')

        intObj = {
            resourceType: 'resourceType',
            citation: {}
        }

        assert_equal intObj, @@NameSpace.unpack(hIn)

    end

    def test_empty_additionalDocumentation_object

        hIn = {}

        assert_equal nil, @@NameSpace.unpack(hIn)

    end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
adiwg-mdtranslator-1.2.1 test/readers/mdJson/v1_0/tc_reader_mdjson_additionalDocumentation.rb
adiwg-mdtranslator-1.2.0 test/readers/mdJson/v1_0/tc_reader_mdjson_additionalDocumentation.rb
adiwg-mdtranslator-1.1.1 test/readers/mdJson/v1_0/tc_reader_mdjson_additionalDocumentation.rb
adiwg-mdtranslator-1.1.0 test/readers/mdJson/v1_0/tc_reader_mdjson_additionalDocumentation.rb
adiwg-mdtranslator-1.0.0 test/readers/mdJson/v1_0/tc_reader_mdjson_additionalDocumentation.rb
adiwg-mdtranslator-1.0.0rc4 test/readers/mdJson/v1_0/tc_reader_mdjson_additionalDocumentation.rb
adiwg-mdtranslator-1.0.0rc3 test/readers/mdJson/v1_0/tc_reader_mdjson_additionalDocumentation.rb
adiwg-mdtranslator-1.0.0rc2 test/readers/mdJson/v1_0/tc_reader_mdjson_additionalDocumentation.rb