コード例 #1
0
        public void ClassifierWithSystemTypes_ConvertFromDto_MissingSystemTypesAreAdded()
        {
            _classifiers = new ClassifierDictionary();
            // act: convert dtos to classifier types
            _converter = new DomainDtoConverter();
            _converter.ToDomain(new Diagram(_classifiers),new DiagramDataDto {Classifiers = new List<ClassifierDto>()});

            Assert.AreEqual(new SystemTypes().Count(), _classifiers.Count);
        }
コード例 #2
0
 public void LoadSystemTypes_AddMissingSystemTypes()
 {
     // Arrange
     var dtos = new List<ClassifierDto> { StringDto };
     var converter = new DomainDtoConverter();
     // Act
     converter.ToDomain(new Diagram(_classifierDictionary), new DiagramDataDto { Classifiers = dtos });
     // Assert => one system type was loaded, the other ones should be added automatically
     Assert.AreEqual(new SystemTypes().Count(),_classifierDictionary.Count);
 }
コード例 #3
0
        public void Classifiers_ConvertToDto_KeepReferences()
        {
            // Arrange
            var dtos = new List<ClassifierDto> { StringDto, IntegerDto };
            var converter = new DomainDtoConverter();
            // Act
            converter.ToDomain(new Diagram(_classifierDictionary), new DiagramDataDto {Classifiers = dtos});

            // ensure that properties use the same object references
            // as the classifier dictionary
            Assert.AreEqual(
                _classifierDictionary.ElementAt(0), 
                _classifierDictionary.ElementAt(1).Properties.ElementAt(0).Type);
            Assert.AreEqual(_classifierDictionary.ElementAt(1),
                _classifierDictionary.ElementAt(0).Properties.ElementAt(0).Type);
        }
コード例 #4
0
 public void LoadClassifiers_SystemTypeReferences_AreCorrect()
 {
     const string classifierName = "ClassifierWithSystemType";
     // Arrange
     var dtoWithSystemTypeProperty = new ClassifierDto
     {
         Name = classifierName,
         Properties = new List<PropertyDto>{new PropertyDto {Name = "Property", Type = StringDto}}
     };
     var dtos = new List<ClassifierDto> { dtoWithSystemTypeProperty,StringDto };
     var converter = new DomainDtoConverter();
     // Act
     converter.ToDomain(new Diagram(_classifierDictionary), new DiagramDataDto { Classifiers = dtos });
     // Assert => ensure that the instance of String is always the same in the dictionary
     Assert.AreEqual(
         _classifierDictionary.String,
         _classifierDictionary.FindByName(classifierName).Properties.Single().Type);
 }
コード例 #5
0
 public void Methods_ConvertToDtoAndDomain()
 {
     // Arrange
     var dtos = new List<ClassifierDto> {VoidDto, StringDto, ServiceDto};
     var converter = new DomainDtoConverter();
     // Act
     converter.ToDomain(new Diagram(_classifierDictionary), new DiagramDataDto { Classifiers = dtos });
     // Assert return type has correct reference
     Assert.AreEqual(
         _classifierDictionary.Void,
         _classifierDictionary
             .FindByName(Service.Name)
             .Methods.ElementAt(0).ReturnType);
     // Assert parameters have correct reference
     Assert.AreEqual(
         _classifierDictionary.String,
         _classifierDictionary
             .FindByName(Service.Name)
             .Methods.ElementAt(0)
             .Parameters.ElementAt(0).Type);
 }
コード例 #6
0
 protected override void Init()
 {
     _converter = new DomainDtoConverter();
 }
コード例 #7
0
 /// <summary>
 /// loads the given data in json format and stores it in the given classifier dictionary
 /// </summary>
 public void Load(JsonContent jsonContent,Diagram diagram)
 {
     var toDomainConverter = new DomainDtoConverter();
     var diagramDto = LoadDto(jsonContent);
     toDomainConverter.ToDomain(diagram, diagramDto);            
 }
コード例 #8
0
 public JsonContent Save(Diagram diagram)
 {
     var toDtoConverter = new DomainDtoConverter();
     var diagramDto = toDtoConverter.ToDto(diagram);
     return SaveDto(diagramDto);
 }