Esempio n. 1
0
        public void Test_ValidateJSONWithBadData()
        {
            // arrange
            var sut        = new JSONAdapter();
            var schema     = new JSONSchemas();
            var testString = @"{
               CPU: 'Intel',
               Drives: [
                  'DVD read/writer',
                  '500 gigabyte hard drive'
               ]
         }";

            // act
            var actual = sut.ValidateJSON(testString, schema.SchemaDnD);

            // assert
            Assert.False(actual);
        }
Esempio n. 2
0
        public void Test_LoadWithBadDataReturnsNull()
        {
            // arrange
            var sut        = new JSONAdapter();
            var schema     = new JSONSchemas();
            var testString = @"{
               CPU: 'Intel',
               Drives: [
                  'DVD read/writer',
                  '500 gigabyte hard drive'
               ]
         }";

            // act
            var actual = sut.Load(testString);

            // assert
            Assert.Null(actual);
        }
Esempio n. 3
0
        public void Test_LoadWithGoodDataReturnsCharacter()
        {
            // arrange
            var sut        = new JSONAdapter();
            var schema     = new JSONSchemas();
            var testString = @"{
            'Name': 'Geralt of Rivia',
            'Race': 'Mutant',
            'CharacterClass': 'Witcher',
            'Level': 100,
            'Strength': 18,
            'Intelligence': 16,
            'Dexterity': 22,
            'Wisdom': 16,
            'Charisma': 12,
            'Constitution': 18
         }";

            // act
            var actual = sut.Load(testString);

            // assert
            Assert.IsType <Character>(actual);
        }
Esempio n. 4
0
        public void Test_ValidateJSONWithGoodData()
        {
            //arrange
            var sut        = new JSONAdapter();
            var schema     = new JSONSchemas();
            var testString = @"{
            'Name': 'Geralt of Rivia',
            'Race': 'Mutant',
            'CharacterClass': 'Witcher',
            'Level': 100,
            'Strength': 18,
            'Intelligence': 16,
            'Dexterity': 22,
            'Wisdom': 16,
            'Charisma': 12,
            'Constitution': 18
         }";

            // act
            var actual = sut.ValidateJSON(testString, schema.SchemaDnD);

            // assert
            Assert.True(actual);
        }
Esempio n. 5
0
        public void TestImportExport()
        {
            // Setup: Create a NailsMap
            NailsMap map = new NailsMap();

            // Mark a location
            map.MarkLocation("TestStyle", 0, 1, 0);

            // Create a new JSON adapter
            JSONAdapter adapter = new JSONAdapter("testoutput.json");

            // Export the map
            adapter.Export(map);

            // Import the map
            var newMap = adapter.Import();

            // Compare
            Assert.IsNotNull(newMap);
            NailsCube cube = newMap.GetCube(0, 1, 0);

            Assert.IsNotNull(cube);
            Assert.AreEqual("TestStyle", cube.StyleName);
        }