<commit_before>library ricochetrobots.test.messages;

import 'package:unittest/unittest.dart';

import 'package:ricochetrobots/messages.dart';

void main() {
  group('messages', () {
    
    group_message();
    
  });
}

void group_message() {
  group('Message', () {
    var msg;
    
    group('default constructor', () {
      setUp(() {
        msg = new Message('client-id');
      });
      
      test('clientId-Getter', () {
        expect(msg.clientId, equals('client-id'));
      });
      
      test('type-Getter', () {
        expect(msg.type, equals('default'));
      });
      
      group('_props-Accessors', () {
        setUp(() {
          msg.propOne = 5;
          msg.propTwo = 'propTwoVal';
        });
        
        test('getter', () {
          expect(msg.propOne, equals(5));
          expect(msg.propTwo, equals('propTwoVal'));
        });
      });
    });
    
    group('fromJson constructor', () {
      setUp(() {
        msg = new Message.fromJson({
          'clientId': 'client-id',
          'propFoo': 'foo',
          'propBar': 123
        });
      });
      
      test('clientId-Getter', () {
        expect(msg.clientId, equals('client-id'));
      });
      
      test('type-Getter', () {
        expect(msg.type, equals('default'));
      });
    });
    
  });
}<commit_msg>add tests<commit_after>library ricochetrobots.test.messages;

import 'package:unittest/unittest.dart';

import 'package:ricochetrobots/messages.dart';

void main() {
  group('messages', () {
    
    group_message();
    
  });
}

void group_message() {
  group('Message', () {
    var msg;
    
    group('#default constructor', () {
      setUp(() {
        msg = new Message('client-id');
      });
      
      test('should return the clientId', () {
        expect(msg.clientId, equals('client-id'));
      });
      
      test('should return the default type as string', () {
        expect(msg.type, equals('default'));
      });
    });
    
    group('#default constructor with props', () {
      setUp(() {
        msg = new Message('client-id', {
          'propOne': 5,
          'propTwo': 'propTwoVal'
        });
      });
      
      test('should return the initial value', () {
        expect(msg.propOne, equals(5));
        expect(msg.propTwo, equals('propTwoVal'));
      });
      
      test('should return the set value', () {
        msg.propFoo = 32.2343;
        msg.propBar = 'hallo';
        expect(msg.propFoo, equals(32.2343));
        expect(msg.propBar, equals('hallo'));
      });
    });
    
    group('#fromJson constructor with no type', () {
      setUp(() {
        msg = new Message.fromJson({
          'clientId': 'my-client-id',
          'propFoo': 'foo',
          'propBar': 123
        });
      });
      
      test('it should be the default type', () {
        expect(msg is Message, equals(true));
      });
      
      test('it should return the type used in json', () {
        expect(msg.type, equals('default'));
      });
      
      test('it should return the clientId that is declared in the json', () {
        expect(msg.clientId, equals('my-client-id'));
      });
    });
    
    group('#fromJson constructor with type', () {
      setUp(() {
        msg = new Message.fromJson({
          'clientId': 'connect-client-id',
          'type': 'connectResponse',
          'propFoo': 'foo',
          'propBar': 123
        });
      });
      
      test('it should be an instance of ConnectResponseMessage', () {
        expect(msg is ConnectResponseMessage, equals(true));
      });
      
      test('it should return the type used in json', () {
        expect(msg.type, equals('connectResponse'));
      });
      
      test('clientId should be accessable', () {
        expect(msg.clientId, equals('connect-client-id'));
      });
      
      test('props should be accessable', () {
        expect(msg.propFoo, equals('foo'));
        expect(msg.propBar, equals(123));
        msg.fooBar = 'batman';
        expect(msg.fooBar, equals('batman'));
      });
    });
    
  });
}
{'fraction_non_alphanumeric': 0.1724730127576055, 'fraction_numerical': 0.0068694798822374874, 'mean_word_length': 1.9330935251798562, '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': '2324630', 'n_tokens_mistral': 1238, 'n_tokens_neox': 1214, 'n_words': 230}